# HG changeset patch # User Daniel Atallah # Date 1241394378 0 # Node ID c791a82b5bb58e5fa0a8eb0d367eb8c8028276c7 # Parent 55736bd691e20bab183848143bc27366ac5fa814 Avoid adding several callbacks on repeated invocations of gtk_imhtml_set_editable. diff -r 55736bd691e2 -r c791a82b5bb5 pidgin/gtkimhtml.c --- a/pidgin/gtkimhtml.c Sun May 03 22:59:02 2009 +0000 +++ b/pidgin/gtkimhtml.c Sun May 03 23:46:18 2009 +0000 @@ -4420,15 +4420,19 @@ * 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)