changeset 5880:1b85ff65be57

[gaim-migrate @ 6312] The neat little account drop-down is now used in the Send IM and Get Info dialogs. committer: Tailor Script <tailor@pidgin.im>
author Christian Hammond <chipx86@chipx86.com>
date Sun, 15 Jun 2003 05:24:57 +0000
parents d58406d31a1a
children cc7870e1e3b3
files src/dialogs.c src/gtkutils.c
diffstat 2 files changed, 19 insertions(+), 71 deletions(-) [+]
line wrap: on
line diff
--- a/src/dialogs.c	Sun Jun 15 04:58:09 2003 +0000
+++ b/src/dialogs.c	Sun Jun 15 05:24:57 2003 +0000
@@ -596,10 +596,10 @@
 	gtk_widget_show_all(window);
 }
 
-void show_info_select_account(GObject *w, GaimConnection *gc)
+void show_info_select_account(GObject *w, GaimAccount *account,
+							  struct getuserinfo *info)
 {
-	struct getuserinfo *info = g_object_get_data(w, "getuserinfo");
-	info->gc = gc;
+	info->gc = gaim_account_get_connection(account);
 }
 
 static void dialog_set_ok_sensitive(GtkWidget *entry, GtkWidget *dlg) {
@@ -612,12 +612,8 @@
 {
 	GtkWidget *hbox, *vbox;
 	GtkWidget *label;
-	GtkWidget *table, *menu, *opt;
-	GList *g = gaim_connections_get_all();
-	GaimConnection *c;
-	GaimAccount *account;
+	GtkWidget *table;
 	struct gaim_gtk_buddy_list *gtkblist;
-	char buf[256];
 	GtkWidget *img = gtk_image_new_from_stock(GAIM_STOCK_DIALOG_QUESTION, GTK_ICON_SIZE_DIALOG);
 	struct getuserinfo *info = NULL;
 
@@ -678,36 +674,11 @@
 			gtk_label_set_markup_with_mnemonic(GTK_LABEL(label), _("_Account:"));
 			gtk_misc_set_alignment(GTK_MISC(label), 0, 0);
 
-			info->account = gtk_option_menu_new();
+			info->account = gaim_gtk_account_option_menu_new(NULL, FALSE,
+					G_CALLBACK(show_info_select_account), info);
+
 			gtk_table_attach_defaults(GTK_TABLE(table), info->account, 1, 2, 1, 2);
 			gtk_label_set_mnemonic_widget(GTK_LABEL(label), GTK_WIDGET(info->account));
-
-			menu = gtk_menu_new();
-
-			while (g) {
-				c = (GaimConnection *)g->data;
-
-				if (!GAIM_PLUGIN_PROTOCOL_INFO(c->prpl)->send_im) {
-					g = g->next;
-					continue;
-				}
-
-				account = gaim_connection_get_account(c);
-
-				g_snprintf(buf, sizeof(buf), "%s (%s)",
-						   gaim_account_get_username(account),
-						   c->prpl->info->name);
-				opt = gtk_menu_item_new_with_label(buf);
-				g_object_set_data(G_OBJECT(opt), "getuserinfo", info);
-
-				g_signal_connect(G_OBJECT(opt), "activate",
-						   G_CALLBACK(show_info_select_account), c);
-
-				gtk_menu_shell_append(GTK_MENU_SHELL(menu), opt);
-				g = g->next;
-			}
-
-			gtk_option_menu_set_menu(GTK_OPTION_MENU(info->account), menu);
 		}
 
 		g_signal_connect(G_OBJECT(imdialog), "response", G_CALLBACK(do_im), info);
@@ -723,13 +694,9 @@
 	GtkWidget *window, *hbox, *vbox;
 	GtkWidget *label;
 	GtkWidget *img = gtk_image_new_from_stock(GAIM_STOCK_DIALOG_QUESTION, GTK_ICON_SIZE_DIALOG);
-	GtkWidget *table, *menu, *opt;
-	GList *g = gaim_connections_get_all();
-	GaimConnection *c;
-	GaimAccount *account;
+	GtkWidget *table;
 	struct getuserinfo *info = g_new0(struct getuserinfo, 1);
 	struct gaim_gtk_buddy_list *gtkblist;
-	char buf[256];
 
 	gtkblist = GAIM_GTK_BLIST(gaim_get_blist());
 
@@ -785,36 +752,11 @@
 		gtk_label_set_markup_with_mnemonic(GTK_LABEL(label), _("_Account:"));
 		gtk_misc_set_alignment(GTK_MISC(label), 0, 0);
 
-		info->account = gtk_option_menu_new();
+		info->account = gaim_gtk_account_option_menu_new(NULL, FALSE,
+				G_CALLBACK(show_info_select_account), info);
+
 		gtk_table_attach_defaults(GTK_TABLE(table), info->account, 1, 2, 1, 2);
 		gtk_label_set_mnemonic_widget(GTK_LABEL(label), GTK_WIDGET(info->account));
-		
-		menu = gtk_menu_new();
-
-		while (g) {
-			c = (GaimConnection *)g->data;
-
-			if (!GAIM_PLUGIN_PROTOCOL_INFO(c->prpl)->get_info) {
-				g = g->next;
-				continue;
-			}
-
-			account = gaim_connection_get_account(c);
-
-			g_snprintf(buf, sizeof(buf), "%s (%s)",
-					   gaim_account_get_username(account),
-					   c->prpl->info->name);
-			opt = gtk_menu_item_new_with_label(buf);
-			g_object_set_data(G_OBJECT(opt), "getuserinfo", info);
-
-			g_signal_connect(G_OBJECT(opt), "activate",
-					   G_CALLBACK(show_info_select_account), c);
-
-			gtk_menu_shell_append(GTK_MENU_SHELL(menu), opt);
-			g = g->next;
-		}
-		
-		gtk_option_menu_set_menu(GTK_OPTION_MENU(info->account), menu);
 	}
 
 	g_signal_connect(G_OBJECT(window), "response", G_CALLBACK(do_info), info);
--- a/src/gtkutils.c	Sun Jun 15 04:58:09 2003 +0000
+++ b/src/gtkutils.c	Sun Jun 15 05:24:57 2003 +0000
@@ -691,13 +691,15 @@
 	menu = gtk_menu_new();
 	gtk_widget_show(menu);
 
-	sg  = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
+	sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
 
 	if (show_all)
 		list = gaim_accounts_get_all();
 	else
 		list = gaim_connections_get_all();
 
+	gaim_debug(GAIM_DEBUG_INFO, "gtkutils", "Populating menu\n");
+
 	for (p = list, i = 0; p != NULL; p = p->next, i++) {
 		GaimPluginProtocolInfo *prpl_info = NULL;
 		GaimPlugin *plugin;
@@ -710,6 +712,8 @@
 			account = gaim_connection_get_account(gc);
 		}
 
+		gaim_debug(GAIM_DEBUG_INFO, "gtkutils", "Adding item.\n");
+
 		plugin = gaim_find_prpl(gaim_account_get_protocol(account));
 
 		if (plugin != NULL)
@@ -768,10 +772,12 @@
 		gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
 		gtk_widget_show(item);
 
-		if (account == default_account)
+		if (default_account != NULL && account == default_account)
 			selected_index = i;
 	}
 
+	gaim_debug(GAIM_DEBUG_INFO, "gtkutils", "Done populating menu\n");
+
 	gtk_option_menu_set_menu(GTK_OPTION_MENU(optmenu), menu);
 
 	if (selected_index != -1)