comparison pidgin/gtkblist.c @ 32691:e71b9033d9f5

Cairo-ify buddy list tooltips.
author Elliott Sales de Andrade <qulogic@pidgin.im>
date Sun, 09 Oct 2011 05:03:55 +0000
parents 3538e783b98c
children 763d65f3f758
comparison
equal deleted inserted replaced
32690:650d40e86c10 32691:e71b9033d9f5
2938 2938
2939 static gboolean 2939 static gboolean
2940 pidgin_blist_paint_tip(GtkWidget *widget, gpointer null) 2940 pidgin_blist_paint_tip(GtkWidget *widget, gpointer null)
2941 { 2941 {
2942 GtkStyle *style; 2942 GtkStyle *style;
2943 cairo_t *cr;
2943 int current_height, max_width; 2944 int current_height, max_width;
2944 int max_text_width; 2945 int max_text_width;
2945 int max_avatar_width; 2946 int max_avatar_width;
2946 GList *l; 2947 GList *l;
2947 int prpl_col = 0; 2948 int prpl_col = 0;
2971 if (dir == GTK_TEXT_DIR_RTL) 2972 if (dir == GTK_TEXT_DIR_RTL)
2972 prpl_col = TOOLTIP_BORDER + max_avatar_width + SMALL_SPACE; 2973 prpl_col = TOOLTIP_BORDER + max_avatar_width + SMALL_SPACE;
2973 else 2974 else
2974 prpl_col = TOOLTIP_BORDER + status_size + SMALL_SPACE + max_text_width - PRPL_SIZE; 2975 prpl_col = TOOLTIP_BORDER + status_size + SMALL_SPACE + max_text_width - PRPL_SIZE;
2975 2976
2977 cr = gdk_cairo_create(GDK_DRAWABLE(gtk_widget_get_window(gtkblist->tipwindow)));
2976 current_height = 12; 2978 current_height = 12;
2977 for(l = gtkblist->tooltipdata; l; l = l->next) 2979 for(l = gtkblist->tooltipdata; l; l = l->next)
2978 { 2980 {
2979 struct tooltip_data *td = l->data; 2981 struct tooltip_data *td = l->data;
2980 2982
2990 max_width - (td->avatar_width+ TOOLTIP_BORDER)-1, 2992 max_width - (td->avatar_width+ TOOLTIP_BORDER)-1,
2991 current_height-1,td->avatar_width+2, td->avatar_height+2); 2993 current_height-1,td->avatar_width+2, td->avatar_height+2);
2992 } 2994 }
2993 2995
2994 if (td->status_icon) { 2996 if (td->status_icon) {
2995 if (dir == GTK_TEXT_DIR_RTL) 2997 if (dir == GTK_TEXT_DIR_RTL) {
2996 gdk_draw_pixbuf(GDK_DRAWABLE(gtkblist->tipwindow->window), NULL, td->status_icon, 2998 gdk_cairo_set_source_pixbuf(cr, td->status_icon,
2997 0, 0, max_width - TOOLTIP_BORDER - status_size, current_height, -1, -1, GDK_RGB_DITHER_NONE, 0, 0); 2999 max_width - TOOLTIP_BORDER - status_size,
2998 else 3000 current_height);
2999 gdk_draw_pixbuf(GDK_DRAWABLE(gtkblist->tipwindow->window), NULL, td->status_icon, 3001 cairo_paint(cr);
3000 0, 0, TOOLTIP_BORDER, current_height, -1 , -1, GDK_RGB_DITHER_NONE, 0, 0); 3002 } else {
3003 gdk_cairo_set_source_pixbuf(cr, td->status_icon,
3004 TOOLTIP_BORDER, current_height);
3005 cairo_paint(cr);
3006 }
3001 } 3007 }
3002 3008
3003 if(td->avatar) { 3009 if(td->avatar) {
3004 if (dir == GTK_TEXT_DIR_RTL) 3010 if (dir == GTK_TEXT_DIR_RTL) {
3005 gdk_draw_pixbuf(GDK_DRAWABLE(gtkblist->tipwindow->window), NULL, 3011 gdk_cairo_set_source_pixbuf(cr, td->avatar,
3006 td->avatar, 0, 0, TOOLTIP_BORDER, current_height, -1, -1, GDK_RGB_DITHER_NONE, 0, 0); 3012 TOOLTIP_BORDER, current_height);
3007 else 3013 cairo_paint(cr);
3008 gdk_draw_pixbuf(GDK_DRAWABLE(gtkblist->tipwindow->window), NULL, 3014 } else {
3009 td->avatar, 0, 0, max_width - (td->avatar_width + TOOLTIP_BORDER), 3015 gdk_cairo_set_source_pixbuf(cr, td->avatar,
3010 current_height, -1 , -1, GDK_RGB_DITHER_NONE, 0, 0); 3016 max_width - (td->avatar_width + TOOLTIP_BORDER),
3011 } 3017 current_height);
3012 3018 cairo_paint(cr);
3013 if (!td->avatar_is_prpl_icon && td->prpl_icon) 3019 }
3014 gdk_draw_pixbuf(GDK_DRAWABLE(gtkblist->tipwindow->window), NULL, td->prpl_icon, 3020 }
3015 0, 0, 3021
3016 prpl_col, 3022 if (!td->avatar_is_prpl_icon && td->prpl_icon) {
3017 current_height + ((td->name_height / 2) - (PRPL_SIZE / 2)), 3023 gdk_cairo_set_source_pixbuf(cr, td->prpl_icon, prpl_col,
3018 -1 , -1, GDK_RGB_DITHER_NONE, 0, 0); 3024 current_height +
3025 (td->name_height - PRPL_SIZE) / 2);
3026 cairo_paint(cr);
3027 }
3019 3028
3020 if (td->name_layout) { 3029 if (td->name_layout) {
3021 if (dir == GTK_TEXT_DIR_RTL) { 3030 if (dir == GTK_TEXT_DIR_RTL) {
3022 gtk_paint_layout(style, gtkblist->tipwindow->window, GTK_STATE_NORMAL, FALSE, 3031 gtk_paint_layout(style, gtkblist->tipwindow->window, GTK_STATE_NORMAL, FALSE,
3023 NULL, gtkblist->tipwindow, "tooltip", 3032 NULL, gtkblist->tipwindow, "tooltip",
3044 } 3053 }
3045 } 3054 }
3046 3055
3047 current_height += MAX(td->name_height + td->height, td->avatar_height) + td->padding; 3056 current_height += MAX(td->name_height + td->height, td->avatar_height) + td->padding;
3048 } 3057 }
3058
3059 cairo_destroy(cr);
3049 return FALSE; 3060 return FALSE;
3050 } 3061 }
3051 3062
3052 static void 3063 static void
3053 pidgin_blist_destroy_tooltip_data(void) 3064 pidgin_blist_destroy_tooltip_data(void)