changeset 8586:5af95c2b1179

[gaim-migrate @ 9336] Another patch from Pekka Riikonen, this one implementing a prpl-specific blist chat menu similar to the prpl-specific blist buddy menu. I also took the liberty of filling out the prpl callback structures with NULL entries for those which were short -- not that it matters, but it soothes my sense of aesthetics. committer: Tailor Script <tailor@pidgin.im>
author Ethan Blanton <elb@pidgin.im>
date Mon, 05 Apr 2004 20:42:13 +0000
parents e4087b5c0627
children 699cc19a40d6
files src/gtkblist.c src/multi.h src/protocols/gg/gg.c src/protocols/irc/irc.c src/protocols/jabber/jabber.c src/protocols/msn/msn.c src/protocols/napster/napster.c src/protocols/oscar/oscar.c src/protocols/rendezvous/rendezvous.c src/protocols/toc/toc.c src/protocols/trepia/trepia.c src/protocols/yahoo/yahoo.c src/protocols/zephyr/zephyr.c src/prpl.h
diffstat 14 files changed, 108 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/src/gtkblist.c	Mon Apr 05 20:15:29 2004 +0000
+++ b/src/gtkblist.c	Mon Apr 05 20:42:13 2004 +0000
@@ -1168,10 +1168,22 @@
 	return menu;
 }
 
+static void gaim_proto_chat_menu_cb(GtkMenuItem *item, GaimChat *c)
+{
+	struct proto_chat_menu *pcm = g_object_get_data(G_OBJECT(item), "gaimcallback");
+	if (pcm->callback)
+		pcm->callback(pcm->gc, c->components);
+}
+
 static GtkWidget *
-create_chat_menu (GaimBlistNode *node)
+create_chat_menu (GaimBlistNode *node,
+		  GaimChat *c,
+		  GaimPlugin *prpl,
+		  GaimPluginProtocolInfo *prpl_info)
 {
 	GtkWidget *menu;
+	GList *list;
+	GtkWidget *menuitem;
 	gboolean autojoin = (gaim_blist_node_get_bool(node,
 						     "gtk-autojoin") || (gaim_blist_node_get_string(node,
 									 "gtk-autojoin") != NULL));
@@ -1182,10 +1194,28 @@
 	gaim_new_check_item(menu, _("Auto-Join"),
 			    G_CALLBACK(gtk_blist_menu_autojoin_cb), node,
 				autojoin);
+
+	if (prpl_info && prpl_info->chat_menu) {
+		list = prpl_info->chat_menu(c->account->gc, c->components);
+		while (list) {
+			struct proto_chat_menu *pcm = list->data;
+			menuitem = gtk_menu_item_new_with_mnemonic(pcm->label);
+			g_object_set_data(G_OBJECT(menuitem), "gaimcallback", pcm);
+			g_signal_connect(G_OBJECT(menuitem), "activate",
+					 G_CALLBACK(gaim_proto_chat_menu_cb), c);
+			gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
+			list = list->next;
+		}
+	}
+	gaim_signal_emit(GAIM_GTK_BLIST(gaim_get_blist()),
+			"drawing-menu", menu, c);
+
+	gaim_separator(menu);
 	gaim_new_item_from_stock(menu, _("_Alias..."), GAIM_STOCK_ALIAS,
 				 G_CALLBACK(gtk_blist_menu_alias_cb), node, 0, 0, NULL);
 	gaim_new_item_from_stock(menu, _("_Remove"), GTK_STOCK_REMOVE,
 				 G_CALLBACK(gaim_gtk_blist_remove_cb), node, 0, 0, NULL);
+
 	return menu;
 }
 
