| 381 gtk_widget_show(status_box->icon_box); |
383 gtk_widget_show(status_box->icon_box); |
| 382 |
384 |
| 383 if (status_box->account && |
385 if (status_box->account && |
| 384 !purple_account_get_bool(status_box->account, "use-global-buddyicon", TRUE)) |
386 !purple_account_get_bool(status_box->account, "use-global-buddyicon", TRUE)) |
| 385 { |
387 { |
| 386 char *string = purple_buddy_icons_get_full_path(purple_account_get_buddy_icon(status_box->account)); |
388 PurpleStoredImage *img = purple_buddy_icons_find_account_icon(status_box->account); |
| 387 pidgin_status_box_set_buddy_icon(status_box, string); |
389 pidgin_status_box_set_buddy_icon(status_box, img); |
| 388 g_free(string); |
390 purple_imgstore_unref(img); |
| 389 } |
391 } |
| 390 else |
392 else |
| 391 { |
393 { |
| 392 pidgin_status_box_set_buddy_icon(status_box, purple_prefs_get_path(PIDGIN_PREFS_ROOT "/accounts/buddyicon")); |
394 const char *filename = purple_prefs_get_path(PIDGIN_PREFS_ROOT "/accounts/buddyicon"); |
| |
395 PurpleStoredImage *img = NULL; |
| |
396 |
| |
397 if (filename != NULL) |
| |
398 { |
| |
399 gchar *contents; |
| |
400 gsize size; |
| |
401 if (g_file_get_contents(filename, &contents, &size, NULL)) |
| |
402 { |
| |
403 img = purple_imgstore_add(contents, size, filename); |
| |
404 } |
| |
405 } |
| |
406 |
| |
407 pidgin_status_box_set_buddy_icon(status_box, img); |
| 393 } |
408 } |
| 394 |
409 |
| 395 status_box->hand_cursor = gdk_cursor_new (GDK_HAND2); |
410 status_box->hand_cursor = gdk_cursor_new (GDK_HAND2); |
| 396 status_box->arrow_cursor = gdk_cursor_new (GDK_LEFT_PTR); |
411 status_box->arrow_cursor = gdk_cursor_new (GDK_LEFT_PTR); |
| 397 |
412 |
| 420 |
435 |
| 421 gtk_widget_destroy(statusbox->icon_box); |
436 gtk_widget_destroy(statusbox->icon_box); |
| 422 gdk_cursor_unref(statusbox->hand_cursor); |
437 gdk_cursor_unref(statusbox->hand_cursor); |
| 423 gdk_cursor_unref(statusbox->arrow_cursor); |
438 gdk_cursor_unref(statusbox->arrow_cursor); |
| 424 |
439 |
| |
440 purple_imgstore_unref(statusbox->buddy_icon_img); |
| |
441 |
| 425 g_object_unref(G_OBJECT(statusbox->buddy_icon)); |
442 g_object_unref(G_OBJECT(statusbox->buddy_icon)); |
| 426 g_object_unref(G_OBJECT(statusbox->buddy_icon_hover)); |
443 g_object_unref(G_OBJECT(statusbox->buddy_icon_hover)); |
| 427 |
444 |
| 428 if (statusbox->buddy_icon_sel) |
445 if (statusbox->buddy_icon_sel) |
| 429 gtk_widget_destroy(statusbox->buddy_icon_sel); |
446 gtk_widget_destroy(statusbox->buddy_icon_sel); |
| 430 |
447 |
| 431 if (statusbox->icon_box_menu) |
448 if (statusbox->icon_box_menu) |
| 432 gtk_widget_destroy(statusbox->icon_box_menu); |
449 gtk_widget_destroy(statusbox->icon_box_menu); |
| 433 |
|
| 434 g_free(statusbox->buddy_icon_path); |
|
| 435 |
450 |
| 436 statusbox->icon = NULL; |
451 statusbox->icon = NULL; |
| 437 statusbox->icon_box = NULL; |
452 statusbox->icon_box = NULL; |
| 438 statusbox->icon_box_menu = NULL; |
453 statusbox->icon_box_menu = NULL; |
| 439 statusbox->buddy_icon_path = NULL; |
454 statusbox->buddy_icon_img = NULL; |
| 440 statusbox->buddy_icon = NULL; |
455 statusbox->buddy_icon = NULL; |
| 441 statusbox->buddy_icon_hover = NULL; |
456 statusbox->buddy_icon_hover = NULL; |
| 442 statusbox->hand_cursor = NULL; |
457 statusbox->hand_cursor = NULL; |
| 443 statusbox->arrow_cursor = NULL; |
458 statusbox->arrow_cursor = NULL; |
| 444 } |
459 } |
| 487 purple_prefs_disconnect_by_handle(statusbox); |
502 purple_prefs_disconnect_by_handle(statusbox); |
| 488 |
503 |
| 489 gdk_cursor_unref(statusbox->hand_cursor); |
504 gdk_cursor_unref(statusbox->hand_cursor); |
| 490 gdk_cursor_unref(statusbox->arrow_cursor); |
505 gdk_cursor_unref(statusbox->arrow_cursor); |
| 491 |
506 |
| |
507 purple_imgstore_unref(statusbox->buddy_icon_img); |
| 492 g_object_unref(G_OBJECT(statusbox->buddy_icon)); |
508 g_object_unref(G_OBJECT(statusbox->buddy_icon)); |
| 493 g_object_unref(G_OBJECT(statusbox->buddy_icon_hover)); |
509 g_object_unref(G_OBJECT(statusbox->buddy_icon_hover)); |
| 494 |
510 |
| 495 if (statusbox->buddy_icon_sel) |
511 if (statusbox->buddy_icon_sel) |
| 496 gtk_widget_destroy(statusbox->buddy_icon_sel); |
512 gtk_widget_destroy(statusbox->buddy_icon_sel); |
| 497 |
|
| 498 g_free(statusbox->buddy_icon_path); |
|
| 499 |
513 |
| 500 G_OBJECT_CLASS(parent_class)->finalize(obj); |
514 G_OBJECT_CLASS(parent_class)->finalize(obj); |
| 501 } |
515 } |
| 502 |
516 |
| 503 static GType |
517 static GType |
| 1400 } |
1414 } |
| 1401 |
1415 |
| 1402 static void |
1416 static void |
| 1403 buddy_icon_set_cb(const char *filename, PidginStatusBox *box) |
1417 buddy_icon_set_cb(const char *filename, PidginStatusBox *box) |
| 1404 { |
1418 { |
| |
1419 PurpleStoredImage *img = NULL; |
| 1405 |
1420 |
| 1406 if (box->account) { |
1421 if (box->account) { |
| 1407 PurplePlugin *plug = purple_find_prpl(purple_account_get_protocol_id(box->account)); |
1422 PurplePlugin *plug = purple_find_prpl(purple_account_get_protocol_id(box->account)); |
| 1408 if (plug) { |
1423 if (plug) { |
| 1409 PurplePluginProtocolInfo *prplinfo = PURPLE_PLUGIN_PROTOCOL_INFO(plug); |
1424 PurplePluginProtocolInfo *prplinfo = PURPLE_PLUGIN_PROTOCOL_INFO(plug); |
| 1410 if (prplinfo && prplinfo->icon_spec.format) { |
1425 if (prplinfo && prplinfo->icon_spec.format) { |
| 1411 char *icon = NULL; |
1426 gpointer data = NULL; |
| |
1427 size_t len = 0; |
| 1412 if (filename) |
1428 if (filename) |
| 1413 icon = pidgin_convert_buddy_icon(plug, filename); |
1429 data = pidgin_convert_buddy_icon(plug, filename, &len); |
| |
1430 img = purple_buddy_icons_set_account_icon(box->account, data, len); |
| |
1431 purple_account_set_buddy_icon_path(box->account, filename); |
| |
1432 |
| 1414 purple_account_set_bool(box->account, "use-global-buddyicon", (filename != NULL)); |
1433 purple_account_set_bool(box->account, "use-global-buddyicon", (filename != NULL)); |
| 1415 purple_account_set_ui_string(box->account, PIDGIN_UI, "non-global-buddyicon-cached-path", icon); |
|
| 1416 purple_account_set_buddy_icon_path(box->account, filename); |
|
| 1417 purple_account_set_buddy_icon(box->account, icon); |
|
| 1418 g_free(icon); |
|
| 1419 } |
1434 } |
| 1420 } |
1435 } |
| 1421 } else { |
1436 } else { |
| 1422 GList *accounts; |
1437 GList *accounts; |
| 1423 for (accounts = purple_accounts_get_all(); accounts != NULL; accounts = accounts->next) { |
1438 for (accounts = purple_accounts_get_all(); accounts != NULL; accounts = accounts->next) { |
| 1426 if (plug) { |
1441 if (plug) { |
| 1427 PurplePluginProtocolInfo *prplinfo = PURPLE_PLUGIN_PROTOCOL_INFO(plug); |
1442 PurplePluginProtocolInfo *prplinfo = PURPLE_PLUGIN_PROTOCOL_INFO(plug); |
| 1428 if (prplinfo != NULL && |
1443 if (prplinfo != NULL && |
| 1429 purple_account_get_bool(account, "use-global-buddyicon", TRUE) && |
1444 purple_account_get_bool(account, "use-global-buddyicon", TRUE) && |
| 1430 prplinfo->icon_spec.format) { |
1445 prplinfo->icon_spec.format) { |
| 1431 char *icon = NULL; |
1446 gpointer data = NULL; |
| |
1447 size_t len = 0; |
| 1432 if (filename) |
1448 if (filename) |
| 1433 icon = pidgin_convert_buddy_icon(plug, filename); |
1449 data = pidgin_convert_buddy_icon(plug, filename, &len); |
| 1434 purple_account_set_buddy_icon_path(account, filename); |
1450 img = purple_buddy_icons_set_account_icon(box->account, data, len); |
| 1435 purple_account_set_buddy_icon(account, icon); |
1451 purple_account_set_buddy_icon_path(box->account, filename); |
| 1436 g_free(icon); |
1452 |
| |
1453 purple_account_set_bool(box->account, "use-global-buddyicon", (filename != NULL)); |
| 1437 } |
1454 } |
| 1438 } |
1455 } |
| 1439 } |
1456 } |
| 1440 } |
1457 } |
| 1441 pidgin_status_box_set_buddy_icon(box, filename); |
1458 |
| |
1459 pidgin_status_box_set_buddy_icon(box, img); |
| 1442 } |
1460 } |
| 1443 |
1461 |
| 1444 static void |
1462 static void |
| 1445 remove_buddy_icon_cb(GtkWidget *w, PidginStatusBox *box) |
1463 remove_buddy_icon_cb(GtkWidget *w, PidginStatusBox *box) |
| 1446 { |
1464 { |
| 2008 if (status_box->buddy_icon_hover) |
2026 if (status_box->buddy_icon_hover) |
| 2009 g_object_unref(status_box->buddy_icon_hover); |
2027 g_object_unref(status_box->buddy_icon_hover); |
| 2010 status_box->buddy_icon = NULL; |
2028 status_box->buddy_icon = NULL; |
| 2011 status_box->buddy_icon_hover = NULL; |
2029 status_box->buddy_icon_hover = NULL; |
| 2012 |
2030 |
| 2013 if ((status_box->buddy_icon_path != NULL) && |
2031 if (status_box->buddy_icon_img != NULL) |
| 2014 (*status_box->buddy_icon_path != '\0')) |
2032 { |
| 2015 status_box->buddy_icon = gdk_pixbuf_new_from_file_at_scale(status_box->buddy_icon_path, |
2033 GdkPixbufLoader *loader = gdk_pixbuf_loader_new(); |
| 2016 status_box->icon_size, status_box->icon_size, FALSE, NULL); |
2034 gdk_pixbuf_loader_write(loader, purple_imgstore_get_data(status_box->buddy_icon_img), |
| |
2035 purple_imgstore_get_size(status_box->buddy_icon_img), NULL); |
| |
2036 gdk_pixbuf_loader_close(loader, NULL); |
| |
2037 status_box->buddy_icon = gdk_pixbuf_loader_get_pixbuf(loader); |
| |
2038 } |
| 2017 |
2039 |
| 2018 if (status_box->buddy_icon == NULL) |
2040 if (status_box->buddy_icon == NULL) |
| 2019 { |
2041 { |
| 2020 /* Show a placeholder icon */ |
2042 /* Show a placeholder icon */ |
| 2021 GtkIconSize icon_size = gtk_icon_size_from_name(PIDGIN_ICON_SIZE_TANGO_SMALL); |
2043 GtkIconSize icon_size = gtk_icon_size_from_name(PIDGIN_ICON_SIZE_TANGO_SMALL); |
| 2032 gtk_widget_queue_resize(GTK_WIDGET(status_box)); |
2054 gtk_widget_queue_resize(GTK_WIDGET(status_box)); |
| 2033 } |
2055 } |
| 2034 } |
2056 } |
| 2035 |
2057 |
| 2036 void |
2058 void |
| 2037 pidgin_status_box_set_buddy_icon(PidginStatusBox *status_box, const char *filename) |
2059 pidgin_status_box_set_buddy_icon(PidginStatusBox *status_box, PurpleStoredImage *img) |
| 2038 { |
2060 { |
| 2039 g_free(status_box->buddy_icon_path); |
2061 purple_imgstore_unref(status_box->buddy_icon_img); |
| 2040 status_box->buddy_icon_path = g_strdup(filename); |
2062 status_box->buddy_icon_img = purple_imgstore_ref(img); |
| 2041 |
2063 |
| 2042 pidgin_status_box_redisplay_buddy_icon(status_box); |
2064 pidgin_status_box_redisplay_buddy_icon(status_box); |
| 2043 } |
|
| 2044 |
|
| 2045 const char* |
|
| 2046 pidgin_status_box_get_buddy_icon(PidginStatusBox *box) |
|
| 2047 { |
|
| 2048 return box->buddy_icon_path; |
|
| 2049 } |
2065 } |
| 2050 |
2066 |
| 2051 void |
2067 void |
| 2052 pidgin_status_box_pulse_connecting(PidginStatusBox *status_box) |
2068 pidgin_status_box_pulse_connecting(PidginStatusBox *status_box) |
| 2053 { |
2069 { |