changeset 16966:825f0fe66304

Add Google Talk to the account editor. I'm sure this will be controversial. If you select "Google Talk (XMPP)", you get "XMPP".
author Richard Laager <rlaager@wiktel.com>
date Wed, 09 May 2007 02:45:35 +0000
parents ab45289d2c36
children abbbc8374c74 a728447e4e72 cbe900af96a8
files pidgin/gtkutils.c
diffstat 1 files changed, 64 insertions(+), 33 deletions(-) [+]
line wrap: on
line diff
--- a/pidgin/gtkutils.c	Wed May 09 01:21:15 2007 +0000
+++ b/pidgin/gtkutils.c	Wed May 09 02:45:35 2007 +0000
@@ -442,6 +442,14 @@
 	item = gtk_menu_get_active(GTK_MENU(menu));
 
 	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);
+		return;
+	}
+
 	user_data = (g_object_get_data(G_OBJECT(optmenu), "user_data"));
 
 	if (cb != NULL)
@@ -449,19 +457,53 @@
 															user_data);
 }
 
+static GtkWidget *
+pidgin_protocol_option_menu_item(GtkWidget *menu, GtkSizeGroup *sg, GtkWidget *image,
+                                  const char *name, const char *id)
+{
+	GtkWidget *item;
+	GtkWidget *hbox;
+	GtkWidget *label;
+
+	/* Create the item. */
+	item = gtk_menu_item_new();
+
+	/* Create the hbox. */
+	hbox = gtk_hbox_new(FALSE, 4);
+	gtk_container_add(GTK_CONTAINER(item), hbox);
+	gtk_widget_show(hbox);
+
+	gtk_size_group_add_widget(sg, image);
+
+	gtk_box_pack_start(GTK_BOX(hbox), image, FALSE, FALSE, 0);
+	gtk_widget_show(image);
+
+	/* Create the label. */
+	label = gtk_label_new(name);
+	gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT);
+	gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
+	gtk_box_pack_start(GTK_BOX(hbox), label, TRUE, TRUE, 0);
+	gtk_widget_show(label);
+
+	g_object_set_data(G_OBJECT(item), "protocol", (gpointer)id);
+
+	gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
+	gtk_widget_show(item);
+	pidgin_set_accessible_label (item, label);
+
+	return item;
+}
+
 GtkWidget *
 pidgin_protocol_option_menu_new(const char *id, GCallback cb,
 								  gpointer user_data)
 {
 	PurplePluginProtocolInfo *prpl_info;
 	PurplePlugin *plugin;
-	GtkWidget *hbox;
-	GtkWidget *label;
 	GtkWidget *optmenu;
 	GtkWidget *menu;
-	GtkWidget *item;
+	GdkPixbuf *pixbuf;
 	GtkWidget *image;
-	GdkPixbuf *pixbuf;
 	GList *p;
 	GtkSizeGroup *sg;
 	char *filename;
@@ -486,14 +528,6 @@
 		plugin = (PurplePlugin *)p->data;
 		prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(plugin);
 
-		/* Create the item. */
-		item = gtk_menu_item_new();
-
-		/* Create the hbox. */
-		hbox = gtk_hbox_new(FALSE, 4);
-		gtk_container_add(GTK_CONTAINER(item), hbox);
-		gtk_widget_show(hbox);
-
 		/* Load the image. */
 		proto_name = prpl_info->list_icon(NULL, NULL);
 		g_snprintf(buf, sizeof(buf), "%s.png", proto_name);
@@ -503,34 +537,31 @@
 		pixbuf = gdk_pixbuf_new_from_file(filename, NULL);
 		g_free(filename);
 
-		if (pixbuf) {
+		if (pixbuf)
 			image = gtk_image_new_from_pixbuf(pixbuf);
-
-			g_object_unref(G_OBJECT(pixbuf));
-		}
 		else
 			image = gtk_image_new();
 
-		gtk_size_group_add_widget(sg, image);
-
-		gtk_box_pack_start(GTK_BOX(hbox), image, FALSE, FALSE, 0);
-		gtk_widget_show(image);
-
-		/* Create the label. */
-		label = gtk_label_new(plugin->info->name);
-		gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT);
-		gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
-		gtk_box_pack_start(GTK_BOX(hbox), label, TRUE, TRUE, 0);
-		gtk_widget_show(label);
-
-		g_object_set_data(G_OBJECT(item), "protocol", plugin->info->id);
-
-		gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
-		gtk_widget_show(item);
-		pidgin_set_accessible_label (item, label);
+		pidgin_protocol_option_menu_item(menu, sg, image, plugin->info->name, plugin->info->id);
 
 		if (id != NULL && !strcmp(plugin->info->id, id))
 			selected_index = i;
+
+		if (!strcmp(plugin->info->id, "prpl-jabber"))
+		{
+			GtkWidget *gtalk_item;
+			if (pixbuf)
+				image = gtk_image_new_from_pixbuf(pixbuf);
+			else
+				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));
+			i++;
+		}
+
+		if (pixbuf)
+			g_object_unref(G_OBJECT(pixbuf));
 	}
 
 	gtk_option_menu_set_menu(GTK_OPTION_MENU(optmenu), menu);