diff finch/gntblist.c @ 32716:4f8626d4ef63

propagate from branch 'im.pidgin.pidgin' (head deb06ab6aa118efb674f1a8434ff529e67b28809) to branch 'im.pidgin.cpw.qulogic.gtk3' (head 34c3103eabae4a4c23439048d383f73c94dfd23e)
author Elliott Sales de Andrade <qulogic@pidgin.im>
date Thu, 23 Feb 2012 08:13:23 +0000
parents f5e193735392
children
line wrap: on
line diff
--- a/finch/gntblist.c	Sat Jan 21 12:02:41 2012 +0000
+++ b/finch/gntblist.c	Thu Feb 23 08:13:23 2012 +0000
@@ -50,6 +50,7 @@
 #include "gntmenu.h"
 #include "gntmenuitem.h"
 #include "gntmenuitemcheck.h"
+#include "gntmenuutil.h"
 #include "gntpounce.h"
 #include "gntstyle.h"
 #include "gnttree.h"
@@ -1072,46 +1073,6 @@
 }
 
 static void
-context_menu_callback(GntMenuItem *item, gpointer data)
-{
-	PurpleMenuAction *action = data;
-	PurpleBlistNode *node = ggblist->cnode;
-	if (action) {
-		void (*callback)(PurpleBlistNode *, gpointer);
-		callback = (void (*)(PurpleBlistNode *, gpointer))
-			purple_menu_action_get_callback(action);
-		if (callback)
-			callback(node, purple_menu_action_get_data(action));
-		else
-			return;
-	}
-}
-
-static void
-gnt_append_menu_action(GntMenu *menu, PurpleMenuAction *action, gpointer parent)
-{
-	GList *list;
-	GntMenuItem *item;
-
-	if (action == NULL)
-		return;
-
-	item = gnt_menuitem_new(purple_menu_action_get_label(action));
-	if (purple_menu_action_get_callback(action))
-		gnt_menuitem_set_callback(GNT_MENU_ITEM(item), context_menu_callback, action);
-	gnt_menu_add_item(menu, GNT_MENU_ITEM(item));
-
-	list = purple_menu_action_get_children(action);
-
-	if (list) {
-		GntWidget *sub = gnt_menu_new(GNT_MENU_POPUP);
-		gnt_menuitem_set_submenu(item, GNT_MENU(sub));
-		for (; list; list = list->next)
-			gnt_append_menu_action(GNT_MENU(sub), list->data, action);
-	}
-}
-
-static void
 append_proto_menu(GntMenu *menu, PurpleConnection *gc, PurpleBlistNode *node)
 {
 	GList *list;
@@ -1127,9 +1088,7 @@
 		if (!act)
 			continue;
 		purple_menu_action_set_data(act, node);
-		gnt_append_menu_action(menu, act, NULL);
-		g_signal_connect_swapped(G_OBJECT(menu), "destroy",
-			G_CALLBACK(purple_menu_action_free), act);
+		gnt_append_menu_action(menu, act, node);
 	}
 }
 
@@ -1139,8 +1098,6 @@
 {
 	PurpleMenuAction *action = purple_menu_action_new(label, callback, data, NULL);
 	gnt_append_menu_action(menu, action, NULL);
-	g_signal_connect_swapped(G_OBJECT(menu), "destroy",
-			G_CALLBACK(purple_menu_action_free), action);
 }
 
 static void
@@ -1379,9 +1336,7 @@
 	for (iter = purple_blist_node_get_extended_menu(node);
 			iter; iter = g_list_delete_link(iter, iter))
 	{
-		gnt_append_menu_action(menu, iter->data, NULL);
-		g_signal_connect_swapped(G_OBJECT(menu), "destroy",
-				G_CALLBACK(purple_menu_action_free), iter->data);
+		gnt_append_menu_action(menu, iter->data, node);
 	}
 }