From: <the...@us...> - 2007-04-01 17:31:56
|
Revision: 18225 http://svn.sourceforge.net/gaim/?rev=18225&view=rev Author: thekingant Date: 2007-04-01 10:31:56 -0700 (Sun, 01 Apr 2007) Log Message: ----------- sf patch #1689182, from Will Thompson gtkblist: remove code duplication, and plug a leak Over in gtkblist.c, the code to generate plugin action menus is the same for regular plugins and prpls, except that there is non-NULL context in the latter. It was copy-pasted. Now it is not. Incidentally, the version in gaim_gtk_blist_update_accounts_menu was leaking the list every time: a pointer to the start was kept, presumably with the intention that the list be freed, but it never actually was. Modified Paths: -------------- trunk/gtk/gtkblist.c Modified: trunk/gtk/gtkblist.c =================================================================== --- trunk/gtk/gtkblist.c 2007-04-01 08:06:29 UTC (rev 18224) +++ trunk/gtk/gtkblist.c 2007-04-01 17:31:56 UTC (rev 18225) @@ -6202,13 +6202,14 @@ } static void -build_plugin_actions(GtkWidget *menu, GaimPlugin *plugin) +build_plugin_actions(GtkWidget *menu, GaimPlugin *plugin, + GaimConnection *context) { GtkWidget *menuitem; GaimPluginAction *action = NULL; GList *actions, *l; - actions = GAIM_PLUGIN_ACTIONS(plugin, NULL); + actions = GAIM_PLUGIN_ACTIONS(plugin, context); for (l = actions; l != NULL; l = l->next) { @@ -6216,7 +6217,7 @@ { action = (GaimPluginAction *) l->data; action->plugin = plugin; - action->context = NULL; + action->context = context; menuitem = gtk_menu_item_new_with_label(action->label); gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); @@ -6288,6 +6289,7 @@ GaimAccount *account = NULL; GaimStatus *status = NULL; GdkPixbuf *pixbuf = NULL; + GaimPlugin *plugin = NULL; account = accounts->data; accel_group = gtk_menu_get_accel_group(GTK_MENU(accountmenu)); @@ -6330,35 +6332,12 @@ gaim_separator(submenu); gc = gaim_account_get_connection(account); - if (gc && GAIM_CONNECTION_IS_CONNECTED(gc)) { - GaimPlugin *plugin = NULL; + plugin = gc ? gc->prpl : NULL; - plugin = gc->prpl; - if (GAIM_PLUGIN_HAS_ACTIONS(plugin)) { - GList *l, *ll = NULL; - GaimPluginAction *action = NULL; - - for (l = ll = GAIM_PLUGIN_ACTIONS(plugin, gc); l; l = l->next) { - if (l->data) { - action = (GaimPluginAction *)l->data; - action->plugin = plugin; - action->context = gc; - - menuitem = gtk_menu_item_new_with_label(action->label); - gtk_menu_shell_append(GTK_MENU_SHELL(submenu), menuitem); - g_signal_connect(G_OBJECT(menuitem), "activate", - G_CALLBACK(plugin_act), action); - g_object_set_data_full(G_OBJECT(menuitem), "plugin_action", action, (GDestroyNotify)gaim_plugin_action_free); - gtk_widget_show(menuitem); - } else - gaim_separator(submenu); - } - } else { - menuitem = gtk_menu_item_new_with_label(_("No actions available")); - gtk_menu_shell_append(GTK_MENU_SHELL(submenu), menuitem); - gtk_widget_set_sensitive(menuitem, FALSE); - gtk_widget_show(menuitem); - } + if (gc && GAIM_CONNECTION_IS_CONNECTED(gc) + && GAIM_PLUGIN_HAS_ACTIONS(plugin)) + { + build_plugin_actions(submenu, plugin, gc); } else { menuitem = gtk_menu_item_new_with_label(_("No actions available")); gtk_menu_shell_append(GTK_MENU_SHELL(submenu), menuitem); @@ -6474,7 +6453,7 @@ gtk_menu_set_accel_path(GTK_MENU(submenu), path); g_free(path); - build_plugin_actions(submenu, plugin); + build_plugin_actions(submenu, plugin, NULL); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |