changeset 16972:dfcc9b337595

Make Google Talk stick when chosen, rather than jumping right to XMPP.
author Richard Laager <rlaager@wiktel.com>
date Wed, 09 May 2007 21:12:35 +0000
parents 21b7f05a2878
children 071fce59e5e9
files pidgin/gtkaccount.c pidgin/gtkutils.c
diffstat 2 files changed, 32 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/pidgin/gtkaccount.c	Wed May 09 19:12:26 2007 +0000
+++ b/pidgin/gtkaccount.c	Wed May 09 21:12:35 2007 +0000
@@ -385,12 +385,20 @@
 add_login_options(AccountPrefsDialog *dialog, GtkWidget *parent)
 {
 	GtkWidget *frame;
+	GtkWidget *hbox;
 	GtkWidget *vbox;
 	GtkWidget *entry;
 	GList *user_splits;
 	GList *l, *l2;
 	char *username = NULL;
 
+	if (dialog->protocol_menu != NULL)
+	{
+		gtk_widget_ref(dialog->protocol_menu);
+		hbox = g_object_get_data(G_OBJECT(dialog->protocol_menu), "container");
+		gtk_container_remove(GTK_CONTAINER(hbox), dialog->protocol_menu);
+	}
+
 	if (dialog->login_frame != NULL)
 		gtk_widget_destroy(dialog->login_frame);
 
@@ -409,10 +417,17 @@
 	gtk_widget_show(vbox);
 
 	/* Protocol */
-	dialog->protocol_menu = pidgin_protocol_option_menu_new(
-			dialog->protocol_id, G_CALLBACK(set_account_protocol_cb), dialog);
-
-	add_pref_box(dialog, vbox, _("Protocol:"), dialog->protocol_menu);
+	if (dialog->protocol_menu == NULL)
+	{
+		dialog->protocol_menu = pidgin_protocol_option_menu_new(
+				dialog->protocol_id, G_CALLBACK(set_account_protocol_cb), dialog);
+		gtk_widget_ref(dialog->protocol_menu);
+	}
+
+	hbox = add_pref_box(dialog, vbox, _("Protocol:"), dialog->protocol_menu);
+	g_object_set_data(G_OBJECT(dialog->protocol_menu), "container", hbox);
+
+	gtk_widget_unref(dialog->protocol_menu);
 
 	/* Screen name */
 	dialog->screenname_entry = gtk_entry_new();
--- a/pidgin/gtkutils.c	Wed May 09 19:12:26 2007 +0000
+++ b/pidgin/gtkutils.c	Wed May 09 21:12:35 2007 +0000
@@ -444,13 +444,13 @@
 	protocol = g_object_get_data(G_OBJECT(item), "protocol");
 
 	if (!strcmp(protocol, "prpl-fake"))
-	{
-		guint index = GPOINTER_TO_UINT(g_object_get_data(G_OBJECT(item), "real_index"));
-		gtk_option_menu_set_history(GTK_OPTION_MENU(optmenu), index);
+		protocol = g_object_get_data(G_OBJECT(item), "real_protocol");
+
+	if (!strcmp(protocol, g_object_get_data(G_OBJECT(optmenu), "last_protocol")))
 		return;
-	}
 
 	user_data = (g_object_get_data(G_OBJECT(optmenu), "user_data"));
+	g_object_set_data(G_OBJECT(optmenu), "last_protocol", (gpointer)protocol);
 
 	if (cb != NULL)
 		((void (*)(GtkWidget *, const char *, gpointer))cb)(item, protocol,
@@ -545,7 +545,15 @@
 		pidgin_protocol_option_menu_item(menu, sg, image, plugin->info->name, plugin->info->id);
 
 		if (id != NULL && !strcmp(plugin->info->id, id))
+		{
+			g_object_set_data(G_OBJECT(optmenu), "last_protocol", plugin->info->id);
 			selected_index = i;
+		}
+		else if (i == 0)
+		{
+			/* Ensure we set the protocol even if id is NULL or can't be found. */
+			g_object_set_data(G_OBJECT(optmenu), "last_protocol", plugin->info->id);
+		}
 
 		if (!strcmp(plugin->info->id, "prpl-jabber"))
 		{
@@ -556,7 +564,7 @@
 				image = gtk_image_new();
 
 			gtalk_item = pidgin_protocol_option_menu_item(menu, sg, image, _("Google Talk (XMPP)"), "prpl-fake");
-			g_object_set_data(G_OBJECT(gtalk_item), "real_index", GUINT_TO_POINTER(i));
+			g_object_set_data(G_OBJECT(gtalk_item), "real_protocol", plugin->info->id);
 			i++;
 		}