[gaim-migrate @ 9791]

Sat, 22 May 2004 17:33:38 +0000

author
Christopher O'Brien <siege@pidgin.im>
date
Sat, 22 May 2004 17:33:38 +0000
changeset 9015
3c27e9074fa2
parent 9014
047e5fb72251
child 9016
69f5ff966dc7

[gaim-migrate @ 9791]
(05:54:53) siege: that's the first pass on merging the two action sources
(05:55:27) siege: using it right now, seems to be working fine. You may
want to look it over though...
(05:56:04) siege: found a small mem-leak in a GList getting created and not
destroyed, this fixes that as well

(13:20:40) KingAnt: LSchiere: Well it's probably ok. I haven't even had a
chance to look at the commit for the other thing

committer: Luke Schierer <lschiere@pidgin.im>

plugins/idle.c file | annotate | diff | comparison | revisions
src/gtkblist.c file | annotate | diff | comparison | revisions
src/multi.h file | annotate | diff | comparison | revisions
src/plugin.c file | annotate | diff | comparison | revisions
src/plugin.h file | annotate | diff | comparison | revisions
src/protocols/gg/gg.c file | annotate | diff | comparison | revisions
src/protocols/irc/irc.c file | annotate | diff | comparison | revisions
src/protocols/jabber/buddy.c file | annotate | diff | comparison | revisions
src/protocols/jabber/buddy.h file | annotate | diff | comparison | revisions
src/protocols/jabber/jabber.c file | annotate | diff | comparison | revisions
src/protocols/msn/msn.c file | annotate | diff | comparison | revisions
src/protocols/napster/napster.c file | annotate | diff | comparison | revisions
src/protocols/novell/novell.c file | annotate | diff | comparison | revisions
src/protocols/oscar/oscar.c file | annotate | diff | comparison | revisions
src/protocols/silc/silc.c file | annotate | diff | comparison | revisions
src/protocols/toc/toc.c file | annotate | diff | comparison | revisions
src/protocols/trepia/trepia.c file | annotate | diff | comparison | revisions
src/protocols/yahoo/yahoo.c file | annotate | diff | comparison | revisions
src/protocols/zephyr/zephyr.c file | annotate | diff | comparison | revisions
src/prpl.h file | annotate | diff | comparison | revisions
--- a/plugins/idle.c	Sat May 22 17:20:27 2004 +0000
+++ b/plugins/idle.c	Sat May 22 17:33:38 2004 +0000
@@ -7,7 +7,6 @@
 
 #include "connection.h"
 #include "debug.h"
-#include "multi.h"
 #include "plugin.h"
 #include "request.h"
 #include "server.h"
@@ -39,7 +38,7 @@
 
 
 static void
