# HG changeset patch # User Etan Reisner # Date 1110161949 0 # Node ID 54ac161a876ee703c587362368305ff01eab9408 # Parent f02873d475dc89cc848d147cbb7d9331c8624419 [gaim-migrate @ 12199] Plugins can now add submenus to the right-click menu of a blist node by passing a GList of actions to gaim_blist_node_action_new. I'm thinking about making GaimBlistNodeActions more like plugin prefs so that plugins can create radio and check menu items as well. We'll see if I can do that and not make it ugly/suck. committer: Tailor Script diff -r f02873d475dc -r 54ac161a876e plugins/gevolution/gevolution.c --- a/plugins/gevolution/gevolution.c Mon Mar 07 01:25:05 2005 +0000 +++ b/plugins/gevolution/gevolution.c Mon Mar 07 02:19:09 2005 +0000 @@ -219,7 +219,8 @@ if (gevo_prpl_is_supported(buddy->account, buddy)) { act = gaim_blist_node_action_new(_("Add to Address Book"), - menu_item_activate_cb, NULL); + menu_item_activate_cb, + NULL, NULL); *menu = g_list_append(*menu, act); } } diff -r f02873d475dc -r 54ac161a876e src/blist.c --- a/src/blist.c Mon Mar 07 01:25:05 2005 +0000 +++ b/src/blist.c Mon Mar 07 02:19:09 2005 +0000 @@ -2460,11 +2460,12 @@ return gaim_value_get_string(value); } -GList *gaim_blist_node_get_extended_menu(GaimBlistNode *n) +GList * +gaim_blist_node_get_extended_menu(GaimBlistNode *n) { GList *menu = NULL; - g_return_val_if_fail(n, NULL); + g_return_val_if_fail(n != NULL, NULL); gaim_signal_emit(gaim_blist_get_handle(), "blist-node-extended-menu", @@ -2474,13 +2475,14 @@ GaimBlistNodeAction * gaim_blist_node_action_new(char *label, - void (*callback)(GaimBlistNode *, gpointer), - gpointer data) + void (*callback)(GaimBlistNode *, gpointer), + gpointer data, GList *children) { GaimBlistNodeAction *act = g_new0(GaimBlistNodeAction, 1); act->label = label; act->callback = callback; act->data = data; + act->children = children; return act; } diff -r f02873d475dc -r 54ac161a876e src/blist.h --- a/src/blist.h Mon Mar 07 01:25:05 2005 +0000 +++ b/src/blist.h Mon Mar 07 02:19:09 2005 +0000 @@ -199,6 +199,7 @@ char *label; void (*callback)(GaimBlistNode *, gpointer); gpointer data; + GList *children; }; @@ -866,13 +867,17 @@ /** * Creates a new GaimBlistNodeAction. - * @param label The text label to display for this action. - * @param callback The function to be called when the action is used on - * a selected GaimBlistNode. - * @param data Additional data, to be passed to the callback + * @param label The text label to display for this action. + * @param callback The function to be called when the action is used on + * a selected GaimBlistNode. + * @param data Additional data, to be passed to the callback + * @param children A GList of GaimBlistNodeActions to be added as a + * submenu of the action. + * @return The GaimBlistNodeAction. */ -GaimBlistNodeAction *gaim_blist_node_action_new(char *label, - void (*callback)(GaimBlistNode *, gpointer), gpointer data); +GaimBlistNodeAction *gaim_blist_node_action_new(char *label, + void (*callback)(GaimBlistNode *, gpointer), gpointer data, + GList *children); /**************************************************************************/ diff -r f02873d475dc -r 54ac161a876e src/gtkblist.c --- a/src/gtkblist.c Mon Mar 07 01:25:05 2005 +0000 +++ b/src/gtkblist.c Mon Mar 07 02:19:09 2005 +0000 @@ -1077,7 +1077,7 @@ static void -append_blist_node_action (GtkWidget *menu, GaimBlistNodeAction *act, +append_blist_node_action(GtkWidget *menu, GaimBlistNodeAction *act, GaimBlistNode *node, gboolean *dup_separator) { if(act == NULL) { @@ -1088,19 +1088,41 @@ } else { GtkWidget *menuitem; - *dup_separator = FALSE; - - menuitem = gtk_menu_item_new_with_mnemonic(act->label); - g_object_set_data(G_OBJECT(menuitem), "gaimcallback", act); - g_signal_connect(G_OBJECT(menuitem), "activate", - G_CALLBACK(blist_node_menu_cb), node); - gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); + if (act->children == NULL) { + *dup_separator = FALSE; + + menuitem = gtk_menu_item_new_with_mnemonic(act->label); + g_object_set_data(G_OBJECT(menuitem), "gaimcallback", + act); + g_signal_connect(G_OBJECT(menuitem), "activate", + G_CALLBACK(blist_node_menu_cb), node); + gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); + } else { + GtkWidget *submenu = NULL; + GList *l = NULL; + + menuitem = gtk_menu_item_new_with_mnemonic(act->label); + gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); + + submenu = gtk_menu_new(); + gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), submenu); + + for (l = act->children; l; l = l->next) { + GaimBlistNodeAction *act = (GaimBlistNodeAction *) l->data; + + append_blist_node_action(submenu, act, node, dup_separator); + + g_list_free(act->children); + act->children = NULL; + } + } } } void -gaim_gtk_append_blist_node_proto_menu (GtkWidget *menu, GaimConnection *gc, GaimBlistNode *node) +gaim_gtk_append_blist_node_proto_menu(GtkWidget *menu, GaimConnection *gc, + GaimBlistNode *node) { GList *l, *ll; gboolean dup_separator = FALSE; diff -r f02873d475dc -r 54ac161a876e src/protocols/gg/gg.c --- a/src/protocols/gg/gg.c Mon Mar 07 01:25:05 2005 +0000 +++ b/src/protocols/gg/gg.c Mon Mar 07 02:19:09 2005 +0000 @@ -1,6 +1,6 @@ /* * gaim - Gadu-Gadu Protocol Plugin - * $Id: gg.c 12108 2005-02-23 04:21:50Z thekingant $ + * $Id: gg.c 12199 2005-03-07 02:19:09Z deryni9 $ * * Copyright (C) 2001 Arkadiusz Mi¶kiewicz * @@ -343,7 +343,7 @@ /* um... this seems silly. since in this pass, I'm only converting over the menu building, I'm not going to mess with it though */ /* XXX: shouldn't this be in the tooltip instead? */ - act = gaim_blist_node_action_new(buf, NULL, NULL); + act = gaim_blist_node_action_new(buf, NULL, NULL, NULL); m = g_list_append(m, act); return m; diff -r f02873d475dc -r 54ac161a876e src/protocols/jabber/buddy.c --- a/src/protocols/jabber/buddy.c Mon Mar 07 01:25:05 2005 +0000 +++ b/src/protocols/jabber/buddy.c Mon Mar 07 02:19:09 2005 +0000 @@ -1016,23 +1016,23 @@ if(js->protocol_version == JABBER_PROTO_0_9 /* && NOT ME */) { if(jb->invisible & JABBER_INVIS_BUDDY) { act = gaim_blist_node_action_new(_("Un-hide From"), - jabber_buddy_make_visible, NULL); + jabber_buddy_make_visible, NULL, NULL); } else { act = gaim_blist_node_action_new(_("Temporarily Hide From"), - jabber_buddy_make_invisible, NULL); + jabber_buddy_make_invisible, NULL, NULL); } m = g_list_append(m, act); } if(jb->subscription & JABBER_SUB_FROM /* && NOT ME */) { act = gaim_blist_node_action_new(_("Cancel Presence Notification"), - jabber_buddy_cancel_presence_notification, NULL); + jabber_buddy_cancel_presence_notification, NULL, NULL); m = g_list_append(m, act); } if(!(jb->subscription & JABBER_SUB_TO)) { act = gaim_blist_node_action_new(_("(Re-)Request authorization"), - jabber_buddy_rerequest_auth, NULL); + jabber_buddy_rerequest_auth, NULL, NULL); m = g_list_append(m, act); } else /* if(NOT ME) */{ @@ -1040,7 +1040,7 @@ /* shouldn't this just happen automatically when the buddy is removed? */ act = gaim_blist_node_action_new(_("Unsubscribe"), - jabber_buddy_unsubscribe, NULL); + jabber_buddy_unsubscribe, NULL, NULL); m = g_list_append(m, act); } diff -r f02873d475dc -r 54ac161a876e src/protocols/msn/msn.c --- a/src/protocols/msn/msn.c Mon Mar 07 01:25:05 2005 +0000 +++ b/src/protocols/msn/msn.c Mon Mar 07 02:19:09 2005 +0000 @@ -616,7 +616,7 @@ if (user->mobile) { act = gaim_blist_node_action_new(_("Send to Mobile"), - show_send_to_mobile_cb, NULL); + show_send_to_mobile_cb, NULL, NULL); m = g_list_append(m, act); } } @@ -625,7 +625,7 @@ gaim_account_get_username(buddy->account))) { act = gaim_blist_node_action_new(_("Initiate _Chat"), - initiate_chat_cb, NULL); + initiate_chat_cb, NULL, NULL); m = g_list_append(m, act); } diff -r f02873d475dc -r 54ac161a876e src/protocols/novell/novell.c --- a/src/protocols/novell/novell.c Mon Mar 07 01:25:05 2005 +0000 +++ b/src/protocols/novell/novell.c Mon Mar 07 02:19:09 2005 +0000 @@ -3378,7 +3378,7 @@ if(GAIM_BLIST_NODE_IS_BUDDY(node)) { act = gaim_blist_node_action_new(_("Initiate _Chat"), - _initiate_conference_cb, NULL); + _initiate_conference_cb, NULL, NULL); list = g_list_append(list, act); } diff -r f02873d475dc -r 54ac161a876e src/protocols/oscar/oscar.c --- a/src/protocols/oscar/oscar.c Mon Mar 07 01:25:05 2005 +0000 +++ b/src/protocols/oscar/oscar.c Mon Mar 07 02:19:09 2005 +0000 @@ -7155,13 +7155,13 @@ GaimBlistNodeAction *act; act = gaim_blist_node_action_new(_("Edit Buddy Comment"), - oscar_buddycb_edit_comment, NULL); + oscar_buddycb_edit_comment, NULL, NULL); m = g_list_append(m, act); if (od->icq) { #if 0 act = gaim_blist_node_action_new(_("Get Status Msg"), - oscar_get_icqstatusmsg, NULL); + oscar_get_icqstatusmsg, NULL, NULL); m = g_list_append(m, act); #endif } else { @@ -7173,13 +7173,13 @@ if (userinfo->capabilities & AIM_CAPS_DIRECTIM) { act = gaim_blist_node_action_new(_("Direct IM"), - oscar_ask_direct_im, NULL); + oscar_ask_direct_im, NULL, NULL); m = g_list_append(m, act); } #if 0 if (userinfo->capabilities & AIM_CAPS_GETFILE) { act = gaim_blist_node_action_new(_("Get File"), - oscar_ask_getfile, NULL); + oscar_ask_getfile, NULL, NULL); m = g_list_append(m, act); } #endif @@ -7190,7 +7190,7 @@ char *gname = aim_ssi_itemlist_findparentname(od->sess->ssi.local, buddy->name); if (gname && aim_ssi_waitingforauth(od->sess->ssi.local, gname, buddy->name)) { act = gaim_blist_node_action_new(_("Re-request Authorization"), - gaim_auth_sendrequest_menu, NULL); + gaim_auth_sendrequest_menu, NULL, NULL); m = g_list_append(m, act); } } diff -r f02873d475dc -r 54ac161a876e src/protocols/silc/buddy.c --- a/src/protocols/silc/buddy.c Mon Mar 07 01:25:05 2005 +0000 +++ b/src/protocols/silc/buddy.c Mon Mar 07 02:19:09 2005 +0000 @@ -1541,33 +1541,35 @@ if (client_entry && client_entry->send_key) { act = gaim_blist_node_action_new(_("Reset IM Key"), - silcgaim_buddy_resetkey, NULL); + silcgaim_buddy_resetkey, NULL, NULL); m = g_list_append(m, act); } else { act = gaim_blist_node_action_new(_("IM with Key Exchange"), - silcgaim_buddy_keyagr, NULL); + silcgaim_buddy_keyagr, NULL, NULL); m = g_list_append(m, act); act = gaim_blist_node_action_new(_("IM with Password"), - silcgaim_buddy_privkey_menu, NULL); + silcgaim_buddy_privkey_menu, + NULL, NULL); m = g_list_append(m, act); } if (pkfile) { act = gaim_blist_node_action_new(_("Show Public Key"), - silcgaim_buddy_showkey, NULL); + silcgaim_buddy_showkey, NULL, NULL); m = g_list_append(m, act); } else { act = gaim_blist_node_action_new(_("Get Public Key..."), - silcgaim_buddy_getkey_menu, NULL); + silcgaim_buddy_getkey_menu, + NULL, NULL); m = g_list_append(m, act); } if (conn && conn->local_entry->mode & SILC_UMODE_ROUTER_OPERATOR) { act = gaim_blist_node_action_new(_("Kill User"), - silcgaim_buddy_kill, NULL); + silcgaim_buddy_kill, NULL, NULL); m = g_list_append(m, act); } diff -r f02873d475dc -r 54ac161a876e src/protocols/silc/chat.c --- a/src/protocols/silc/chat.c Mon Mar 07 01:25:05 2005 +0000 +++ b/src/protocols/silc/chat.c Mon Mar 07 02:19:09 2005 +0000 @@ -861,76 +861,90 @@ return NULL; act = gaim_blist_node_action_new(_("Get Info"), - silcgaim_chat_getinfo_menu, NULL); + silcgaim_chat_getinfo_menu, + NULL, NULL); m = g_list_append(m, act); #if 0 /* XXX For now these are not implemented. We need better listview dialog from Gaim for these. */ if (mode & SILC_CHANNEL_UMODE_CHANOP) { act = gaim_blist_node_action_new(_("Invite List"), - silcgaim_chat_invitelist, NULL); + silcgaim_chat_invitelist, + NULL, NULL); m = g_list_append(m, act); act = gaim_blist_node_action_new(_("Ban List"), - silcgaim_chat_banlist, NULL); + silcgaim_chat_banlist, + NULL, NULL); m = g_list_append(m, act); } #endif if (chu) { act = gaim_blist_node_action_new(_("Add Private Group"), - silcgaim_chat_prv, NULL); + silcgaim_chat_prv, + NULL, NULL); m = g_list_append(m, act); } if (mode & SILC_CHANNEL_UMODE_CHANFO) { act = gaim_blist_node_action_new(_("Channel Authentication"), - silcgaim_chat_chauth, NULL); + silcgaim_chat_chauth, + NULL, NULL); m = g_list_append(m, act); if (channel->mode & SILC_CHANNEL_MODE_FOUNDER_AUTH) { act = gaim_blist_node_action_new(_("Reset Permanent"), - silcgaim_chat_permanent_reset, NULL); + silcgaim_chat_permanent_reset, + NULL, NULL); m = g_list_append(m, act); } else { act = gaim_blist_node_action_new(_("Set Permanent"), - silcgaim_chat_permanent, NULL); + silcgaim_chat_permanent, + NULL, NULL); m = g_list_append(m, act); } } if (mode & SILC_CHANNEL_UMODE_CHANOP) { act = gaim_blist_node_action_new(_("Set User Limit"), - silcgaim_chat_ulimit, NULL); + silcgaim_chat_ulimit, + NULL, NULL); m = g_list_append(m, act); if (channel->mode & SILC_CHANNEL_MODE_TOPIC) { act = gaim_blist_node_action_new(_("Reset Topic Restriction"), - silcgaim_chat_resettopic, NULL); + silcgaim_chat_resettopic, + NULL, NULL); m = g_list_append(m, act); } else { act = gaim_blist_node_action_new(_("Set Topic Restriction"), - silcgaim_chat_settopic, NULL); + silcgaim_chat_settopic, + NULL, NULL); m = g_list_append(m, act); } if (channel->mode & SILC_CHANNEL_MODE_PRIVATE) { act = gaim_blist_node_action_new(_("Reset Private Channel"), - silcgaim_chat_resetprivate, NULL); + silcgaim_chat_resetprivate, + NULL, NULL); m = g_list_append(m, act); } else { act = gaim_blist_node_action_new(_("Set Private Channel"), - silcgaim_chat_setprivate, NULL); + silcgaim_chat_setprivate, + NULL, NULL); m = g_list_append(m, act); } if (channel->mode & SILC_CHANNEL_MODE_SECRET) { act = gaim_blist_node_action_new(_("Reset Secret Channel"), - silcgaim_chat_resetsecret, NULL); + silcgaim_chat_resetsecret, + NULL, NULL); m = g_list_append(m, act); } else { act = gaim_blist_node_action_new(_("Set Secret Channel"), - silcgaim_chat_setsecret, NULL); + silcgaim_chat_setsecret, + NULL, NULL); m = g_list_append(m, act); } } diff -r f02873d475dc -r 54ac161a876e src/protocols/toc/toc.c --- a/src/protocols/toc/toc.c Mon Mar 07 01:25:05 2005 +0000 +++ b/src/protocols/toc/toc.c Mon Mar 07 02:19:09 2005 +0000 @@ -1430,7 +1430,7 @@ if(GAIM_BLIST_NODE_IS_BUDDY(node)) { act = gaim_blist_node_action_new(_("Get Dir Info"), - toc_get_dir, NULL); + toc_get_dir, NULL, NULL); m = g_list_append(m, act); } diff -r f02873d475dc -r 54ac161a876e src/protocols/trepia/trepia.c --- a/src/protocols/trepia/trepia.c Mon Mar 07 01:25:05 2005 +0000 +++ b/src/protocols/trepia/trepia.c Mon Mar 07 02:19:09 2005 +0000 @@ -474,7 +474,8 @@ if (trepia_profile_get_homepage(profile) != NULL) { act = gaim_blist_node_action_new(_("Visit Homepage"), - trepia_visit_homepage, NULL); + trepia_visit_homepage, + NULL, NULL); m = g_list_append(m, act); } } diff -r f02873d475dc -r 54ac161a876e src/protocols/yahoo/yahoo.c --- a/src/protocols/yahoo/yahoo.c Mon Mar 07 01:25:05 2005 +0000 +++ b/src/protocols/yahoo/yahoo.c Mon Mar 07 02:19:09 2005 +0000 @@ -2599,7 +2599,7 @@ if (!f && !yd->wm) { act = gaim_blist_node_action_new(_("Add Buddy"), - yahoo_addbuddyfrommenu_cb, NULL); + yahoo_addbuddyfrommenu_cb, NULL, NULL); m = g_list_append(m, act); return m; @@ -2610,12 +2610,12 @@ if (!yd->wm) { act = gaim_blist_node_action_new(_("Join in Chat"), - yahoo_chat_goto_menu, NULL); + yahoo_chat_goto_menu, NULL, NULL); m = g_list_append(m, act); } act = gaim_blist_node_action_new(_("Initiate Conference"), - yahoo_initiate_conference, NULL); + yahoo_initiate_conference, NULL, NULL); m = g_list_append(m, act); if (yahoo_friend_get_game(f)) { @@ -2633,7 +2633,7 @@ *t = ' '; g_snprintf(buf2, sizeof buf2, "%s", room); - act = gaim_blist_node_action_new(buf2, yahoo_game, NULL); + act = gaim_blist_node_action_new(buf2, yahoo_game, NULL, NULL); m = g_list_append(m, act); }