changeset 5646:48c63ee49961

[gaim-migrate @ 6060] The protocol drop-down menu now has protocol icons. committer: Tailor Script <tailor@pidgin.im>
author Christian Hammond <chipx86@chipx86.com>
date Mon, 02 Jun 2003 03:52:43 +0000
parents a9cd11fd0d6f
children 6e551616d051
files src/gtkutils.c src/plugin.c src/protocols/oscar/oscar.c
diffstat 3 files changed, 37 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/src/gtkutils.c	Sun Jun 01 23:31:46 2003 +0000
+++ b/src/gtkutils.c	Mon Jun 02 03:52:43 2003 +0000
@@ -532,9 +532,14 @@
 	GtkWidget *optmenu;
 	GtkWidget *menu;
 	GtkWidget *item;
+	GtkWidget *image;
+	GdkPixbuf *pixbuf;
+	GdkPixbuf *scale;
 	GList *p;
-	int i;
-	int selected_index = -1;
+	char *filename;
+	const char *proto_name;
+	char buf[256];
+	int i, selected_index = -1;
 
 	optmenu = gtk_option_menu_new();
 	gtk_widget_show(optmenu);
@@ -549,7 +554,28 @@
 		plugin = (GaimPlugin *)p->data;
 		prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(plugin);
 
-		item = gtk_menu_item_new_with_label(plugin->info->name);
+		/* Create the item. */
+		item = gtk_image_menu_item_new_with_label(plugin->info->name);
+
+		/* Load the image. */
+		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));
+			gtk_widget_show(image);
+			gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(item), image);
+		}
 
 		g_object_set_data(G_OBJECT(item), "user_data", user_data);
 
--- a/src/plugin.c	Sun Jun 01 23:31:46 2003 +0000
+++ b/src/plugin.c	Mon Jun 02 03:52:43 2003 +0000
@@ -339,8 +339,11 @@
 			for (l = prpl_info->protocol_options; l != NULL; l = l->next)
 				gaim_account_option_destroy(l->data);
 
-			g_list_free(prpl_info->user_splits);
-			g_list_free(prpl_info->protocol_options);
+			if (prpl_info->user_splits != NULL)
+				g_list_free(prpl_info->user_splits);
+
+			if (prpl_info->protocol_options != NULL)
+				g_list_free(prpl_info->protocol_options);
 		}
 		else if (plugin->info->type == GAIM_PLUGIN_LOADER) {
 			GaimPluginLoaderInfo *loader_info;
--- a/src/protocols/oscar/oscar.c	Sun Jun 01 23:31:46 2003 +0000
+++ b/src/protocols/oscar/oscar.c	Mon Jun 02 03:52:43 2003 +0000
@@ -5258,13 +5258,13 @@
 
 static const char *oscar_list_icon(GaimAccount *a, struct buddy *b) {
 	if (!b || (b && b->name && b->name[0] == '+')) {
-		if (isdigit(a->username[0]))
+		if (a != NULL && isdigit(*gaim_account_get_username(a)))
 			return "icq";
 		else
 			return "aim";
 	}
-				
-	if (isdigit(b->name[0]))
+
+	if (b != NULL && isdigit(b->name[0]))
 		return "icq";
 	return "aim";
 }