-idle_action(GaimPlugin *plugin)
+idle_action(GaimPluginAction *action)
 {
 	/* Use the super fancy request API */
 
@@ -59,7 +58,7 @@
 	request = gaim_request_fields_new();
 	gaim_request_fields_add_group(request, group);
 
-	gaim_request_fields(plugin,
+	gaim_request_fields(action->plugin,
 			N_("I'dle Mak'er"),
 			_("Set Account Idle Time"),
 			NULL,
@@ -71,16 +70,14 @@
 
 
 static GList *
-actions(GaimPlugin *plugin)
+actions(GaimPlugin *plugin, gpointer context)
 {
 	GList *l = NULL;
-	struct plugin_actions_menu *pam;
+	GaimPluginAction *act = NULL;
 
-	pam = g_new0(struct plugin_actions_menu, 1);
-	pam->label = _("Set Account Idle Time");
-	pam->callback = idle_action;
-	pam->plugin = plugin;
-	l = g_list_append(l, pam);
+	act = gaim_plugin_action_new(_("Set Account Idle Time"),
+			idle_action);
+	l = g_list_append(l, act);
 
 	return l;
 }
--- a/src/gtkblist.c	Sat May 22 17:20:27 2004 +0000
+++ b/src/gtkblist.c	Sat May 22 17:33:38 2004 +0000
@@ -23,6 +23,7 @@
 #include "gtkinternal.h"
 
 #include "account.h"
+#include "connection.h"
 #include "core.h"
 #include "debug.h"
 #include "multi.h"
@@ -4930,117 +4931,108 @@
 
 #endif
 
+
 static void
-proto_act(GtkObject *obj, struct proto_actions_menu *pam)
+plugin_act(GtkObject *obk, GaimPluginAction *pam)
 {
-	if (pam->callback && pam->gc)
-		pam->callback(pam->gc);
+	if (pam->callback) pam->callback(pam);
 }
 
 
+
 static void
-plugin_act(GtkObject *obk, struct plugin_actions_menu *pam)
+build_plugin_actions(GtkWidget *menu, GaimPlugin *plugin, gpointer context)
 {
-	if (pam->callback && pam->plugin)
-		pam->callback(pam->plugin);
+	GtkWidget *menuitem = NULL;
+	GaimPluginAction *action = NULL;
+	GList *l, *ll;
+
+	for (l = ll = GAIM_PLUGIN_ACTIONS(plugin, context); l; l = l->next) {
+		if (l->data) {
+			action = (GaimPluginAction *) l->data;
+			action->plugin = plugin;
+			action->context = context;
+
+			menuitem = gtk_menu_item_new_with_label(action->label);
+			gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
+			g_signal_connect(G_OBJECT(menuitem), "activate",
+					G_CALLBACK(plugin_act), action);
+			g_object_set_data(G_OBJECT(menuitem), "plugin_action", action);
+			gtk_widget_show(menuitem);
+		}
+		else
+			gaim_separator(menu);
+	}
+
+	g_list_free(ll);
 }
 
 
 void
 gaim_gtk_blist_update_protocol_actions(void)
 {
-	GtkWidget *menuitem;
-	GtkWidget *submenu;
-	GaimPluginProtocolInfo *prpl_info = NULL;
+	GtkWidget *menuitem, *submenu;
 	GList *l;
-	GList *c;
-	struct proto_actions_menu *pam;
 	GaimConnection *gc = NULL;
+	GaimPlugin *plugin = NULL;
 	int count = 0;
-	char buf[256];
-
-	if (!protomenu)
+
+	if (! protomenu)
 		return;
 
-	for (l = gtk_container_get_children(GTK_CONTAINER(protomenu));
-		 l != NULL;
-		 l = l->next) {
-
+	for (l = gtk_container_get_children(GTK_CONTAINER(protomenu)); l; l = l->next) {
+		GaimPluginAction *action;
+		
 		menuitem = l->data;
-		pam = g_object_get_data(G_OBJECT(menuitem), "proto_actions_menu");
-
-		if (pam)
-			g_free(pam);
+		action = (GaimPluginAction *) g_object_get_data(G_OBJECT(menuitem),
+				"plugin_action");
+		g_free(action);
 
 		gtk_container_remove(GTK_CONTAINER(protomenu), GTK_WIDGET(menuitem));
 	}
 
-	for (c = gaim_connections_get_all(); c != NULL; c = c->next) {
-		gc = c->data;
-
-		prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl);
-
-		if (prpl_info->actions && gc->login_time)
-			count++;
+	for (l = gaim_connections_get_all(); l; l = l->next) {
+		gc = l->data;
+		plugin = gc->prpl;
+
+		/* no need to count past 2, so don't */
+		if (gc->login_time && GAIM_PLUGIN_HAS_ACTIONS(plugin) && count++)
+			break;
 	}
 
-	if (!count) {
-		g_snprintf(buf, sizeof(buf), _("No actions available"));
-		menuitem = gtk_menu_item_new_with_label(buf);
+	
+	if (count == 0) {
+		menuitem = gtk_menu_item_new_with_label(_("No actions available"));
 		gtk_menu_shell_append(GTK_MENU_SHELL(protomenu), menuitem);
+		gtk_widget_set_sensitive(menuitem, FALSE);
 		gtk_widget_show(menuitem);
-		return;
+
 	}
-
+	else
 	if (count == 1) {
-		GList *act;
-
-		for (c = gaim_connections_get_all(); c != NULL; c = c->next) {
-			gc = c->data;
-
-			prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl);
-
-			if (prpl_info->actions && gc->login_time)
-				break;
-		}
-
-		for (act = prpl_info->actions(gc); act != NULL; act = act->next) {
-			if (act->data) {
-				struct proto_actions_menu *pam = act->data;
-				menuitem = gtk_menu_item_new_with_label(pam->label);
-				gtk_menu_shell_append(GTK_MENU_SHELL(protomenu), menuitem);
-				g_signal_connect(G_OBJECT(menuitem), "activate",
-								 G_CALLBACK(proto_act), pam);
-				g_object_set_data(G_OBJECT(menuitem), "proto_actions_menu", pam);
-				gtk_widget_show(menuitem);
-			}
-			else
-				gaim_separator(protomenu);
-		}
+		/* plugin and gc will be set from the counting loop already */
+		build_plugin_actions(protomenu, plugin, gc);
 	}
 	else {
-		for (c = gaim_connections_get_all(); c != NULL; c = c->next) {
+		for (l = gaim_connections_get_all(); l; l = l->next) {