im.pidgin.pidgin, im.pidgin.pidgin.next.minor: bcfb665250821266c993e2f5818c4e3f65314ff4
sadrul at pidgin.im
sadrul at pidgin.im
Mon Nov 26 05:00:44 EST 2007
-----------------------------------------------------------------
Revision: bcfb665250821266c993e2f5818c4e3f65314ff4
Ancestor: 73f9fc06f86b6dfcd381f23f36e4d51fa2b01b37
Author: sadrul at pidgin.im
Date: 2007-11-26T09:49:27
Date: 2007-11-26T09:56:03
Branch: im.pidgin.pidgin
Branch: im.pidgin.pidgin.next.minor
Modified files:
pidgin/gtkimhtml.c
ChangeLog:
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.
ChangeLog:
applied changes from 73f9fc06f86b6dfcd381f23f36e4d51fa2b01b37
through bcfb665250821266c993e2f5818c4e3f65314ff4
-------------- next part --------------
============================================================
--- pidgin/gtkimhtml.c 0767f7ed4c43f5407ca8a24905c5d6c01170f9c8
+++ pidgin/gtkimhtml.c 314edca9329042a9b656e82d296c798156bb33ac
@@ -1097,6 +1097,38 @@ static void paste_received_cb (GtkClipbo
g_free(text);
}
+
+static void smart_backspace_cb(GtkIMHtml *imhtml, gpointer blah)
+{
+ GtkTextIter iter;
+ GtkTextChildAnchor* anchor;
+ char * text;
+ gint offset;
+
+ if (!imhtml->editable)
+ return;
+
+ gtk_text_buffer_get_iter_at_mark(imhtml->text_buffer, &iter, gtk_text_buffer_get_insert(imhtml->text_buffer));
+
+ /* Get the character before the insertion point */
+ offset = gtk_text_iter_get_offset(&iter);
+ if (offset <= 0)
+ return;
+
+ gtk_text_iter_backward_char(&iter);
+ anchor = gtk_text_iter_get_child_anchor(&iter);
+
+ if (!anchor)
+ return; /* No smiley here */
+
+ text = g_object_get_data(G_OBJECT(anchor), "gtkimhtml_plaintext");
+ if (!text)
+ return;
+
+ /* ok, then we need to insert the image buffer text before the anchor */
+ gtk_text_buffer_insert(imhtml->text_buffer, &iter, text, -1);
+}
+
static void paste_clipboard_cb(GtkIMHtml *imhtml, gpointer blah)
{
#ifdef _WIN32
@@ -4052,8 +4084,11 @@ void gtk_imhtml_set_editable(GtkIMHtml *
imhtml->format_functions = GTK_IMHTML_ALL;
if (editable)
+ {
g_signal_connect_after(G_OBJECT(GTK_IMHTML(imhtml)->text_buffer), "mark-set",
- G_CALLBACK(mark_set_cb), imhtml);
+ G_CALLBACK(mark_set_cb), imhtml);
+ g_signal_connect(G_OBJECT(imhtml), "backspace", G_CALLBACK(smart_backspace_cb), NULL);
+ }
}
void gtk_imhtml_set_whole_buffer_formatting_only(GtkIMHtml *imhtml, gboolean wbfo)
More information about the Commits
mailing list