diff src/gtkblist.c @ 8952:e3f4657fa555

[gaim-migrate @ 9724] " This patch enables plugins to have the ability to provide a list of named call-backs for a GaimGroup in the buddy list. Most of the credit for this should go to Christopher (siege) O'Brien who did the same for the buddy menu (patch 907267). See his excellent description on that patch :)" --Stu Tomlinson committer: Tailor Script <tailor@pidgin.im>
author Luke Schierer <lschiere@pidgin.im>
date Sun, 16 May 2004 17:43:00 +0000
parents 6d7b403b11bb
children 7c008d98ef33
line wrap: on
line diff
--- a/src/gtkblist.c	Sun May 16 15:46:46 2004 +0000
+++ b/src/gtkblist.c	Sun May 16 17:43:00 2004 +0000
@@ -1065,6 +1065,13 @@
 		pbm->callback(pbm->gc, b->name);
 }
 
+static void gaim_proto_group_menu_cb(GtkMenuItem *item, GaimGroup *g)
+{
+	struct proto_group_menu *pgm = g_object_get_data(G_OBJECT(item), "gaimcallback");
+	if (pgm->callback)
+		pgm->callback(g);
+}
+
 static void make_buddy_menu(GtkWidget *menu, GaimPluginProtocolInfo *prpl_info, GaimBuddy *b)
 {
 	GList *list = NULL, *l = NULL;
@@ -1186,9 +1193,12 @@
 }
 
 static GtkWidget *
-create_group_menu (GaimBlistNode *node)
+create_group_menu (GaimBlistNode *node, GaimGroup *g)
 {
 	GtkWidget *menu;
+	GList *list = NULL, *l = NULL;
+	gboolean dup_separator = FALSE;
+	GtkWidget *menuitem;
 
 	menu = gtk_menu_new();
 	gaim_new_item_from_stock(menu, _("Add a _Buddy"), GTK_STOCK_ADD,
@@ -1199,6 +1209,31 @@
 				 G_CALLBACK(gaim_gtk_blist_remove_cb), node, 0, 0, NULL);
 	gaim_new_item_from_stock(menu, _("_Rename"), NULL,
 				 G_CALLBACK(show_rename_group), node, 0, 0, NULL);
+
+	list = gaim_group_get_extended_menu(g);
+	for(l = list; l; l = l->next) {
+		struct proto_group_menu *pgm = l->data;
+
+		/* draw "-" titled menu items as a separator.  see previous,
+		   identical-looking code. (in make_buddy_menu)*/
+		if(pgm == NULL) {
+			if(! dup_separator) {
+				gaim_separator(menu);
+				dup_separator = TRUE;
+			}
+			continue;
+		} else {
+			dup_separator = FALSE;
+		}
+
+		menuitem = gtk_menu_item_new_with_mnemonic(pgm->label);
+		g_object_set_data(G_OBJECT(menuitem), "gaimcallback", pgm);
+		g_signal_connect(G_OBJECT(menuitem), "activate",
+			G_CALLBACK(gaim_proto_group_menu_cb), g);
+		gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
+	}
+	g_list_free(list);
+
 	return menu;
 }
 
@@ -1351,7 +1386,8 @@
 
 	/* Create a menu based on the thing we right-clicked on */
 	if (GAIM_BLIST_NODE_IS_GROUP(node)) {
-		menu = create_group_menu(node);
+		GaimGroup *g = (GaimGroup *)node;
+		menu = create_group_menu(node, g);
 	} else if (GAIM_BLIST_NODE_IS_CHAT(node)) {
 		GaimChat *c = (GaimChat *)node;
 		GaimPlugin *prpl = NULL;