changeset 20045:507e109387fd

Move to menu in blist context menu. Used for more easily moving buddies between groups
author Sean Egan <seanegan@gmail.com>
date Sat, 15 Sep 2007 06:46:32 +0000
parents 4fdf9c1212e2
children 466bbf2a516a
files ChangeLog pidgin/gtkblist.c
diffstat 2 files changed, 39 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Sat Sep 15 03:01:22 2007 +0000
+++ b/ChangeLog	Sat Sep 15 06:46:32 2007 +0000
@@ -6,6 +6,7 @@
 	Pidgin:
 	* When aliasing someone to an alias that already exists in the
 	  same group, offer to merge the buddies into the same contact
+	* 'Move to' submenu in Buddy List context menu
 
 Version 2.2.0 (09/13/2007):
 	http://developer.pidgin.im/query?status=closed&milestone=2.2.0
--- a/pidgin/gtkblist.c	Sat Sep 15 03:01:22 2007 +0000
+++ b/pidgin/gtkblist.c	Sat Sep 15 06:46:32 2007 +0000
@@ -306,6 +306,13 @@
 	serv_send_file(b->account->gc, b->name, NULL);
 }
 
+static void gtk_blist_menu_move_to_cb(GtkWidget *w, PurpleBlistNode *node)
+{
+	PurpleBlistNode *group = g_object_get_data(w, "groupnode");
+	purple_blist_add_contact(node, group, NULL);
+
+}
+
 static void gtk_blist_menu_autojoin_cb(GtkWidget *w, PurpleChat *chat)
 {
 	purple_blist_node_set_bool((PurpleBlistNode*)chat, "gtk-autojoin",
@@ -1217,6 +1224,34 @@
 	g_list_free(ll);
 }
 
+
+
+static void
+pidgin_append_blist_node_move_to_menu(GtkWidget *menu, PurpleBlistNode *node)
+{
+	GtkWidget *submenu;
+	GtkWidget *menuitem;
+	PurpleBlistNode *group;
+
+	menuitem = gtk_menu_item_new_with_label(_("Move to"));
+	gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
+	gtk_widget_show(menuitem);
+
+	submenu = gtk_menu_new();
+	gtk_menu_item_set_submenu(menuitem, submenu);
+
+	for (group = purple_blist_get_root(); group; group = group->next) {
+		if (group->type != PURPLE_BLIST_GROUP_NODE)
+			continue;
+		if (group == node->parent)
+			continue;
+		menuitem = pidgin_new_item_from_stock(submenu, purple_group_get_name(group), NULL,
+						      G_CALLBACK(gtk_blist_menu_move_to_cb), node, 0, 0, NULL);
+		g_object_set_data(G_OBJECT(menuitem), "groupnode", group);
+	}
+	gtk_widget_show_all(submenu);
+}
+
 void
 pidgin_blist_make_buddy_menu(GtkWidget *menu, PurpleBuddy *buddy, gboolean sub) {
 	PurplePluginProtocolInfo *prpl_info;
@@ -1268,6 +1303,9 @@
 										  (PurpleBlistNode *)buddy);
 	pidgin_append_blist_node_extended_menu(menu, (PurpleBlistNode *)buddy);
 
+	if (!contact_expanded)
+		pidgin_append_blist_node_move_to_menu(menu, contact);
+
 	if (((PurpleBlistNode*)buddy)->parent && ((PurpleBlistNode*)buddy)->parent->child->next && 
               !sub && !contact_expanded) {
 		pidgin_separator(menu);
@@ -1405,7 +1443,6 @@
 				 node, 0, 0, NULL);
 
 	pidgin_append_blist_node_extended_menu(menu, node);
-
 	return menu;
 }