changeset 11854:4ab3ce602932

[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 <tailor@pidgin.im>
author Stu Tomlinson <stu@nosnilmot.com>
date Thu, 27 Oct 2005 18:47:19 +0000
parents 65b6f52c2696
children dba7bf61e64c
files src/gtkconv.c
diffstat 1 files changed, 24 insertions(+), 28 deletions(-) [+]
line wrap: on
line diff
--- 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));