# HG changeset patch # User Stu Tomlinson # Date 1130438839 0 # Node ID 4ab3ce602932b8e05ae91fd7f73b0175ada67cc8 # Parent 65b6f52c269676055ea188e72a91a8bc99559b9e [gaim-migrate @ 14145] I think this is a slightly better way of updating conversations, though at some point the strange mix of calls to gaim_conversation_update, gaim_gtkconv_updated, gray_stuff_out and update_send_to_selection could probably be cleaned up a bit. now instead of iterating through all windows N times when we have N conversations, we just ensure that the signals fire once for each window (and disconnect the signals when the window is destroyed) committer: Tailor Script diff -r 65b6f52c2696 -r 4ab3ce602932 src/gtkconv.c --- a/src/gtkconv.c Thu Oct 27 18:38:52 2005 +0000 +++ b/src/gtkconv.c Thu Oct 27 18:47:19 2005 +0000 @@ -3804,26 +3804,6 @@ return NULL; } -static void -buddy_update_cb(GaimBlistNode *bnode) -{ - GList *list; - - g_return_if_fail(bnode); - g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(bnode)); - - for (list = gaim_gtk_conv_windows_get_list(); list; list = list->next) - { - GaimGtkWindow *win = list->data; - GaimConversation *conv = gaim_gtk_conv_window_get_active_conversation(win); - - if (gaim_conversation_get_type(conv) != GAIM_CONV_TYPE_IM) - continue; - - gaim_conversation_update(conv, GAIM_CONV_ACCOUNT_ONLINE); - } -} - /************************************************************************** * Conversation UI operations **************************************************************************/ @@ -3921,14 +3901,6 @@ G_CALLBACK(gtk_widget_grab_focus), gtkconv->entry); - if (conv_type == GAIM_CONV_TYPE_IM) - { - gaim_signal_connect(gaim_blist_get_handle(), "buddy-added", gtkconv, - G_CALLBACK(buddy_update_cb), conv); - gaim_signal_connect(gaim_blist_get_handle(), "buddy-removed", gtkconv, - G_CALLBACK(buddy_update_cb), conv); - } - gaim_gtkconv_placement_place(gtkconv); } @@ -6210,6 +6182,24 @@ start_anim(NULL, gtkconv); } +static void +buddy_update_cb(GaimBlistNode *bnode, void *data) +{ + GaimGtkWindow *win = (GaimGtkWindow *)data; + GaimConversation *conv; + + g_return_if_fail(bnode); + g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(bnode)); + + conv = gaim_gtk_conv_window_get_active_conversation(win); + + if (gaim_conversation_get_type(conv) != GAIM_CONV_TYPE_IM) + return; + + gaim_conversation_update(conv, GAIM_CONV_ACCOUNT_ONLINE); +} + + /************************************************************************** * GTK+ window ops **************************************************************************/ @@ -6277,6 +6267,11 @@ g_signal_connect(G_OBJECT(win->notebook), "button_release_event", G_CALLBACK(notebook_release_cb), win); + gaim_signal_connect(gaim_blist_get_handle(), "buddy-added", win, + G_CALLBACK(buddy_update_cb), win); + gaim_signal_connect(gaim_blist_get_handle(), "buddy-removed", win, + G_CALLBACK(buddy_update_cb), win); + testidea = gtk_vbox_new(FALSE, 0); /* Setup the menubar. */ @@ -6311,6 +6306,7 @@ } return; } + gaim_signals_disconnect_by_handle(win); gtk_widget_destroy(win->window); g_object_unref(G_OBJECT(win->menu.item_factory));