# HG changeset patch # User Christian Hammond # Date 1082348424 0 # Node ID 36b043fe2740c3efd6bb3ec1f8035404b5a13552 # Parent e67d9b67ee56a951f9c931e3c985c7b9595a627a [gaim-migrate @ 9464] Plugins can now add menu items to the buddy context menu (Christopher O'Brien). committer: Tailor Script diff -r e67d9b67ee56 -r 36b043fe2740 ChangeLog --- a/ChangeLog Sun Apr 18 22:40:25 2004 +0000 +++ b/ChangeLog Mon Apr 19 04:20:24 2004 +0000 @@ -11,6 +11,8 @@ * WYSIWYG improvements (Tim Ringenbach) * WYSIWYG editing for user info (Jon Oberheide) * Rich-text copy and paste + * Plugins can now add menu items to the buddy context menu + (Christopher O'Brien) Bug Fixes: * TOC has been removed from the default build list. I do not support diff -r e67d9b67ee56 -r 36b043fe2740 src/blist.c --- a/src/blist.c Sun Apr 18 22:40:25 2004 +0000 +++ b/src/blist.c Mon Apr 19 04:20:24 2004 +0000 @@ -2699,6 +2699,15 @@ /* XXX: end compat crap */ + +GList *gaim_buddy_get_extended_menu(GaimBuddy *b) { + GList *menu = NULL; + gaim_signal_emit(gaim_blist_get_handle(), "buddy-extended-menu", + b, &menu); + return menu; +} + + int gaim_blist_get_group_size(GaimGroup *group, gboolean offline) { if(!group) return 0; @@ -2769,6 +2778,11 @@ GAIM_SUBTYPE_BLIST_BUDDY)); gaim_signal_register(handle, "update-idle", gaim_marshal_VOID, NULL, 0); + gaim_signal_register(handle, "buddy-extended-menu", + gaim_marshal_VOID__POINTER_POINTER, NULL, 2, + gaim_value_new(GAIM_TYPE_SUBTYPE, + GAIM_SUBTYPE_BLIST_BUDDY), + gaim_value_new(GAIM_TYPE_BOXED, "GList **")); } void diff -r e67d9b67ee56 -r 36b043fe2740 src/blist.h --- a/src/blist.h Sun Apr 18 22:40:25 2004 +0000 +++ b/src/blist.h Mon Apr 19 04:20:24 2004 +0000 @@ -854,6 +854,14 @@ /*@}*/ + +/** + * Retrieves the extended menu items for a buddy. + * @param b The buddy to obtain the extended menu items for +*/ +GList *gaim_buddy_get_extended_menu(GaimBuddy *b); + + /**************************************************************************/ /** @name UI Registration Functions */ /**************************************************************************/ diff -r e67d9b67ee56 -r 36b043fe2740 src/gtkblist.c --- a/src/gtkblist.c Sun Apr 18 22:40:25 2004 +0000 +++ b/src/gtkblist.c Mon Apr 19 04:20:24 2004 +0000 @@ -1079,7 +1079,8 @@ static void make_buddy_menu(GtkWidget *menu, GaimPluginProtocolInfo *prpl_info, GaimBuddy *b) { - GList *list; + GList *list = NULL, *l = NULL; + gboolean dup_separator = FALSE; GtkWidget *menuitem; if (prpl_info && prpl_info->get_info) { @@ -1095,17 +1096,62 @@ if (prpl_info && prpl_info->buddy_menu) { list = prpl_info->buddy_menu(b->account->gc, b->name); - while (list) { - struct proto_buddy_menu *pbm = list->data; + + for(l = list; l; l = l->next) { + struct proto_buddy_menu *pbm = l->data; + + /* draw "-" titled menu items as a separator. Since the + pbm is not being used in a callback, it needs to be + freed. Also, do some simple checking to prevent + doubled-up separators */ + if('-' == *pbm->label) { + if(! dup_separator) { + gaim_separator(menu); + dup_separator = TRUE; + } + g_free(pbm); + continue; + } else { + dup_separator = FALSE; + } + menuitem = gtk_menu_item_new_with_mnemonic(pbm->label); g_object_set_data(G_OBJECT(menuitem), "gaimcallback", pbm); g_signal_connect(G_OBJECT(menuitem), "activate", - G_CALLBACK(gaim_proto_menu_cb), b); + G_CALLBACK(gaim_proto_menu_cb), b); gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); - list = list->next; } + g_list_free(list); } + /* check for additional menu items which may be added by other + plugins. */ + list = gaim_buddy_get_extended_menu(b); + for(l = list; l; l = l->next) { + struct proto_buddy_menu *pbm = l->data; + + /* draw "-" titled menu items as a separator. see previous, + identical-looking code. */ + if('-' == *pbm->label) { + if(! dup_separator) { + gaim_separator(menu); + dup_separator = TRUE; + } + g_free(pbm); + continue; + } else { + dup_separator = FALSE; + } + + menuitem = gtk_menu_item_new_with_mnemonic(pbm->label); + g_object_set_data(G_OBJECT(menuitem), "gaimcallback", pbm); + g_signal_connect(G_OBJECT(menuitem), "activate", + G_CALLBACK(gaim_proto_menu_cb), b); + gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); + } + g_list_free(list); + + /* moving on to the old ui-specific plugin menus */ gaim_signal_emit(GAIM_GTK_BLIST(gaim_get_blist()), "drawing-menu", menu, b);