| 405 _("Click to change your buddyicon for all accounts.")); |
404 _("Click to change your buddyicon for all accounts.")); |
| 406 |
405 |
| 407 if (status_box->account && |
406 if (status_box->account && |
| 408 !purple_account_get_bool(status_box->account, "use-global-buddyicon", TRUE)) |
407 !purple_account_get_bool(status_box->account, "use-global-buddyicon", TRUE)) |
| 409 { |
408 { |
| 410 PurpleStoredImage *img = purple_buddy_icons_find_account_icon(status_box->account); |
409 PurpleImage *img = purple_buddy_icons_find_account_icon(status_box->account); |
| 411 pidgin_status_box_set_buddy_icon(status_box, img); |
410 pidgin_status_box_set_buddy_icon(status_box, img); |
| 412 purple_imgstore_unref(img); |
411 g_object_unref(img); |
| 413 } |
412 } |
| 414 else |
413 else |
| 415 { |
414 { |
| 416 const char *filename = purple_prefs_get_path(PIDGIN_PREFS_ROOT "/accounts/buddyicon"); |
415 const char *filename = purple_prefs_get_path(PIDGIN_PREFS_ROOT "/accounts/buddyicon"); |
| 417 PurpleStoredImage *img = NULL; |
416 PurpleImage *img = NULL; |
| 418 |
417 |
| 419 if (filename && *filename) |
418 if (filename && *filename) |
| 420 img = purple_imgstore_new_from_file(filename); |
419 img = purple_image_new_from_file(filename, TRUE); |
| 421 |
420 |
| 422 pidgin_status_box_set_buddy_icon(status_box, img); |
421 pidgin_status_box_set_buddy_icon(status_box, img); |
| 423 if (img) |
422 if (img) |
| 424 /* |
423 g_object_unref(img); |
| 425 * purple_imgstore_new gives us a reference and |
|
| 426 * pidgin_status_box_set_buddy_icon also takes one. |
|
| 427 */ |
|
| 428 purple_imgstore_unref(img); |
|
| 429 } |
424 } |
| 430 |
425 |
| 431 status_box->hand_cursor = gdk_cursor_new (GDK_HAND2); |
426 status_box->hand_cursor = gdk_cursor_new (GDK_HAND2); |
| 432 status_box->arrow_cursor = gdk_cursor_new (GDK_LEFT_PTR); |
427 status_box->arrow_cursor = gdk_cursor_new (GDK_LEFT_PTR); |
| 433 |
428 |
| 462 #else |
457 #else |
| 463 gdk_cursor_unref(statusbox->hand_cursor); |
458 gdk_cursor_unref(statusbox->hand_cursor); |
| 464 gdk_cursor_unref(statusbox->arrow_cursor); |
459 gdk_cursor_unref(statusbox->arrow_cursor); |
| 465 #endif |
460 #endif |
| 466 |
461 |
| 467 purple_imgstore_unref(statusbox->buddy_icon_img); |
462 if (statusbox->buddy_icon_img) |
| |
463 g_object_unref(statusbox->buddy_icon_img); |
| 468 |
464 |
| 469 g_object_unref(G_OBJECT(statusbox->buddy_icon)); |
465 g_object_unref(G_OBJECT(statusbox->buddy_icon)); |
| 470 g_object_unref(G_OBJECT(statusbox->buddy_icon_hover)); |
466 g_object_unref(G_OBJECT(statusbox->buddy_icon_hover)); |
| 471 |
467 |
| 472 if (statusbox->buddy_icon_sel) |
468 if (statusbox->buddy_icon_sel) |
| 1460 gpointer data = NULL; |
1456 gpointer data = NULL; |
| 1461 size_t len = 0; |
1457 size_t len = 0; |
| 1462 if (filename) |
1458 if (filename) |
| 1463 data = pidgin_convert_buddy_icon(plug, filename, &len); |
1459 data = pidgin_convert_buddy_icon(plug, filename, &len); |
| 1464 img = purple_buddy_icons_set_account_icon(box->account, data, len); |
1460 img = purple_buddy_icons_set_account_icon(box->account, data, len); |
| 1465 if (img) |
1461 if (img) { |
| 1466 /* |
1462 /* |
| 1467 * set_account_icon doesn't give us a reference, but we |
1463 * set_account_icon doesn't give us a reference, but we |
| 1468 * unref one below (for the other code path) |
1464 * unref one below (for the other code path) |
| 1469 */ |
1465 */ |
| 1470 purple_imgstore_ref(img); |
1466 g_object_ref(img); |
| |
1467 } |
| 1471 |
1468 |
| 1472 purple_account_set_buddy_icon_path(box->account, filename); |
1469 purple_account_set_buddy_icon_path(box->account, filename); |
| 1473 |
1470 |
| 1474 purple_account_set_bool(box->account, "use-global-buddyicon", (filename != NULL)); |
1471 purple_account_set_bool(box->account, "use-global-buddyicon", (filename != NULL)); |
| 1475 } |
1472 } |
| 1494 } |
1491 } |
| 1495 } |
1492 } |
| 1496 |
1493 |
| 1497 /* Even if no accounts were processed, load the icon that was set. */ |
1494 /* Even if no accounts were processed, load the icon that was set. */ |
| 1498 if (filename != NULL) |
1495 if (filename != NULL) |
| 1499 img = purple_imgstore_new_from_file(filename); |
1496 img = purple_image_new_from_file(filename, TRUE); |
| 1500 } |
1497 } |
| 1501 |
1498 |
| 1502 pidgin_status_box_set_buddy_icon(box, img); |
1499 pidgin_status_box_set_buddy_icon(box, img); |
| 1503 if (img) |
1500 if (img) |
| 1504 purple_imgstore_unref(img); |
1501 g_object_unref(img); |
| 1505 } |
1502 } |
| 1506 |
1503 |
| 1507 static void |
1504 static void |
| 1508 remove_buddy_icon_cb(GtkWidget *w, PidginStatusBox *box) |
1505 remove_buddy_icon_cb(GtkWidget *w, PidginStatusBox *box) |
| 1509 { |
1506 { |
| 2270 |
2267 |
| 2271 loader = gdk_pixbuf_loader_new(); |
2268 loader = gdk_pixbuf_loader_new(); |
| 2272 |
2269 |
| 2273 g_signal_connect(G_OBJECT(loader), "size-prepared", G_CALLBACK(pixbuf_size_prepared_cb), NULL); |
2270 g_signal_connect(G_OBJECT(loader), "size-prepared", G_CALLBACK(pixbuf_size_prepared_cb), NULL); |
| 2274 if (!gdk_pixbuf_loader_write(loader, |
2271 if (!gdk_pixbuf_loader_write(loader, |
| 2275 purple_imgstore_get_data(status_box->buddy_icon_img), |
2272 purple_image_get_data(status_box->buddy_icon_img), |
| 2276 purple_imgstore_get_size(status_box->buddy_icon_img), |
2273 purple_image_get_size(status_box->buddy_icon_img), |
| 2277 &error) || error) |
2274 &error) || error) |
| 2278 { |
2275 { |
| 2279 purple_debug_warning("gtkstatusbox", "gdk_pixbuf_loader_write() " |
2276 purple_debug_warning("gtkstatusbox", |
| 2280 "failed with size=%" G_GSIZE_FORMAT ": %s\n", |
2277 "gdk_pixbuf_loader_write() failed with size=%" |
| 2281 (gsize)purple_imgstore_get_size(status_box->buddy_icon_img), |
2278 G_GSIZE_FORMAT ": %s", purple_image_get_size( |
| 2282 error ? error->message : "(no error message)"); |
2279 status_box->buddy_icon_img), |
| |
2280 error ? error->message : "(no error message)"); |
| 2283 if (error) |
2281 if (error) |
| 2284 g_error_free(error); |
2282 g_error_free(error); |
| 2285 } else if (!gdk_pixbuf_loader_close(loader, &error) || error) { |
2283 } else if (!gdk_pixbuf_loader_close(loader, &error) || error) { |
| 2286 purple_debug_warning("gtkstatusbox", "gdk_pixbuf_loader_close() " |
2284 purple_debug_warning("gtkstatusbox", |
| 2287 "failed for image of size %" G_GSIZE_FORMAT ": %s\n", |
2285 "gdk_pixbuf_loader_close() failed for image of " |
| 2288 (gsize)purple_imgstore_get_size(status_box->buddy_icon_img), |
2286 "size %" G_GSIZE_FORMAT ": %s", |
| 2289 error ? error->message : "(no error message)"); |
2287 purple_image_get_size(status_box->buddy_icon_img), |
| |
2288 error ? error->message : "(no error message)"); |
| 2290 if (error) |
2289 if (error) |
| 2291 g_error_free(error); |
2290 g_error_free(error); |
| 2292 } else { |
2291 } else { |
| 2293 GdkPixbuf *buf, *scale; |
2292 GdkPixbuf *buf, *scale; |
| 2294 int scale_width, scale_height; |
2293 int scale_width, scale_height; |