diff src/gtkpounce.c @ 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 10a41e67a800
children 721899998983
line wrap: on
line diff
--- 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);