changeset 5881:cc7870e1e3b3

[gaim-migrate @ 6313] Added the protocol icons to the Join Chat dialog. Unfortunately, we couldn't use my new function, because it must check if a prpl function is set before deciding whether or not to display it. Also, fixed some calls to chats that should only be called on IMs. Harmless, but generated run-time warnings. committer: Tailor Script <tailor@pidgin.im>
author Christian Hammond <chipx86@chipx86.com>
date Sun, 15 Jun 2003 05:41:27 +0000
parents 1b85ff65be57
children ea6dfabdf60f
files src/buddy_chat.c src/gtkconv.c
diffstat 2 files changed, 84 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/src/buddy_chat.c	Sun Jun 15 05:24:57 2003 +0000
+++ b/src/buddy_chat.c	Sun Jun 15 05:41:27 2003 +0000
@@ -170,11 +170,19 @@
 create_joinchat_menu(GtkWidget *box)
 {
 	GaimAccount *account;
+	GtkWidget *hbox;
+	GtkWidget *label;
 	GtkWidget *optmenu;
 	GtkWidget *menu;
 	GtkWidget *opt;
+	GtkWidget *image;
+	GdkPixbuf *pixbuf;
+	GdkPixbuf *scale;
+	GtkSizeGroup *sg;
 	GList *c;
 	GaimConnection *g;
+	const char *proto_name;
+	char *filename;
 	char buf[2048];
 
 	optmenu = gtk_option_menu_new();
@@ -183,10 +191,22 @@
 	menu = gtk_menu_new();
 	joinchatgc = NULL;
 
+	sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
+
 	for (c = gaim_connections_get_all(); c != NULL; c = c->next) {
+		GaimPluginProtocolInfo *prpl_info = NULL;
+		GaimPlugin *plugin;
+
 		g = (GaimConnection *)c->data;
 
-		if (!GAIM_PLUGIN_PROTOCOL_INFO(g->prpl)->join_chat)
+		plugin = g->prpl;
+
+		if (plugin == NULL)
+			continue;
+
+		prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(plugin);
+
+		if (prpl_info == NULL || prpl_info->join_chat == NULL)
 			continue;
 
 		if (!joinchatgc)
@@ -196,7 +216,53 @@
 
 		g_snprintf(buf, sizeof(buf), "%s (%s)",
 				   gaim_account_get_username(account), g->prpl->info->name);
-		opt = gtk_menu_item_new_with_label(buf);
+
+		opt = gtk_menu_item_new();
+
+		/* Create the hbox. */
+		hbox = gtk_hbox_new(FALSE, 4);
+		gtk_container_add(GTK_CONTAINER(opt), hbox);
+		gtk_widget_show(hbox);
+
+		/* Load the image. */
+		if (prpl_info != NULL) {
+			proto_name = prpl_info->list_icon(NULL, NULL);
+			g_snprintf(buf, sizeof(buf), "%s.png", proto_name);
+
+			filename = g_build_filename(DATADIR, "pixmaps", "gaim", "status",
+										"default", buf, NULL);
+			pixbuf = gdk_pixbuf_new_from_file(filename, NULL);
+			g_free(filename);
+
+			if (pixbuf != NULL) {
+				/* Scale and insert the image */
+				scale = gdk_pixbuf_scale_simple(pixbuf, 16, 16,
+												GDK_INTERP_BILINEAR);
+				image = gtk_image_new_from_pixbuf(scale);
+
+				g_object_unref(G_OBJECT(pixbuf));
+				g_object_unref(G_OBJECT(scale));
+			}
+			else
+				image = gtk_image_new();
+		}
+		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);
+
+		g_snprintf(buf, sizeof(buf), "%s (%s)",
+				   gaim_account_get_username(account), plugin->info->name);
+
+		/* Create the label. */
+		label = gtk_label_new(buf);
+		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(opt), "gaim_connection", g);
 
@@ -209,6 +275,8 @@
 
 	gtk_option_menu_set_menu(GTK_OPTION_MENU(optmenu), menu);
 	gtk_option_menu_set_history(GTK_OPTION_MENU(optmenu), 0);
+
+	g_object_unref(sg);
 }
 
 static void
--- a/src/gtkconv.c	Sun Jun 15 05:24:57 2003 +0000
+++ b/src/gtkconv.c	Sun Jun 15 05:41:27 2003 +0000
@@ -3677,7 +3677,8 @@
 	focus_gtkconv = GAIM_GTK_CONVERSATION(focus_conv);
 	gtk_widget_grab_focus(focus_gtkconv->entry);
 
-	gaim_gtkconv_update_buddy_icon(conv);
+	if (gaim_conversation_get_type(conv) == GAIM_CONV_IM)
+		gaim_gtkconv_update_buddy_icon(conv);
 
 	if (!new_ui)
 		g_object_unref(gtkconv->tab_cont);
@@ -4432,7 +4433,10 @@
 
 	if (type == GAIM_CONV_UPDATE_ACCOUNT) {
 		gaim_conversation_autoset_title(conv);
-		gaim_gtkconv_update_buddy_icon(conv);
+
+		if (gaim_conversation_get_type(conv) == GAIM_CONV_IM)
+			gaim_gtkconv_update_buddy_icon(conv);
+
 		gaim_gtkconv_update_buttons_by_protocol(conv);
 
 		g_timeout_add(0, (GSourceFunc)update_send_as_selection, win);
@@ -5300,7 +5304,14 @@
 show_buddy_icons_pref_cb(const char *name, GaimPrefType type, gpointer value,
 						 gpointer data)
 {
-	gaim_conversation_foreach(gaim_gtkconv_update_buddy_icon);
+	GList *l;
+
+	for (l = gaim_get_conversations(); l != NULL; l = l->next) {
+		GaimConversation *conv = l->data;
+
+		if (gaim_conversation_get_type(conv) == GAIM_CONV_IM)
+			gaim_conversation_foreach(gaim_gtkconv_update_buddy_icon);
+	}
 }
 
 static void