changeset 27217:54de7746e148

Transform id-less <img> tags to links using src and alt attributes. Closes #8628. committer: Paul Aurich <paul@darkrain42.org>
author dmitry.petroff@gmail.com
date Sun, 21 Jun 2009 22:17:14 +0000
parents 77cfaae36918
children f97cc05bf3b7 2967cea30d8b
files COPYRIGHT ChangeLog pidgin/gtkimhtml.c
diffstat 3 files changed, 18 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/COPYRIGHT	Sun Jun 21 21:26:59 2009 +0000
+++ b/COPYRIGHT	Sun Jun 21 22:17:14 2009 +0000
@@ -332,6 +332,7 @@
 Luke Petre
 Diego Petten
 Nathan Peterson
+Dmitry Petroff
 Sebastián E. Peyrott
 Andrea Piccinelli
 Celso Pinto
--- a/ChangeLog	Sun Jun 21 21:26:59 2009 +0000
+++ b/ChangeLog	Sun Jun 21 22:17:14 2009 +0000
@@ -94,6 +94,8 @@
 	* Support saving animated custom smileys as animated images or animated
 	  custom smileys. (Andrea Piccinelli)
 	* Support for keyboard navigation on the status icon. (Li Yuan)
+	* IMG tags without 'id' attributes are turned into links to the image URL.
+	  (Dmitry Petroff)
 
 	Finch:
 	* The hardware cursor is updated correctly. This will be useful
--- a/pidgin/gtkimhtml.c	Sun Jun 21 21:26:59 2009 +0000
+++ b/pidgin/gtkimhtml.c	Sun Jun 21 22:17:14 2009 +0000
@@ -2996,10 +2996,21 @@
 							break;
 
 						id = gtk_imhtml_get_html_opt(tag, "ID=");
-						if (!id)
-							break;
-						gtk_imhtml_insert_image_at_iter(imhtml, atoi(id), iter);
-						g_free(id);
+						if (id) {
+							gtk_imhtml_insert_image_at_iter(imhtml, atoi(id), iter);
+							g_free(id);
+						} else {
+							char *src, *alt;
+							src = gtk_imhtml_get_html_opt(tag, "SRC=");
+							alt = gtk_imhtml_get_html_opt(tag, "ALT=");
+							if (src) {
+								gtk_imhtml_toggle_link(imhtml, src);
+								gtk_text_buffer_insert(imhtml->text_buffer, iter, alt ? alt : src, -1);
+								gtk_imhtml_toggle_link(imhtml, NULL);
+							}
+							g_free (src);
+							g_free (alt);
+						}
 						break;
 					}
 				case 47:	/* P (opt) */