| 2573 int height; |
2573 int height; |
| 2574 }; |
2574 }; |
| 2575 |
2575 |
| 2576 static struct tooltip_data * create_tip_for_node(PurpleBlistNode *node, gboolean full) |
2576 static struct tooltip_data * create_tip_for_node(PurpleBlistNode *node, gboolean full) |
| 2577 { |
2577 { |
| 2578 char *tooltip_text = NULL; |
|
| 2579 struct tooltip_data *td = g_new0(struct tooltip_data, 1); |
2578 struct tooltip_data *td = g_new0(struct tooltip_data, 1); |
| 2580 PurpleAccount *account = NULL; |
2579 PurpleAccount *account = NULL; |
| 2581 char *tmp, *node_name; |
2580 char *tmp = NULL, *node_name = NULL, *tooltip_text = NULL; |
| 2582 |
2581 |
| 2583 if(PURPLE_BLIST_NODE_IS_BUDDY(node)) { |
2582 if (PURPLE_BLIST_NODE_IS_BUDDY(node)) { |
| 2584 account = ((PurpleBuddy*)(node))->account; |
2583 account = ((PurpleBuddy*)(node))->account; |
| 2585 } else if(PURPLE_BLIST_NODE_IS_CHAT(node)) { |
2584 } else if (PURPLE_BLIST_NODE_IS_CHAT(node)) { |
| 2586 account = ((PurpleChat*)(node))->account; |
2585 account = ((PurpleChat*)(node))->account; |
| 2587 } |
2586 } |
| 2588 |
2587 |
| 2589 td->status_icon = pidgin_blist_get_status_icon(node, PIDGIN_STATUS_ICON_LARGE); |
2588 td->status_icon = pidgin_blist_get_status_icon(node, PIDGIN_STATUS_ICON_LARGE); |
| 2590 td->avatar = pidgin_blist_get_buddy_icon(node, !full, FALSE); |
2589 td->avatar = pidgin_blist_get_buddy_icon(node, !full, FALSE); |
| 2591 td->prpl_icon = pidgin_create_prpl_icon(account, PIDGIN_PRPL_ICON_SMALL); |
2590 if (account != NULL) { |
| |
2591 td->prpl_icon = pidgin_create_prpl_icon(account, PIDGIN_PRPL_ICON_SMALL); |
| |
2592 } |
| 2592 tooltip_text = pidgin_get_tooltip_text(node, full); |
2593 tooltip_text = pidgin_get_tooltip_text(node, full); |
| 2593 td->layout = gtk_widget_create_pango_layout(gtkblist->tipwindow, NULL); |
2594 td->layout = gtk_widget_create_pango_layout(gtkblist->tipwindow, NULL); |
| 2594 td->name_layout = gtk_widget_create_pango_layout(gtkblist->tipwindow, NULL); |
2595 td->name_layout = gtk_widget_create_pango_layout(gtkblist->tipwindow, NULL); |
| 2595 |
2596 |
| 2596 if (PURPLE_BLIST_NODE_IS_BUDDY(node)) |
2597 if (PURPLE_BLIST_NODE_IS_BUDDY(node)) { |
| 2597 tmp = g_markup_escape_text(purple_buddy_get_name((PurpleBuddy*)node), -1); |
2598 tmp = g_markup_escape_text(purple_buddy_get_name((PurpleBuddy*)node), -1); |
| 2598 else |
2599 } else if (PURPLE_BLIST_NODE_IS_CHAT(node)) { |
| 2599 tmp = g_markup_escape_text(purple_chat_get_name((PurpleChat*)node), -1); |
2600 tmp = g_markup_escape_text(purple_chat_get_name((PurpleChat*)node), -1); |
| |
2601 } else if (PURPLE_BLIST_NODE_IS_GROUP(node)) { |
| |
2602 tmp = g_markup_escape_text(purple_group_get_name((PurpleGroup*)node), -1); |
| |
2603 } else { |
| |
2604 /* I don't believe this can happen currently, I think |
| |
2605 * everything that calls this function checks for one of the |
| |
2606 * above node types first. */ |
| |
2607 tmp = g_strdup(_("Unknown node type")); |
| |
2608 } |
| 2600 node_name = g_strdup_printf("<span size='x-large' weight='bold'>%s</span>", tmp); |
2609 node_name = g_strdup_printf("<span size='x-large' weight='bold'>%s</span>", tmp); |
| 2601 g_free(tmp); |
2610 g_free(tmp); |
| 2602 |
2611 |
| 2603 pango_layout_set_markup(td->layout, tooltip_text, -1); |
2612 pango_layout_set_markup(td->layout, tooltip_text, -1); |
| 2604 pango_layout_set_wrap(td->layout, PANGO_WRAP_WORD); |
2613 pango_layout_set_wrap(td->layout, PANGO_WRAP_WORD); |
| 2685 max_width - (td->avatar_width+ TOOLTIP_BORDER)-1, |
2694 max_width - (td->avatar_width+ TOOLTIP_BORDER)-1, |
| 2686 current_height-1,td->avatar_width+2, td->avatar_height+2); |
2695 current_height-1,td->avatar_width+2, td->avatar_height+2); |
| 2687 } |
2696 } |
| 2688 |
2697 |
| 2689 #if GTK_CHECK_VERSION(2,2,0) |
2698 #if GTK_CHECK_VERSION(2,2,0) |
| 2690 if (dir == GTK_TEXT_DIR_RTL) |
2699 if (td->status_icon) { |
| 2691 gdk_draw_pixbuf(GDK_DRAWABLE(gtkblist->tipwindow->window), NULL, td->status_icon, |
2700 if (dir == GTK_TEXT_DIR_RTL) |
| 2692 0, 0, max_width - TOOLTIP_BORDER - STATUS_SIZE, current_height, -1, -1, GDK_RGB_DITHER_NONE, 0, 0); |
2701 gdk_draw_pixbuf(GDK_DRAWABLE(gtkblist->tipwindow->window), NULL, td->status_icon, |
| 2693 else |
2702 0, 0, max_width - TOOLTIP_BORDER - STATUS_SIZE, current_height, -1, -1, GDK_RGB_DITHER_NONE, 0, 0); |
| 2694 gdk_draw_pixbuf(GDK_DRAWABLE(gtkblist->tipwindow->window), NULL, td->status_icon, |
2703 else |
| 2695 0, 0, TOOLTIP_BORDER, current_height, -1 , -1, GDK_RGB_DITHER_NONE, 0, 0); |
2704 gdk_draw_pixbuf(GDK_DRAWABLE(gtkblist->tipwindow->window), NULL, td->status_icon, |
| 2696 if(td->avatar) |
2705 0, 0, TOOLTIP_BORDER, current_height, -1 , -1, GDK_RGB_DITHER_NONE, 0, 0); |
| 2697 { |
2706 } |
| |
2707 if(td->avatar) { |
| 2698 if (dir == GTK_TEXT_DIR_RTL) |
2708 if (dir == GTK_TEXT_DIR_RTL) |
| 2699 gdk_draw_pixbuf(GDK_DRAWABLE(gtkblist->tipwindow->window), NULL, |
2709 gdk_draw_pixbuf(GDK_DRAWABLE(gtkblist->tipwindow->window), NULL, |
| 2700 td->avatar, 0, 0, TOOLTIP_BORDER, current_height, -1, -1, GDK_RGB_DITHER_NONE, 0, 0); |
2710 td->avatar, 0, 0, TOOLTIP_BORDER, current_height, -1, -1, GDK_RGB_DITHER_NONE, 0, 0); |
| 2701 else |
2711 else |
| 2702 gdk_draw_pixbuf(GDK_DRAWABLE(gtkblist->tipwindow->window), NULL, |
2712 gdk_draw_pixbuf(GDK_DRAWABLE(gtkblist->tipwindow->window), NULL, |
| 2710 prpl_col, |
2720 prpl_col, |
| 2711 current_height + ((td->name_height / 2) - (PRPL_SIZE / 2)), |
2721 current_height + ((td->name_height / 2) - (PRPL_SIZE / 2)), |
| 2712 -1 , -1, GDK_RGB_DITHER_NONE, 0, 0); |
2722 -1 , -1, GDK_RGB_DITHER_NONE, 0, 0); |
| 2713 |
2723 |
| 2714 #else |
2724 #else |
| 2715 gdk_pixbuf_render_to_drawable(td->status_icon, GDK_DRAWABLE(gtkblist->tipwindow->window), NULL, 0, 0, 12, current_height, -1, -1, GDK_RGB_DITHER_NONE, 0, 0); |
2725 if (td->status_icon) { |
| |
2726 gdk_pixbuf_render_to_drawable(td->status_icon, GDK_DRAWABLE(gtkblist->tipwindow->window), NULL, 0, 0, 12, current_height, -1, -1, GDK_RGB_DITHER_NONE, 0, 0); |
| |
2727 } |
| 2716 if(td->avatar) |
2728 if(td->avatar) |
| 2717 gdk_pixbuf_render_to_drawable(td->avatar, |
2729 gdk_pixbuf_render_to_drawable(td->avatar, |
| 2718 GDK_DRAWABLE(gtkblist->tipwindow->window), NULL, 0, 0, |
2730 GDK_DRAWABLE(gtkblist->tipwindow->window), NULL, 0, 0, |
| 2719 max_width - (td->avatar_width + TOOLTIP_BORDER), |
2731 max_width - (td->avatar_width + TOOLTIP_BORDER), |
| 2720 current_height, -1, -1, GDK_RGB_DITHER_NONE, 0, 0); |
2732 current_height, -1, -1, GDK_RGB_DITHER_NONE, 0, 0); |
| 2776 { |
2788 { |
| 2777 PurpleBlistNode *node = data; |
2789 PurpleBlistNode *node = data; |
| 2778 int width, height; |
2790 int width, height; |
| 2779 |
2791 |
| 2780 gtkblist->tipwindow = widget; |
2792 gtkblist->tipwindow = widget; |
| 2781 if(PURPLE_BLIST_NODE_IS_CHAT(node) || PURPLE_BLIST_NODE_IS_BUDDY(node)) { |
2793 if(PURPLE_BLIST_NODE_IS_CHAT(node) || |
| |
2794 PURPLE_BLIST_NODE_IS_BUDDY(node) || |
| |
2795 PURPLE_BLIST_NODE_IS_GROUP(node)) { |
| 2782 struct tooltip_data *td = create_tip_for_node(node, TRUE); |
2796 struct tooltip_data *td = create_tip_for_node(node, TRUE); |
| 2783 gtkblist->tooltipdata = g_list_append(gtkblist->tooltipdata, td); |
2797 gtkblist->tooltipdata = g_list_append(gtkblist->tooltipdata, td); |
| 2784 width = TOOLTIP_BORDER + STATUS_SIZE + SMALL_SPACE + |
2798 width = TOOLTIP_BORDER + STATUS_SIZE + SMALL_SPACE + |
| 2785 MAX(td->width, td->name_width) + SMALL_SPACE + td->avatar_width + TOOLTIP_BORDER; |
2799 MAX(td->width, td->name_width) + SMALL_SPACE + td->avatar_width + TOOLTIP_BORDER; |
| 2786 height = TOOLTIP_BORDER + MAX(td->height + td->name_height, MAX(STATUS_SIZE, td->avatar_height)) |
2800 height = TOOLTIP_BORDER + MAX(td->height + td->name_height, MAX(STATUS_SIZE, td->avatar_height)) |
| 3269 tmp = purple_notify_user_info_get_text_with_newline(user_info, "\n"); |
3283 tmp = purple_notify_user_info_get_text_with_newline(user_info, "\n"); |
| 3270 g_string_append(str, tmp); |
3284 g_string_append(str, tmp); |
| 3271 g_free(tmp); |
3285 g_free(tmp); |
| 3272 |
3286 |
| 3273 purple_notify_user_info_destroy(user_info); |
3287 purple_notify_user_info_destroy(user_info); |
| 3274 } |
3288 } else if (PURPLE_BLIST_NODE_IS_GROUP(node)) { |
| 3275 |
3289 GSList *accounts; |
| 3276 purple_signal_emit(pidgin_blist_get_handle(), |
3290 PurpleGroup *group = (PurpleGroup*)node; |
| 3277 "drawing-tooltip", node, str, full); |
3291 PurpleNotifyUserInfo *user_info; |
| |
3292 |
| |
3293 user_info = purple_notify_user_info_new(); |
| |
3294 |
| |
3295 /* Total buddies (from online accounts) in group */ |
| |
3296 tmp = g_strdup_printf("%d", |
| |
3297 purple_blist_get_group_size(group, FALSE)); |
| |
3298 purple_notify_user_info_add_pair(user_info, _("Total Buddies"), |
| |
3299 tmp); |
| |
3300 g_free(tmp); |
| |
3301 |
| |
3302 /* Online buddies in group */ |
| |
3303 tmp = g_strdup_printf("%d", |
| |
3304 purple_blist_get_group_online_count(group)); |
| |
3305 purple_notify_user_info_add_pair(user_info, _("Online Buddies"), |
| |
3306 tmp); |
| |
3307 g_free(tmp); |
| |
3308 |
| |
3309 /* Accounts with buddies in group */ |
| |
3310 accounts = purple_group_get_accounts(group); |
| |
3311 for (; accounts != NULL; |
| |
3312 accounts = g_slist_remove_link(accounts, accounts)) { |
| |
3313 PurpleAccount *account = accounts->data; |
| |
3314 purple_notify_user_info_add_pair(user_info, _("Account"), purple_account_get_username(account)); |
| |
3315 } |
| |
3316 |
| |
3317 tmp = purple_notify_user_info_get_text_with_newline(user_info, "\n"); |
| |
3318 g_string_append(str, tmp); |
| |
3319 g_free(tmp); |
| |
3320 |
| |
3321 purple_notify_user_info_destroy(user_info); |
| |
3322 } |
| |
3323 |
| |
3324 purple_signal_emit(pidgin_blist_get_handle(), "drawing-tooltip", |
| |
3325 node, str, full); |
| 3278 |
3326 |
| 3279 return g_string_free(str, FALSE); |
3327 return g_string_free(str, FALSE); |
| 3280 } |
3328 } |
| 3281 |
3329 |
| 3282 static GHashTable *cached_emblems; |
3330 static GHashTable *cached_emblems; |