[evolution-patches] Bounty Hunt patch: Better smiley substitution in the composer (Updated)



Hi,

this is a patch for http://bugzilla.gnome.org/show_bug.cgi?id=127533.
This patch makes it possible to replace the smiley with the original text by
pressing the backspace key.

Regards
	Jan Arne Petersen

-- 
Jan Arne Petersen <jpetersen uni-bonn de>
Index: src/ChangeLog
===================================================================
RCS file: /cvs/gnome/gtkhtml/src/ChangeLog,v
retrieving revision 1.1908
diff -u -r1.1908 ChangeLog
--- src/ChangeLog	23 Nov 2003 23:39:02 -0000	1.1908
+++ src/ChangeLog	1 Dec 2003 22:48:54 -0000
@@ -1,3 +1,13 @@
+2003-12-01  Jan Arne Petersen  <jpetersen uni-bonn de>
+
+	* htmlengine-edit-cut-and-paste.c: (use_pictograms): store
+	the replaced text in the picto member.
+	(html_engine_delete_n): replace the smiley with the original text
+	when a smiley is deleted.
+	* htmlimage.[ch]: (destroy), (copy), (html_image_init),
+	(html_image_set_picto): add a picto member which contains the text
+	which was replaced with the smiley image.
+
 2003-11-24  Radek Doulik  <rodo ximian com>
 
 	* htmlgdkpainter.c (item_gc): set a default color
Index: src/htmlengine-edit-cut-and-paste.c
===================================================================
RCS file: /cvs/gnome/gtkhtml/src/htmlengine-edit-cut-and-paste.c,v
retrieving revision 1.96
diff -u -r1.96 htmlengine-edit-cut-and-paste.c
--- src/htmlengine-edit-cut-and-paste.c	3 Oct 2003 16:12:26 -0000	1.96
+++ src/htmlengine-edit-cut-and-paste.c	1 Dec 2003 22:48:57 -0000
@@ -1265,6 +1265,7 @@
 		picto = html_image_new (e->image_factory, filename, NULL, NULL, -1, -1, FALSE, FALSE, 0, NULL,
 					HTML_VALIGN_MIDDLE, FALSE);
 		html_image_set_alt (HTML_IMAGE (picto), alt);
+		html_image_set_picto (HTML_IMAGE (picto), alt);
 		g_free (alt);
 		html_engine_paste_object (e, picto, html_object_get_length (picto));
 	}
@@ -1380,6 +1381,24 @@
 		html_engine_set_mark (e);
 		html_engine_update_selection_if_necessary (e);
 		html_engine_freeze (e);
+		/* Remove magic smiley */
+		if (!forward && len == 1 && gtk_html_get_magic_smileys (e->widget)) {
+			HTMLObject *object = html_object_get_tail_leaf (e->cursor->object);
+
+			if (HTML_IS_IMAGE (object) && HTML_IMAGE (object)->picto != NULL) {
+				gchar *picto = g_strdup ( HTML_IMAGE (object)->picto);
+				html_undo_level_begin (e->undo, "Remove Magic Smiley", "Undo Remove Magic Smiley");
+				html_cursor_backward (e->cursor, e);
+				html_engine_delete (e);
+				html_engine_insert_text (e, picto, -1);
+				html_undo_level_end (e->undo);
+				g_free (picto);
+
+				html_engine_unblock_selection (e);
+				html_engine_thaw (e);
+				return;
+			}
+		}
 		while (len != 0) {
 			if (forward)
 				html_cursor_forward (e->cursor, e);
Index: src/htmlimage.c
===================================================================
RCS file: /cvs/gnome/gtkhtml/src/htmlimage.c,v
retrieving revision 1.194
diff -u -r1.194 htmlimage.c
--- src/htmlimage.c	3 Nov 2003 10:31:28 -0000	1.194
+++ src/htmlimage.c	1 Dec 2003 22:49:00 -0000
@@ -160,6 +160,7 @@
 	g_free (image->url);
 	g_free (image->target);
 	g_free (image->alt);
+	g_free (image->picto);
 	g_free (image->usemap);
 	g_free (image->final_url);
 
@@ -208,6 +209,7 @@
 	dimg->url = g_strdup (simg->url);
 	dimg->target = g_strdup (simg->target);
 	dimg->alt = g_strdup (simg->alt);
+	dimg->picto = g_strdup (simg->picto);
 	dimg->usemap = g_strdup (simg->usemap);
 	dimg->final_url = NULL;
 
@@ -827,6 +829,7 @@
 	}
 
 	image->alt = NULL;
+	image->picto = NULL;
 
 	image->hspace = 0;
 	image->vspace = 0;
@@ -941,6 +944,13 @@
 	image->alt = g_strdup (alt);
 }
 
+void
+html_image_set_picto (HTMLImage *image, gchar *picto)
+{
+	g_free (image->picto);
+	image->picto = g_strdup (picto);
+}
+	
 void
 html_image_set_map (HTMLImage *image, gchar *usemap, gboolean ismap)
 {
Index: src/htmlimage.h
===================================================================
RCS file: /cvs/gnome/gtkhtml/src/htmlimage.h,v
retrieving revision 1.49
diff -u -r1.49 htmlimage.h
--- src/htmlimage.h	20 May 2003 15:17:13 -0000	1.49
+++ src/htmlimage.h	1 Dec 2003 22:49:00 -0000
@@ -72,6 +72,7 @@
 	gchar *url;
 	gchar *target;
 	gchar *alt;
+	gchar *picto;
 	gchar *usemap;
 	gchar *final_url;	
 };
@@ -130,6 +131,8 @@
 					   gint              border);
 void        html_image_set_alt            (HTMLImage        *image,
 					   gchar            *alt);
+void        html_image_set_picto          (HTMLImage        *image,
+					   gchar            *picto);
 void        html_image_set_map            (HTMLImage        *image,
 					   gchar            *mapuri,
 					   gboolean         ismap);

Attachment: signature.asc
Description: This is a digitally signed message part



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]