changeset 32590:a3c70b71e18a

Try to reduce the printf'ing a little in the account menu creation.
author Elliott Sales de Andrade <qulogic@pidgin.im>
date Tue, 28 Jul 2009 03:02:29 +0000
parents f55f8592986c
children c8a8e9f8a6e7
files pidgin/gtkblist.c
diffstat 1 files changed, 9 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/pidgin/gtkblist.c	Tue Jul 28 02:48:40 2009 +0000
+++ b/pidgin/gtkblist.c	Tue Jul 28 03:02:29 2009 +0000
@@ -8225,12 +8225,13 @@
 
 	for (accounts = purple_accounts_get_all(); accounts; accounts = accounts->next) {
 		char *label;
+		char *base;
 		char *name;
 		PurpleAccount *account = NULL;
 
 		account = accounts->data;
 
-		name = g_strdup_printf("account%d", count);
+		base = name = g_strdup_printf("account%d", count);
 		label = g_strconcat(purple_account_get_username(account), " (",
 				purple_account_get_protocol_name(account), ")", NULL);
 		action = gtk_action_new(name, label, NULL, NULL);
@@ -8241,16 +8242,14 @@
 			g_string_append_printf(enable_ui, "<menuitem action='%s'/>", name);
 			g_signal_connect(G_OBJECT(action), "activate",
 			                 G_CALLBACK(enable_account_cb), account);
-			g_free(name);
 
 		} else {
 			PurpleConnection *gc = NULL;
 			PurplePlugin *plugin = NULL;
 
 			g_string_append_printf(accounts_ui, "<menu action='%s'>", name);
-			g_free(name);
-
-			name = g_strdup_printf("account%d-edit", count);
+
+			name = g_strconcat(base, "-edit", NULL);
 			action = gtk_action_new(name, N_("_Edit Account"), NULL, NULL);
 			gtk_action_group_add_action(accounts_action_group, action);
 			g_signal_connect(G_OBJECT(action), "activate",
@@ -8263,16 +8262,14 @@
 			gc = purple_account_get_connection(account);
 			plugin = gc && PURPLE_CONNECTION_IS_CONNECTED(gc) ? gc->prpl : NULL;
 			if (plugin && PURPLE_PLUGIN_HAS_ACTIONS(plugin)) {
-				name = g_strdup_printf("account%d", count);
-				build_plugin_actions(accounts_action_group, accounts_ui, name, plugin, gc);
-				g_free(name);
+				build_plugin_actions(accounts_action_group, accounts_ui, base, plugin, gc);
 			} else {
 				g_string_append(accounts_ui, "<menuitem action='none-available'/>");
 			}
 
 			g_string_append(accounts_ui, "<separator/>");
 
-			name = g_strdup_printf("account%d-disable", count);
+			name = g_strconcat(base, "-disable", NULL);
 			action = gtk_action_new(name, N_("_Disable"), NULL, NULL);
 			gtk_action_group_add_action(accounts_action_group, action);
 			g_signal_connect(G_OBJECT(action), "activate",
@@ -8282,6 +8279,8 @@
 
 			g_string_append(accounts_ui, "</menu>");
 		}
+
+		g_free(base);
 		count++;
 	}
 
@@ -8294,6 +8293,7 @@
 	gtk_ui_manager_insert_action_group(gtkblist->ui, accounts_action_group, 1);
 	accounts_merge_id = gtk_ui_manager_add_ui_from_string(gtkblist->ui, ui_string, -1, NULL);
 purple_debug_info("blist", "The account menu is {%s}\n", ui_string);
+
 	g_string_free(enable_ui, TRUE);
 	g_string_free(accounts_ui, TRUE);
 	g_free(ui_string);