Mercurial > pidgin
changeset 8710:36b043fe2740
[gaim-migrate @ 9464]
Plugins can now add menu items to the buddy context menu (Christopher O'Brien).
committer: Tailor Script <tailor@pidgin.im>
author | Christian Hammond <chipx86@chipx86.com> |
---|---|
date | Mon, 19 Apr 2004 04:20:24 +0000 |
parents | e67d9b67ee56 |
children | 05ed6143ec76 |
files | ChangeLog src/blist.c src/blist.h src/gtkblist.c |
diffstat | 4 files changed, 75 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- 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
--- 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
--- 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 */ /**************************************************************************/
--- 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);