changeset 8259:4f9f68ab8770

[gaim-migrate @ 8982] This should fix some buddy pounce menu issues when signing off the last account and back on. Also, the Remove Buddy Pounce menu is now greyed out if empty. Hopefully the issues are dealt with now. committer: Tailor Script <tailor@pidgin.im>
author Christian Hammond <chipx86@chipx86.com>
date Sun, 15 Feb 2004 04:44:00 +0000
parents cbdef2dcc581
children 1fa30b3f7e6d
files src/blist.c src/gtkblist.c src/gtkpounce.c
diffstat 3 files changed, 36 insertions(+), 22 deletions(-) [+]
line wrap: on
line diff
--- a/src/blist.c	Sat Feb 14 23:26:39 2004 +0000
+++ b/src/blist.c	Sun Feb 15 04:44:00 2004 +0000
@@ -207,6 +207,7 @@
 void gaim_blist_destroy()
 {
 	GaimBlistUiOps *ops = gaimbuddylist->ui_ops;
+	gaim_debug(GAIM_DEBUG_INFO, "blist", "Destroying\n");
 	if (ops)
 		ops->destroy(gaimbuddylist);
 }
--- a/src/gtkblist.c	Sat Feb 14 23:26:39 2004 +0000
+++ b/src/gtkblist.c	Sun Feb 15 04:44:00 2004 +0000
@@ -2518,8 +2518,8 @@
 static void
 signed_on_off_cb(GaimConnection *gc, GaimBuddyList *blist)
 {
-	GaimGtkBuddyList *gtkblist = blist->ui_data;
-	
+	GaimGtkBuddyList *gtkblist = GAIM_GTK_BLIST(blist);
+
 	gaim_gtk_blist_update_protocol_actions();
 	gaim_gtkpounce_menu_build(gtkblist->bpmenu);
 }
@@ -2550,12 +2550,6 @@
 	gtkblist = g_new0(GaimGtkBuddyList, 1);
 	blist->ui_data = gtkblist;
 
-	/* Setup some gaim signal handlers. */
-	gaim_signal_connect(gaim_connections_get_handle(), "signing-on",
-						gtkblist, GAIM_CALLBACK(signed_on_off_cb), blist);
-	gaim_signal_connect(gaim_connections_get_handle(), "signing-off",
-						gtkblist, GAIM_CALLBACK(signed_on_off_cb), blist);
-
 	/* Register some of our own. */
 	gaim_signal_register(gtkblist, "drawing-menu",
 						 gaim_marshal_VOID__POINTER_POINTER, NULL, 2,
@@ -2890,6 +2884,12 @@
 			GINT_TO_POINTER(
 				gaim_prefs_connect_callback("/gaim/gtk/blist/show_warning_level",
 					gaim_gtk_blist_update_columns, NULL)));
+
+	/* Setup some gaim signal handlers. */
+	gaim_signal_connect(gaim_connections_get_handle(), "signing-on",
+						gtkblist, GAIM_CALLBACK(signed_on_off_cb), list);
+	gaim_signal_connect(gaim_connections_get_handle(), "signing-off",
+						gtkblist, GAIM_CALLBACK(signed_on_off_cb), list);
 }
 
 /* XXX: does this need fixing? */
@@ -3376,6 +3376,11 @@
 	if (!gtkblist)
 		return;
 
+	gaim_signal_disconnect(gaim_connections_get_handle(), "signing-on",
+						   gtkblist, GAIM_CALLBACK(signed_on_off_cb));
+	gaim_signal_disconnect(gaim_connections_get_handle(), "signing-off",
+						   gtkblist, GAIM_CALLBACK(signed_on_off_cb));
+
 	gtk_widget_destroy(gtkblist->window);
 
 	gaim_gtk_blist_tooltip_destroy();
--- a/src/gtkpounce.c	Sat Feb 14 23:26:39 2004 +0000
+++ b/src/gtkpounce.c	Sun Feb 15 04:44:00 2004 +0000
@@ -109,7 +109,7 @@
 }
 
 static void
-pounce_update_entryfields(GtkWidget *w, gpointer data)
+pounce_update_entry_fields(GtkWidget *w, gpointer data)
 {
 	const char *filename;
 	GHashTable *args;
@@ -152,7 +152,7 @@
 
 	g_signal_connect(GTK_OBJECT(GTK_FILE_SELECTION(filesel)->ok_button),
 					 "clicked",
-					 G_CALLBACK(pounce_update_entryfields), args);
+					 G_CALLBACK(pounce_update_entry_fields), args);
 	g_signal_connect_swapped(G_OBJECT(GTK_FILE_SELECTION(filesel)->cancel_button),
 							 "clicked",
 							 G_CALLBACK(g_hash_table_destroy), args);
@@ -685,7 +685,7 @@
 	gaim_gtkpounce_dialog_show(NULL, NULL, pounce);
 }
 
-static void
+static gboolean
 fill_menu(GtkWidget *menu, GCallback cb)
 {
 	GtkWidget *image;
@@ -693,6 +693,7 @@
 	GdkPixbuf *pixbuf, *scale;
 	GaimPounce *pounce;
 	const char *buddy;
+	gboolean has_items = FALSE;
 	GList *bp;
 
 	for (bp = gaim_pounces_get_all(); bp != NULL; bp = bp->next) {
@@ -700,9 +701,11 @@
 		buddy = gaim_pounce_get_pouncee(pounce);
 
 		/* Check if account is online, if not skip it */
-		if(!gaim_account_is_connected(pounce->pouncer))
+		if (!gaim_account_is_connected(pounce->pouncer))
 			continue;
-		
+
+		has_items = TRUE;
+
 		/* Build the menu item */
 		item = gtk_image_menu_item_new_with_label(buddy);
 
@@ -727,6 +730,8 @@
 		/* Set our callbacks. */
 		g_signal_connect(G_OBJECT(item), "activate", cb, pounce);
 	}
+
+	return has_items;
 }
 
 void
@@ -734,18 +739,18 @@
 {
 	GtkWidget *remmenu;
 	GtkWidget *item;
-	GList *l;
+	GList *children, *l;
+	gboolean has_items;
 
-	if(!menu)
-		return;
+	g_return_if_fail(menu != NULL);
 
-	for (l = gtk_container_get_children(GTK_CONTAINER(menu));
-		 l != NULL;
-		 l = l->next) {
+	if ((children = gtk_container_get_children(GTK_CONTAINER(menu))) != NULL)
+	{
+		for (l = children; l != NULL; l = l->next)
+			gtk_widget_destroy(GTK_WIDGET(l->data));
 
-		gtk_widget_destroy(GTK_WIDGET(l->data));
+		g_list_free(children);
 	}
-	g_list_free(l);
 
 	/* "New Buddy Pounce" */
 	item = gtk_menu_item_new_with_label(_("New Buddy Pounce"));
@@ -761,7 +766,10 @@
 	/* "Remove Buddy Pounce" menu */
 	remmenu = gtk_menu_new();
 
-	fill_menu(remmenu, G_CALLBACK(delete_pounce_cb));
+	has_items = fill_menu(remmenu, G_CALLBACK(delete_pounce_cb));
+
+	if (!has_items)
+		gtk_widget_set_sensitive(item, FALSE);
 
 	gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), remmenu);
 	gtk_widget_show(remmenu);