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 text by pressing the backspace key. There is also another patch at http://bugzilla.gnome.org/showattachment.cgi?attach_id=21716 which allows it to replace also the explicit inserted smileys (Insert->Smiley->...) with text. Regards Jan Arne Petersen -- Jan Arne Petersen <jpetersen uni-bonn de>
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 23 Nov 2003 00:49:34 -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 23 Nov 2003 00:49:34 -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; @@ -942,6 +945,13 @@ } 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) { char *url = NULL; 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 23 Nov 2003 00:49:35 -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