@@ -1289,7 +1319,13 @@
 	if (GAIM_BLIST_NODE_IS_GROUP(node)) {
 		menu = create_group_menu(node);
 	} else if (GAIM_BLIST_NODE_IS_CHAT(node)) {
-		menu = create_chat_menu(node);
+		GaimChat *c = (GaimChat *)node;
+		GaimPlugin *prpl = NULL;
+		GaimPluginProtocolInfo *prpl_info = NULL;
+		prpl = gaim_find_prpl(gaim_account_get_protocol_id(c->account));
+		if (prpl != NULL)
+			prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(prpl);
+		menu = create_chat_menu(node, c, prpl, prpl_info);
 	} else if ((GAIM_BLIST_NODE_IS_CONTACT(node)) && (gtknode->contact_expanded)) {
 		menu = create_contact_menu(node);
 	} else if (GAIM_BLIST_NODE_IS_CONTACT(node) || GAIM_BLIST_NODE_IS_BUDDY(node)) {
--- a/src/multi.h	Mon Apr 05 20:15:29 2004 +0000
+++ b/src/multi.h	Mon Apr 05 20:42:13 2004 +0000
@@ -39,6 +39,12 @@
 	GaimConnection *gc;
 };
 
+struct proto_chat_menu {
+	char *label;
+	void (*callback)(GaimConnection *, GHashTable *);
+	GaimConnection *gc;
+};
+
 struct proto_chat_entry {
 	char *label;
 	char *identifier;
--- a/src/protocols/gg/gg.c	Mon Apr 05 20:15:29 2004 +0000
+++ b/src/protocols/gg/gg.c	Mon Apr 05 20:42:13 2004 +0000
@@ -1,6 +1,6 @@
 /*
  * gaim - Gadu-Gadu Protocol Plugin
- * $Id: gg.c 9316 2004-04-03 01:33:45Z thekingant $
+ * $Id: gg.c 9336 2004-04-05 20:42:13Z eblanton $
  *
  * Copyright (C) 2001 Arkadiusz Mi¶kiewicz <misiek@pld.ORG.PL>
  *
@@ -1354,7 +1354,8 @@
 	NULL,
 	NULL,
 	NULL,
-	NULL
+	NULL,
+        NULL
 };
 
 static GaimPluginInfo info =
--- a/src/protocols/irc/irc.c	Mon Apr 05 20:15:29 2004 +0000
+++ b/src/protocols/irc/irc.c	Mon Apr 05 20:42:13 2004 +0000
@@ -592,7 +592,8 @@
 	NULL,
 	irc_roomlist_get_list,
 	irc_roomlist_cancel,
-	NULL
+	NULL,
+        NULL
 };
 
 
--- a/src/protocols/jabber/jabber.c	Mon Apr 05 20:15:29 2004 +0000
+++ b/src/protocols/jabber/jabber.c	Mon Apr 05 20:42:13 2004 +0000
@@ -1329,7 +1329,8 @@
 	jabber_find_blist_chat,
 	jabber_roomlist_get_list,
 	jabber_roomlist_cancel,
-	NULL
+	NULL,
+        NULL
 };
 
 static GaimPluginInfo info =
--- a/src/protocols/msn/msn.c	Mon Apr 05 20:15:29 2004 +0000
+++ b/src/protocols/msn/msn.c	Mon Apr 05 20:42:13 2004 +0000
@@ -1648,7 +1648,14 @@
 	msn_convo_closed,
 	msn_normalize,
 	msn_set_buddy_icon,
-	msn_remove_group
+	msn_remove_group,
+        NULL,
+        NULL,
+        NULL,
+        NULL,
+        NULL,
+        NULL,
+        NULL
 };
 
 static GaimPluginInfo info =
--- a/src/protocols/napster/napster.c	Mon Apr 05 20:15:29 2004 +0000
+++ b/src/protocols/napster/napster.c	Mon Apr 05 20:42:13 2004 +0000
@@ -612,7 +612,16 @@
 	NULL,
 	NULL,
 	NULL,
-	NULL
+	NULL,
+        NULL,
+        NULL,
+        NULL,
+        NULL,
+        NULL,
+        NULL,
+        NULL,
+        NULL,
+        NULL
 };
 
 static GaimPluginInfo info =
--- a/src/protocols/oscar/oscar.c	Mon Apr 05 20:15:29 2004 +0000
+++ b/src/protocols/oscar/oscar.c	Mon Apr 05 20:42:13 2004 +0000
@@ -6963,7 +6963,15 @@
 	NULL,
 	oscar_convo_closed,
 	NULL,
-	oscar_set_icon
+	oscar_set_icon,
+        NULL,
+        NULL,
+        NULL,
+        NULL,
+        NULL,
+        NULL,
+        NULL,
+        NULL
 };
 
 static GaimPluginInfo info =
--- a/src/protocols/rendezvous/rendezvous.c	Mon Apr 05 20:15:29 2004 +0000
+++ b/src/protocols/rendezvous/rendezvous.c	Mon Apr 05 20:42:13 2004 +0000
@@ -469,7 +469,8 @@
 	NULL,
 	NULL,
 	NULL,
-	NULL
+	NULL,
+        NULL
 };
 
 static GaimPluginInfo info =
--- a/src/protocols/toc/toc.c	Mon Apr 05 20:15:29 2004 +0000
+++ b/src/protocols/toc/toc.c	Mon Apr 05 20:42:13 2004 +0000
@@ -2140,7 +2140,16 @@
 	NULL,
 	NULL,
 	NULL,
-	NULL
+	NULL,
+        NULL,
+        NULL,
+        NULL,
+        NULL,
+        NULL,
+        NULL,
+        NULL,
+        NULL,
+        NULL
 };
 
 static GaimPluginInfo info =
--- a/src/protocols/trepia/trepia.c	Mon Apr 05 20:15:29 2004 +0000
+++ b/src/protocols/trepia/trepia.c	Mon Apr 05 20:42:13 2004 +0000
@@ -1307,7 +1307,15 @@
 	trepia_buddy_free,
 	NULL,
 	NULL,
-	trepia_set_buddy_icon
+	trepia_set_buddy_icon,
+        NULL,
+        NULL,
+        NULL,
+        NULL,
+        NULL,
+        NULL,
+        NULL,
+        NULL
 };
 
 static GaimPluginInfo info =
--- a/src/protocols/yahoo/yahoo.c	Mon Apr 05 20:15:29 2004 +0000
+++ b/src/protocols/yahoo/yahoo.c	Mon Apr 05 20:42:13 2004 +0000
@@ -3275,6 +3275,7 @@
 	yahoo_roomlist_get_list,
 	yahoo_roomlist_cancel,
 	yahoo_roomlist_expand_category,
+        NULL
 };
 
 static GaimPluginInfo info =
--- a/src/protocols/zephyr/zephyr.c	Mon Apr 05 20:15:29 2004 +0000
+++ b/src/protocols/zephyr/zephyr.c	Mon Apr 05 20:42:13 2004 +0000
@@ -1376,7 +1376,12 @@
 	NULL,
 	NULL,
 	NULL,
-	zephyr_chat_set_topic
+	zephyr_chat_set_topic,
+        NULL,
+        NULL,
+        NULL,
+        NULL,
+        NULL
 };
 
 static GaimPluginInfo info =
--- a/src/prpl.h	Mon Apr 05 20:15:29 2004 +0000
+++ b/src/prpl.h	Mon Apr 05 20:42:13 2004 +0000
@@ -329,6 +329,8 @@
 	void (*roomlist_cancel)(struct _GaimRoomlist *list);
 	void (*roomlist_expand_category)(struct _GaimRoomlist *list, struct _GaimRoomlistRoom *category);
 
+	/* Chat specific menu in the buddy list */
+	GList *(*chat_menu)(GaimConnection *, GHashTable *);
 };
 
 #define GAIM_IS_PROTOCOL_PLUGIN(plugin) \