comparison pidgin/gtkstatusbox.c @ 32335:98ae4b8b592f

propagate from branch 'im.pidgin.pidgin' (head b55fa7e527d663bdb8c0320d6d035488e8446978) to branch 'im.pidgin.pidgin.mxit' (head 62c1402a9d54bdc07737fbefdfeb664eb5f01d81)
author pieter.loubser@mxit.com
date Thu, 11 Aug 2011 15:01:34 +0000
parents e2c6e4fc3c84
children 904686722499
comparison
equal deleted inserted replaced
32334:3951afa56940 32335:98ae4b8b592f
2223 status_box->buddy_icon = NULL; 2223 status_box->buddy_icon = NULL;
2224 status_box->buddy_icon_hover = NULL; 2224 status_box->buddy_icon_hover = NULL;
2225 2225
2226 if (status_box->buddy_icon_img != NULL) 2226 if (status_box->buddy_icon_img != NULL)
2227 { 2227 {
2228 GdkPixbuf *buf, *scale; 2228 GdkPixbufLoader *loader;
2229 int scale_width, scale_height; 2229 GError *error = NULL;
2230 GdkPixbufLoader *loader = gdk_pixbuf_loader_new(); 2230
2231 loader = gdk_pixbuf_loader_new();
2232
2231 g_signal_connect(G_OBJECT(loader), "size-prepared", G_CALLBACK(pixbuf_size_prepared_cb), NULL); 2233 g_signal_connect(G_OBJECT(loader), "size-prepared", G_CALLBACK(pixbuf_size_prepared_cb), NULL);
2232 gdk_pixbuf_loader_write(loader, purple_imgstore_get_data(status_box->buddy_icon_img), 2234 if (!gdk_pixbuf_loader_write(loader,
2233 purple_imgstore_get_size(status_box->buddy_icon_img), NULL); 2235 purple_imgstore_get_data(status_box->buddy_icon_img),
2234 gdk_pixbuf_loader_close(loader, NULL); 2236 purple_imgstore_get_size(status_box->buddy_icon_img),
2235 buf = gdk_pixbuf_loader_get_pixbuf(loader); 2237 &error) || error)
2236 scale_width = gdk_pixbuf_get_width(buf); 2238 {
2237 scale_height = gdk_pixbuf_get_height(buf); 2239 purple_debug_warning("gtkstatusbox", "gdk_pixbuf_loader_write() "
2238 scale = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, scale_width, scale_height); 2240 "failed with size=%zu: %s\n",
2239 gdk_pixbuf_fill(scale, 0x00000000); 2241 purple_imgstore_get_size(status_box->buddy_icon_img),
2240 gdk_pixbuf_copy_area(buf, 0, 0, scale_width, scale_height, scale, 0, 0); 2242 error ? error->message : "(no error message)");
2241 if (pidgin_gdk_pixbuf_is_opaque(scale)) 2243 if (error)
2242 pidgin_gdk_pixbuf_make_round(scale); 2244 g_error_free(error);
2243 status_box->buddy_icon = scale; 2245 } else if (!gdk_pixbuf_loader_close(loader, &error) || error) {
2246 purple_debug_warning("gtkstatusbox", "gdk_pixbuf_loader_close() "
2247 "failed for image of size %zu: %s\n",
2248 purple_imgstore_get_size(status_box->buddy_icon_img),
2249 error ? error->message : "(no error message)");
2250 if (error)
2251 g_error_free(error);
2252 } else {
2253 GdkPixbuf *buf, *scale;
2254 int scale_width, scale_height;
2255
2256 buf = gdk_pixbuf_loader_get_pixbuf(loader);
2257 scale_width = gdk_pixbuf_get_width(buf);
2258 scale_height = gdk_pixbuf_get_height(buf);
2259 scale = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, scale_width, scale_height);
2260 gdk_pixbuf_fill(scale, 0x00000000);
2261 gdk_pixbuf_copy_area(buf, 0, 0, scale_width, scale_height, scale, 0, 0);
2262 if (pidgin_gdk_pixbuf_is_opaque(scale))
2263 pidgin_gdk_pixbuf_make_round(scale);
2264 status_box->buddy_icon = scale;
2265 }
2266
2244 g_object_unref(loader); 2267 g_object_unref(loader);
2245 } 2268 }
2246 2269
2247 if (status_box->buddy_icon == NULL) 2270 if (status_box->buddy_icon == NULL)
2248 { 2271 {