changeset 15431:2067ab51e9dc

merge of '53f08d189b9760ce37803245e4885502527b6025' and '65fe446d073e9f60ecdad1ecabbdfa887753d87a'
author Nathan Walp <nwalp@pidgin.im>
date Sat, 27 Jan 2007 02:06:37 +0000
parents 61d3c3b70e13 (current diff) 07f3ed5adb42 (diff)
children 8a7709e2ed9f
files
diffstat 1 files changed, 44 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/pidgin/gtkblist.c	Sat Jan 27 01:43:28 2007 +0000
+++ b/pidgin/gtkblist.c	Sat Jan 27 02:06:37 2007 +0000
@@ -2059,16 +2059,29 @@
 	GaimBuddyIcon *icon;
 	const guchar *data = NULL;
 	gsize len;
-	GaimBuddy *buddy = (GaimBuddy *)node;
+	GaimBuddy *buddy = NULL;
+	GaimChat *chat = NULL;
+	GaimAccount *account = NULL;
+	GaimPluginProtocolInfo *prpl_info = NULL;
 
 	if(GAIM_BLIST_NODE_IS_CONTACT(node)) {
 		buddy = gaim_contact_get_priority_buddy((GaimContact*)node);
 	} else if(GAIM_BLIST_NODE_IS_BUDDY(node)) {
 		buddy = (GaimBuddy*)node;
+	} else if(GAIM_BLIST_NODE_IS_CHAT(node)) {
+		chat = (GaimChat*)node;
 	} else {
 		return NULL;
 	}
 
+	if(buddy != NULL)
+		account = gaim_buddy_get_account(buddy);
+	else if(chat != NULL)
+		account = chat->account;
+
+	if(account && account->gc)
+		prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(account->gc->prpl);
+
 #if 0
 	if (!gaim_prefs_get_bool("/gaim/gtk/blist/show_buddy_icons"))
 		return NULL;
@@ -2090,13 +2103,33 @@
 	}
 
 	if (data == NULL) {
-		if (!(icon = gaim_buddy_get_icon(buddy)))
-			if (!(icon = gaim_buddy_icons_find(buddy->account, buddy->name))) /* Not sure I like this...*/
-				return NULL;
-		data = gaim_buddy_icon_get_data(icon, &len);
+		if(buddy != NULL) {
+			if (!(icon = gaim_buddy_get_icon(buddy)))
+				if (!(icon = gaim_buddy_icons_find(buddy->account, buddy->name))) /* Not sure I like this...*/
+					return NULL;
+			data = gaim_buddy_icon_get_data(icon, &len);
+		} else if(chat != NULL) {
+			if(prpl_info && prpl_info->list_icon) {
+				char *contents;
+				char *image = g_strdup_printf("%s.png", prpl_info->list_icon(account, NULL));
+				char *filename = g_build_filename(DATADIR, "pixmaps", "pidgin", "status", "32", image, NULL);
+				g_free(image);
+
+				gaim_debug_info("icon", "Using %s as a buddy icon for a chat\n");
+
+				/* we'll exit below with data == NULL if this fails */
+				if(g_file_get_contents(filename, &contents, &len, NULL)) {
+					data = (const guchar*)contents;
+				}
+				g_free(filename);
+			}
+		}
 		custom = FALSE;  /* We are not using the custom icon */
 	}
 
+	if(data == NULL)
+		return NULL;
+
 	loader = gdk_pixbuf_loader_new();
 	gdk_pixbuf_loader_write(loader, data, len, NULL);
 	gdk_pixbuf_loader_close(loader, NULL);
@@ -2108,14 +2141,9 @@
 	if (custom)
 		g_free((void*)data);
 	if (buf) {
-		GaimAccount *account = gaim_buddy_get_account(buddy);
-		GaimPluginProtocolInfo *prpl_info = NULL;
 		int orig_width, orig_height;
 		int scale_width, scale_height;
 
-		if(account && account->gc)
-			prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(account->gc->prpl);
-
 		if (greyed) {
 			GaimPresence *presence = gaim_buddy_get_presence(buddy);
 			if (!GAIM_BUDDY_IS_ONLINE(buddy))
@@ -4842,6 +4870,7 @@
 	if(gaim_account_is_connected(chat->account)) {
 		GtkTreeIter iter;
 		GdkPixbuf *status;
+		GdkPixbuf *avatar;
 		char *mark;
 
 		if(!insert_node(list, node, &iter))
@@ -4850,12 +4879,14 @@
 		status = gaim_gtk_blist_get_status_icon(node,
 				 GAIM_STATUS_ICON_SMALL);
 
+		avatar = gaim_gtk_blist_get_buddy_icon(node, TRUE, FALSE, TRUE);
+
 		mark = g_markup_escape_text(gaim_chat_get_name(chat), -1);
 
 		gtk_tree_store_set(gtkblist->treemodel, &iter,
 				STATUS_ICON_COLUMN, status,
 				STATUS_ICON_VISIBLE_COLUMN, TRUE,
-				BUDDY_ICON_COLUMN, gtkblist->empty_avatar,
+				BUDDY_ICON_COLUMN, avatar ? avatar : gtkblist->empty_avatar,
 				BUDDY_ICON_VISIBLE_COLUMN, TRUE,
 				NAME_COLUMN, mark,
 				-1);
@@ -4863,6 +4894,8 @@
 		g_free(mark);
 		if(status)
 			g_object_unref(status);
+		if(avatar)
+			g_object_unref(avatar);
 	} else {
 		gaim_gtk_blist_hide_node(list, node, TRUE);
 	}