Mercurial > pidgin.yaz
diff pidgin/gtkblist.c @ 16375:391a79778f89
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
imgstore subsystem to not require IDs for everything.
author | Richard Laager <rlaager@wiktel.com> |
---|---|
date | Tue, 24 Apr 2007 03:57:07 +0000 |
parents | 9a4854d71234 |
children | 72dc611f3257 |
line wrap: on
line diff
--- a/pidgin/gtkblist.c Tue Apr 24 03:56:16 2007 +0000 +++ b/pidgin/gtkblist.c Tue Apr 24 03:57:07 2007 +0000 @@ -2155,7 +2155,7 @@ static GdkPixbuf *pidgin_blist_get_buddy_icon(PurpleBlistNode *node, - gboolean scaled, gboolean greyed, gboolean custom) + gboolean scaled, gboolean greyed) { GdkPixbuf *buf, *ret = NULL; GdkPixbufLoader *loader; @@ -2166,6 +2166,7 @@ PurpleChat *chat = NULL; PurpleAccount *account = NULL; PurplePluginProtocolInfo *prpl_info = NULL; + PurpleStoredImage *custom_img; if(PURPLE_BLIST_NODE_IS_CONTACT(node)) { buddy = purple_contact_get_priority_buddy((PurpleContact*)node); @@ -2190,19 +2191,11 @@ return NULL; #endif - if (custom) { - const char *file = purple_blist_node_get_string((PurpleBlistNode*)purple_buddy_get_contact(buddy), - "custom_buddy_icon"); - if (file && *file) { - char *contents; - GError *err = NULL; - if (!g_file_get_contents(file, &contents, &len, &err)) { - purple_debug_info("custom -icon", "Could not open custom-icon %s for %s\n", - file, purple_buddy_get_name(buddy), err->message); - g_error_free(err); - } else - data = (const guchar*)contents; - } + custom_img = purple_buddy_icons_find_custom_icon(purple_buddy_get_contact(buddy)); + if (custom_img) + { + data = purple_imgstore_get_data(custom_img); + len = purple_imgstore_get_size(custom_img); } if (data == NULL) { @@ -2212,7 +2205,6 @@ return NULL; data = purple_buddy_icon_get_data(icon, &len); } - custom = FALSE; /* We are not using the custom icon */ } if(data == NULL) @@ -2221,13 +2213,14 @@ loader = gdk_pixbuf_loader_new(); gdk_pixbuf_loader_write(loader, data, len, NULL); gdk_pixbuf_loader_close(loader, NULL); + + purple_imgstore_unref(custom_img); + buf = gdk_pixbuf_loader_get_pixbuf(loader); if (buf) g_object_ref(G_OBJECT(buf)); g_object_unref(G_OBJECT(loader)); - if (custom) - g_free((void*)data); if (buf) { int orig_width, orig_height; int scale_width, scale_height; @@ -2335,7 +2328,7 @@ } td->status_icon = pidgin_blist_get_status_icon(node, PIDGIN_STATUS_ICON_LARGE); - td->avatar = pidgin_blist_get_buddy_icon(node, !full, FALSE, TRUE); + td->avatar = pidgin_blist_get_buddy_icon(node, !full, FALSE); td->prpl_icon = pidgin_create_prpl_icon(account, PIDGIN_PRPL_ICON_SMALL); tooltip_text = pidgin_get_tooltip_text(node, full); td->layout = gtk_widget_create_pango_layout(gtkblist->tipwindow, NULL); @@ -4893,7 +4886,7 @@ status = pidgin_blist_get_status_icon((PurpleBlistNode*)buddy, PIDGIN_STATUS_ICON_SMALL); - avatar = pidgin_blist_get_buddy_icon((PurpleBlistNode *)buddy, TRUE, TRUE, TRUE); + avatar = pidgin_blist_get_buddy_icon((PurpleBlistNode *)buddy, TRUE, TRUE); if (!avatar) { g_object_ref(G_OBJECT(gtkblist->empty_avatar)); avatar = gtkblist->empty_avatar; @@ -5078,7 +5071,7 @@ status = pidgin_blist_get_status_icon(node, PIDGIN_STATUS_ICON_SMALL); emblem = pidgin_blist_get_emblem(node); - avatar = pidgin_blist_get_buddy_icon(node, TRUE, FALSE, TRUE); + avatar = pidgin_blist_get_buddy_icon(node, TRUE, FALSE); mark = g_markup_escape_text(purple_chat_get_name(chat), -1);