| 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 g_free(contents); |
| |
405 } |
| |
406 } |
| |
407 |
| |
408 pidgin_status_box_set_buddy_icon(status_box, img); |
| 393 } |
409 } |
| 394 |
410 |
| 395 status_box->hand_cursor = gdk_cursor_new (GDK_HAND2); |
411 status_box->hand_cursor = gdk_cursor_new (GDK_HAND2); |
| 396 status_box->arrow_cursor = gdk_cursor_new (GDK_LEFT_PTR); |
412 status_box->arrow_cursor = gdk_cursor_new (GDK_LEFT_PTR); |
| 397 |
413 |
| 420 |
436 |
| 421 gtk_widget_destroy(statusbox->icon_box); |
437 gtk_widget_destroy(statusbox->icon_box); |
| 422 gdk_cursor_unref(statusbox->hand_cursor); |
438 gdk_cursor_unref(statusbox->hand_cursor); |
| 423 gdk_cursor_unref(statusbox->arrow_cursor); |
439 gdk_cursor_unref(statusbox->arrow_cursor); |
| 424 |
440 |
| |
441 purple_imgstore_unref(statusbox->buddy_icon_img); |
| |
442 |
| 425 g_object_unref(G_OBJECT(statusbox->buddy_icon)); |
443 g_object_unref(G_OBJECT(statusbox->buddy_icon)); |
| 426 g_object_unref(G_OBJECT(statusbox->buddy_icon_hover)); |
444 g_object_unref(G_OBJECT(statusbox->buddy_icon_hover)); |
| 427 |
445 |
| 428 if (statusbox->buddy_icon_sel) |
446 if (statusbox->buddy_icon_sel) |
| 429 gtk_widget_destroy(statusbox->buddy_icon_sel); |
447 gtk_widget_destroy(statusbox->buddy_icon_sel); |
| 430 |
448 |
| 431 if (statusbox->icon_box_menu) |
449 if (statusbox->icon_box_menu) |
| 432 gtk_widget_destroy(statusbox->icon_box_menu); |
450 gtk_widget_destroy(statusbox->icon_box_menu); |
| 433 |
|
| 434 g_free(statusbox->buddy_icon_path); |
|
| 435 |
451 |
| 436 statusbox->icon = NULL; |
452 statusbox->icon = NULL; |
| 437 statusbox->icon_box = NULL; |
453 statusbox->icon_box = NULL; |
| 438 statusbox->icon_box_menu = NULL; |
454 statusbox->icon_box_menu = NULL; |
| 439 statusbox->buddy_icon_path = NULL; |
455 statusbox->buddy_icon_img = NULL; |
| 440 statusbox->buddy_icon = NULL; |
456 statusbox->buddy_icon = NULL; |
| 441 statusbox->buddy_icon_hover = NULL; |
457 statusbox->buddy_icon_hover = NULL; |
| 442 statusbox->hand_cursor = NULL; |
458 statusbox->hand_cursor = NULL; |
| 443 statusbox->arrow_cursor = NULL; |
459 statusbox->arrow_cursor = NULL; |
| 444 } |
460 } |
| 487 purple_prefs_disconnect_by_handle(statusbox); |
503 purple_prefs_disconnect_by_handle(statusbox); |
| 488 |
504 |
| 489 gdk_cursor_unref(statusbox->hand_cursor); |
505 gdk_cursor_unref(statusbox->hand_cursor); |
| 490 gdk_cursor_unref(statusbox->arrow_cursor); |
506 gdk_cursor_unref(statusbox->arrow_cursor); |
| 491 |
507 |
| |
508 purple_imgstore_unref(statusbox->buddy_icon_img); |
| 492 g_object_unref(G_OBJECT(statusbox->buddy_icon)); |
509 g_object_unref(G_OBJECT(statusbox->buddy_icon)); |
| 493 g_object_unref(G_OBJECT(statusbox->buddy_icon_hover)); |
510 g_object_unref(G_OBJECT(statusbox->buddy_icon_hover)); |
| 494 |
511 |
| 495 if (statusbox->buddy_icon_sel) |
512 if (statusbox->buddy_icon_sel) |
| 496 gtk_widget_destroy(statusbox->buddy_icon_sel); |
513 gtk_widget_destroy(statusbox->buddy_icon_sel); |
| 497 |
|
| 498 g_free(statusbox->buddy_icon_path); |
|
| 499 |
514 |
| 500 G_OBJECT_CLASS(parent_class)->finalize(obj); |
515 G_OBJECT_CLASS(parent_class)->finalize(obj); |
| 501 } |
516 } |
| 502 |
517 |
| 503 static GType |
518 static GType |
| 1430 } |
1445 } |
| 1431 |
1446 |
| 1432 static void |
1447 static void |
| 1433 buddy_icon_set_cb(const char *filename, PidginStatusBox *box) |
1448 buddy_icon_set_cb(const char *filename, PidginStatusBox *box) |
| 1434 { |
1449 { |
| |
1450 PurpleStoredImage *img = NULL; |
| 1435 |
1451 |
| 1436 if (box->account) { |
1452 if (box->account) { |
| 1437 PurplePlugin *plug = purple_find_prpl(purple_account_get_protocol_id(box->account)); |
1453 PurplePlugin *plug = purple_find_prpl(purple_account_get_protocol_id(box->account)); |
| 1438 if (plug) { |
1454 if (plug) { |
| 1439 PurplePluginProtocolInfo *prplinfo = PURPLE_PLUGIN_PROTOCOL_INFO(plug); |
1455 PurplePluginProtocolInfo *prplinfo = PURPLE_PLUGIN_PROTOCOL_INFO(plug); |
| 1440 if (prplinfo && prplinfo->icon_spec.format) { |
1456 if (prplinfo && prplinfo->icon_spec.format) { |
| 1441 char *icon = NULL; |
1457 gpointer data = NULL; |
| 1442 #if 0 |
1458 size_t len = 0; |
| 1443 if (filename) |
1459 if (filename) |
| 1444 icon = pidgin_convert_buddy_icon(plug, filename); |
1460 data = pidgin_convert_buddy_icon(plug, filename, &len); |
| 1445 #endif |
1461 img = purple_buddy_icons_set_account_icon(box->account, data, len); |
| |
1462 purple_account_set_buddy_icon_path(box->account, filename); |
| |
1463 |
| 1446 purple_account_set_bool(box->account, "use-global-buddyicon", (filename != NULL)); |
1464 purple_account_set_bool(box->account, "use-global-buddyicon", (filename != NULL)); |
| 1447 purple_account_set_ui_string(box->account, PIDGIN_UI, "non-global-buddyicon-cached-path", icon); |
|
| 1448 purple_account_set_buddy_icon_path(box->account, filename); |
|
| 1449 purple_account_set_buddy_icon(box->account, icon); |
|
| 1450 g_free(icon); |
|
| 1451 } |
1465 } |
| 1452 } |
1466 } |
| 1453 } else { |
1467 } else { |
| 1454 GList *accounts; |
1468 GList *accounts; |
| 1455 for (accounts = purple_accounts_get_all(); accounts != NULL; accounts = accounts->next) { |
1469 for (accounts = purple_accounts_get_all(); accounts != NULL; accounts = accounts->next) { |
| 1458 if (plug) { |
1472 if (plug) { |
| 1459 PurplePluginProtocolInfo *prplinfo = PURPLE_PLUGIN_PROTOCOL_INFO(plug); |
1473 PurplePluginProtocolInfo *prplinfo = PURPLE_PLUGIN_PROTOCOL_INFO(plug); |
| 1460 if (prplinfo != NULL && |
1474 if (prplinfo != NULL && |
| 1461 purple_account_get_bool(account, "use-global-buddyicon", TRUE) && |
1475 purple_account_get_bool(account, "use-global-buddyicon", TRUE) && |
| 1462 prplinfo->icon_spec.format) { |
1476 prplinfo->icon_spec.format) { |
| 1463 char *icon = NULL; |
1477 gpointer data = NULL; |
| 1464 #if 0 |
1478 size_t len = 0; |
| 1465 if (filename) |
1479 if (filename) |
| 1466 icon = pidgin_convert_buddy_icon(plug, filename); |
1480 data = pidgin_convert_buddy_icon(plug, filename, &len); |
| 1467 #endif |
1481 img = purple_buddy_icons_set_account_icon(box->account, data, len); |
| 1468 purple_account_set_buddy_icon_path(account, filename); |
1482 purple_account_set_buddy_icon_path(box->account, filename); |
| 1469 purple_account_set_buddy_icon(account, icon); |
1483 |
| 1470 g_free(icon); |
1484 purple_account_set_bool(box->account, "use-global-buddyicon", (filename != NULL)); |
| 1471 } |
1485 } |
| 1472 } |
1486 } |
| 1473 } |
1487 } |
| 1474 } |
1488 } |
| 1475 pidgin_status_box_set_buddy_icon(box, filename); |
1489 |
| |
1490 pidgin_status_box_set_buddy_icon(box, img); |
| 1476 } |
1491 } |
| 1477 |
1492 |
| 1478 static void |
1493 static void |
| 1479 remove_buddy_icon_cb(GtkWidget *w, PidginStatusBox *box) |
1494 remove_buddy_icon_cb(GtkWidget *w, PidginStatusBox *box) |
| 1480 { |
1495 { |
| 2042 if (status_box->buddy_icon_hover) |
2057 if (status_box->buddy_icon_hover) |
| 2043 g_object_unref(status_box->buddy_icon_hover); |
2058 g_object_unref(status_box->buddy_icon_hover); |
| 2044 status_box->buddy_icon = NULL; |
2059 status_box->buddy_icon = NULL; |
| 2045 status_box->buddy_icon_hover = NULL; |
2060 status_box->buddy_icon_hover = NULL; |
| 2046 |
2061 |
| 2047 if ((status_box->buddy_icon_path != NULL) && |
2062 if (status_box->buddy_icon_img != NULL) |
| 2048 (*status_box->buddy_icon_path != '\0')) |
2063 { |
| 2049 status_box->buddy_icon = gdk_pixbuf_new_from_file_at_scale(status_box->buddy_icon_path, |
2064 GdkPixbufLoader *loader = gdk_pixbuf_loader_new(); |
| 2050 status_box->icon_size, status_box->icon_size, FALSE, NULL); |
2065 gdk_pixbuf_loader_write(loader, purple_imgstore_get_data(status_box->buddy_icon_img), |
| |
2066 purple_imgstore_get_size(status_box->buddy_icon_img), NULL); |
| |
2067 gdk_pixbuf_loader_close(loader, NULL); |
| |
2068 status_box->buddy_icon = gdk_pixbuf_loader_get_pixbuf(loader); |
| |
2069 } |
| 2051 |
2070 |
| 2052 if (status_box->buddy_icon == NULL) |
2071 if (status_box->buddy_icon == NULL) |
| 2053 { |
2072 { |
| 2054 /* Show a placeholder icon */ |
2073 /* Show a placeholder icon */ |
| 2055 GtkIconSize icon_size = gtk_icon_size_from_name(PIDGIN_ICON_SIZE_TANGO_SMALL); |
2074 GtkIconSize icon_size = gtk_icon_size_from_name(PIDGIN_ICON_SIZE_TANGO_SMALL); |
| 2066 gtk_widget_queue_resize(GTK_WIDGET(status_box)); |
2085 gtk_widget_queue_resize(GTK_WIDGET(status_box)); |
| 2067 } |
2086 } |
| 2068 } |
2087 } |
| 2069 |
2088 |
| 2070 void |
2089 void |
| 2071 pidgin_status_box_set_buddy_icon(PidginStatusBox *status_box, const char *filename) |
2090 pidgin_status_box_set_buddy_icon(PidginStatusBox *status_box, PurpleStoredImage *img) |
| 2072 { |
2091 { |
| 2073 g_free(status_box->buddy_icon_path); |
2092 purple_imgstore_unref(status_box->buddy_icon_img); |
| 2074 status_box->buddy_icon_path = g_strdup(filename); |
2093 status_box->buddy_icon_img = purple_imgstore_ref(img); |
| 2075 |
2094 |
| 2076 pidgin_status_box_redisplay_buddy_icon(status_box); |
2095 pidgin_status_box_redisplay_buddy_icon(status_box); |
| 2077 } |
|
| 2078 |
|
| 2079 const char* |
|
| 2080 pidgin_status_box_get_buddy_icon(PidginStatusBox *box) |
|
| 2081 { |
|
| 2082 return box->buddy_icon_path; |
|
| 2083 } |
2096 } |
| 2084 |
2097 |
| 2085 void |
2098 void |
| 2086 pidgin_status_box_pulse_connecting(PidginStatusBox *status_box) |
2099 pidgin_status_box_pulse_connecting(PidginStatusBox *status_box) |
| 2087 { |
2100 { |