pidgin: d9973762: Avoid adding several callbacks on repeat...

datallah at pidgin.im datallah at pidgin.im
Sun May 3 19:50:27 EDT 2009


-----------------------------------------------------------------
Revision: d9973762180bd415b9e93e59fb1772a54552b885
Ancestor: 706a83709228c4f9330ad89c170026fcf6cedaaa
Author: datallah at pidgin.im
Date: 2009-05-03T23:46:18
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/d9973762180bd415b9e93e59fb1772a54552b885

Modified files:
        pidgin/gtkimhtml.c

ChangeLog: 

Avoid adding several callbacks on repeated invocations of gtk_imhtml_set_editable.

-------------- next part --------------
============================================================
--- pidgin/gtkimhtml.c	74f43282006f9b92fcdc93627a474efc231b42c2
+++ pidgin/gtkimhtml.c	eb96e663e8e45ecf74a3d401f726034ffbd0c34c
@@ -4420,15 +4420,19 @@ void gtk_imhtml_set_editable(GtkIMHtml *
 	 * people can highlight stuff.
 	 */
 	/* gtk_text_view_set_cursor_visible(GTK_TEXT_VIEW(imhtml), editable); */
-	imhtml->editable = editable;
-	imhtml->format_functions = GTK_IMHTML_ALL;
-
-	if (editable)
-	{
+	if (editable && !imhtml->editable) {
 		g_signal_connect_after(G_OBJECT(GTK_IMHTML(imhtml)->text_buffer), "mark-set",
 				G_CALLBACK(mark_set_cb), imhtml);
 		g_signal_connect(G_OBJECT(imhtml), "backspace", G_CALLBACK(smart_backspace_cb), NULL);
+	} else if (!editable && imhtml->editable) {
+		g_signal_handlers_disconnect_by_func(G_OBJECT(GTK_IMHTML(imhtml)->text_buffer),
+			mark_set_cb, imhtml);
+		g_signal_handlers_disconnect_by_func(G_OBJECT(imhtml),
+			smart_backspace_cb, NULL);
 	}
+
+	imhtml->editable = editable;
+	imhtml->format_functions = GTK_IMHTML_ALL;
 }
 
 void gtk_imhtml_set_whole_buffer_formatting_only(GtkIMHtml *imhtml, gboolean wbfo)


More information about the Commits mailing list