changeset 3313:b0d5ce77f7dd

[gaim-migrate @ 3331] Added capability for protocol-specific "edit buddy menu" items. committer: Tailor Script <tailor@pidgin.im>
author Jim Seymour <jseymour>
date Sat, 15 Jun 2002 20:21:01 +0000
parents 0c7bd995eb03
children 52db87ab4083
files src/buddy.c src/prpl.h
diffstat 2 files changed, 28 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/buddy.c	Sat Jun 15 17:26:58 2002 +0000
+++ b/src/buddy.c	Sat Jun 15 20:21:01 2002 +0000
@@ -789,6 +789,7 @@
 	int row, column;
 	static GtkWidget *menu = NULL;
 	GtkWidget *button;
+	static GList *mo_top = NULL;
 
 	if (event->button != 3 || event->type != GDK_BUTTON_PRESS)
 		return FALSE;
@@ -806,6 +807,11 @@
 	if(menu) {
 		gtk_widget_destroy(menu);
 		menu = NULL;	/* safety measure */
+		if(mo_top) {
+			g_list_foreach(mo_top, (GFunc)g_free, NULL);
+			g_list_free(mo_top);
+			mo_top = NULL;
+		}
 	}
 
 	if (*type == EDIT_GROUP) {
@@ -861,6 +867,27 @@
 		gtk_menu_append(GTK_MENU(menu), button);
 		gtk_widget_show(button);
 
+		/*
+		 * Add protocol-specific edit buddy menu items if they exist
+		 */
+		if (b->gc->prpl->edit_buddy_menu) {
+			GList *mo = mo_top = b->gc->prpl->edit_buddy_menu(b->gc, b->name);
+
+			while (mo) {
+				struct proto_buddy_menu *pbm = mo->data;
+				GtkWidget *button;
+
+				button = gtk_menu_item_new_with_label(pbm->label);
+				gtk_signal_connect(GTK_OBJECT(button), "activate",
+						   GTK_SIGNAL_FUNC(menu_click), b->name);
+				gtk_object_set_user_data(GTK_OBJECT(button), mo);
+				gtk_menu_append(GTK_MENU(menu), button);
+				gtk_widget_show(button);
+
+				mo = mo->next;
+			}
+		}
+
 		gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, event->button, event->time);
 
 		return TRUE;
--- a/src/prpl.h	Sat Jun 15 17:26:58 2002 +0000
+++ b/src/prpl.h	Sat Jun 15 20:21:01 2002 +0000
@@ -99,6 +99,7 @@
 	/* user_opts returns a GList* of g_malloc'd struct proto_user_opts */
 	GList *(* user_opts)();
 	GList *(* buddy_menu)(struct gaim_connection *, char *);
+	GList *(* edit_buddy_menu)(struct gaim_connection *, char *);
 	GList *(* chat_info)(struct gaim_connection *);
 
 	GSList *(* smiley_list)();