Mercurial > pidgin.yaz
comparison pidgin/gtkimhtml.c @ 21648:3aa34d20d798
Patch from 'goutnet': Pressing backspace on a smiley will replace the smiley
with its text. Pressing backspace again will behave as it would for normal text.
References #3286.
author | Sadrul Habib Chowdhury <imadil@gmail.com> |
---|---|
date | Mon, 26 Nov 2007 09:49:27 +0000 |
parents | adc4da4ff21c |
children | 1f6935a5d189 c9946b9965c9 |
comparison
equal
deleted
inserted
replaced
21645:d0ea3a86add5 | 21648:3aa34d20d798 |
---|---|
1093 return; | 1093 return; |
1094 } | 1094 } |
1095 | 1095 |
1096 imhtml_paste_insert(imhtml, text, FALSE); | 1096 imhtml_paste_insert(imhtml, text, FALSE); |
1097 g_free(text); | 1097 g_free(text); |
1098 } | |
1099 | |
1100 | |
1101 static void smart_backspace_cb(GtkIMHtml *imhtml, gpointer blah) | |
1102 { | |
1103 GtkTextIter iter; | |
1104 GtkTextChildAnchor* anchor; | |
1105 char * text; | |
1106 gint offset; | |
1107 | |
1108 if (!imhtml->editable) | |
1109 return; | |
1110 | |
1111 gtk_text_buffer_get_iter_at_mark(imhtml->text_buffer, &iter, gtk_text_buffer_get_insert(imhtml->text_buffer)); | |
1112 | |
1113 /* Get the character before the insertion point */ | |
1114 offset = gtk_text_iter_get_offset(&iter); | |
1115 if (offset <= 0) | |
1116 return; | |
1117 | |
1118 gtk_text_iter_backward_char(&iter); | |
1119 anchor = gtk_text_iter_get_child_anchor(&iter); | |
1120 | |
1121 if (!anchor) | |
1122 return; /* No smiley here */ | |
1123 | |
1124 text = g_object_get_data(G_OBJECT(anchor), "gtkimhtml_plaintext"); | |
1125 if (!text) | |
1126 return; | |
1127 | |
1128 /* ok, then we need to insert the image buffer text before the anchor */ | |
1129 gtk_text_buffer_insert(imhtml->text_buffer, &iter, text, -1); | |
1098 } | 1130 } |
1099 | 1131 |
1100 static void paste_clipboard_cb(GtkIMHtml *imhtml, gpointer blah) | 1132 static void paste_clipboard_cb(GtkIMHtml *imhtml, gpointer blah) |
1101 { | 1133 { |
1102 #ifdef _WIN32 | 1134 #ifdef _WIN32 |
4050 /* gtk_text_view_set_cursor_visible(GTK_TEXT_VIEW(imhtml), editable); */ | 4082 /* gtk_text_view_set_cursor_visible(GTK_TEXT_VIEW(imhtml), editable); */ |
4051 imhtml->editable = editable; | 4083 imhtml->editable = editable; |
4052 imhtml->format_functions = GTK_IMHTML_ALL; | 4084 imhtml->format_functions = GTK_IMHTML_ALL; |
4053 | 4085 |
4054 if (editable) | 4086 if (editable) |
4087 { | |
4055 g_signal_connect_after(G_OBJECT(GTK_IMHTML(imhtml)->text_buffer), "mark-set", | 4088 g_signal_connect_after(G_OBJECT(GTK_IMHTML(imhtml)->text_buffer), "mark-set", |
4056 G_CALLBACK(mark_set_cb), imhtml); | 4089 G_CALLBACK(mark_set_cb), imhtml); |
4090 g_signal_connect(G_OBJECT(imhtml), "backspace", G_CALLBACK(smart_backspace_cb), NULL); | |
4091 } | |
4057 } | 4092 } |
4058 | 4093 |
4059 void gtk_imhtml_set_whole_buffer_formatting_only(GtkIMHtml *imhtml, gboolean wbfo) | 4094 void gtk_imhtml_set_whole_buffer_formatting_only(GtkIMHtml *imhtml, gboolean wbfo) |
4060 { | 4095 { |
4061 g_return_if_fail(imhtml != NULL); | 4096 g_return_if_fail(imhtml != NULL); |