pidgin/gtkstatusbox.c

branch
cpw.qulogic.gtk3
changeset 32433
f539a2c083b2
parent 32424
be4a642b2d45
parent 31889
96183796df0c
child 32438
dc8991868906
child 33120
f6f1a27ade72
equal deleted inserted replaced
32432:47b61b9e08e6 32433:f539a2c083b2
2235 status_box->buddy_icon = NULL; 2235 status_box->buddy_icon = NULL;
2236 status_box->buddy_icon_hover = NULL; 2236 status_box->buddy_icon_hover = NULL;
2237 2237
2238 if (status_box->buddy_icon_img != NULL) 2238 if (status_box->buddy_icon_img != NULL)
2239 { 2239 {
2240 GdkPixbuf *buf, *scale; 2240 GdkPixbufLoader *loader;
2241 int scale_width, scale_height; 2241 GError *error = NULL;
2242 GdkPixbufLoader *loader = gdk_pixbuf_loader_new(); 2242
2243 loader = gdk_pixbuf_loader_new();
2244
2243 g_signal_connect(G_OBJECT(loader), "size-prepared", G_CALLBACK(pixbuf_size_prepared_cb), NULL); 2245 g_signal_connect(G_OBJECT(loader), "size-prepared", G_CALLBACK(pixbuf_size_prepared_cb), NULL);
2244 gdk_pixbuf_loader_write(loader, purple_imgstore_get_data(status_box->buddy_icon_img), 2246 if (!gdk_pixbuf_loader_write(loader,
2245 purple_imgstore_get_size(status_box->buddy_icon_img), NULL); 2247 purple_imgstore_get_data(status_box->buddy_icon_img),
2246 gdk_pixbuf_loader_close(loader, NULL); 2248 purple_imgstore_get_size(status_box->buddy_icon_img),
2247 buf = gdk_pixbuf_loader_get_pixbuf(loader); 2249 &error) || error)
2248 scale_width = gdk_pixbuf_get_width(buf); 2250 {
2249 scale_height = gdk_pixbuf_get_height(buf); 2251 purple_debug_warning("gtkstatusbox", "gdk_pixbuf_loader_write() "
2250 scale = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, scale_width, scale_height); 2252 "failed with size=%zu: %s\n",
2251 gdk_pixbuf_fill(scale, 0x00000000); 2253 purple_imgstore_get_size(status_box->buddy_icon_img),
2252 gdk_pixbuf_copy_area(buf, 0, 0, scale_width, scale_height, scale, 0, 0); 2254 error ? error->message : "(no error message)");
2253 if (pidgin_gdk_pixbuf_is_opaque(scale)) 2255 if (error)
2254 pidgin_gdk_pixbuf_make_round(scale); 2256 g_error_free(error);
2255 status_box->buddy_icon = scale; 2257 } else if (!gdk_pixbuf_loader_close(loader, &error) || error) {
2258 purple_debug_warning("gtkstatusbox", "gdk_pixbuf_loader_close() "
2259 "failed for image of size %zu: %s\n",
2260 purple_imgstore_get_size(status_box->buddy_icon_img),
2261 error ? error->message : "(no error message)");
2262 if (error)
2263 g_error_free(error);
2264 } else {
2265 GdkPixbuf *buf, *scale;
2266 int scale_width, scale_height;
2267
2268 buf = gdk_pixbuf_loader_get_pixbuf(loader);
2269 scale_width = gdk_pixbuf_get_width(buf);
2270 scale_height = gdk_pixbuf_get_height(buf);
2271 scale = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, scale_width, scale_height);
2272 gdk_pixbuf_fill(scale, 0x00000000);
2273 gdk_pixbuf_copy_area(buf, 0, 0, scale_width, scale_height, scale, 0, 0);
2274 if (pidgin_gdk_pixbuf_is_opaque(scale))
2275 pidgin_gdk_pixbuf_make_round(scale);
2276 status_box->buddy_icon = scale;
2277 }
2278
2256 g_object_unref(loader); 2279 g_object_unref(loader);
2257 } 2280 }
2258 2281
2259 if (status_box->buddy_icon == NULL) 2282 if (status_box->buddy_icon == NULL)
2260 { 2283 {

mercurial