Wed, 18 Jul 2012 17:56:49 -0400
Pass the cairo context to the tooltip paint function.
This way, the paint function doesn't need to allocate another one
itself, which should save some (small) resources.
| pidgin/gtkblist.c | file | annotate | diff | comparison | revisions | |
| pidgin/gtkplugin.c | file | annotate | diff | comparison | revisions | |
| pidgin/gtkroomlist.c | file | annotate | diff | comparison | revisions | |
| pidgin/pidgintooltip.c | file | annotate | diff | comparison | revisions | |
| pidgin/pidgintooltip.h | file | annotate | diff | comparison | revisions |
--- a/pidgin/gtkblist.c Wed Jul 18 03:42:42 2012 -0400 +++ b/pidgin/gtkblist.c Wed Jul 18 17:56:49 2012 -0400 @@ -2950,10 +2950,9 @@ } static gboolean -pidgin_blist_paint_tip(GtkWidget *widget, gpointer null) +pidgin_blist_paint_tip(GtkWidget *widget, cairo_t *cr, gpointer null) { GtkStyle *style; - cairo_t *cr; int current_height, max_width; int max_text_width; int max_avatar_width; @@ -2987,7 +2986,6 @@ else prpl_col = TOOLTIP_BORDER + status_size + SMALL_SPACE + max_text_width - PRPL_SIZE; - cr = gdk_cairo_create(gtk_widget_get_window(gtkblist->tipwindow)); current_height = 12; for(l = gtkblist->tooltipdata; l; l = l->next) { @@ -3071,7 +3069,6 @@ current_height += MAX(td->name_height + td->height, td->avatar_height) + td->padding; } - cairo_destroy(cr); return FALSE; }
--- a/pidgin/gtkplugin.c Wed Jul 18 03:42:42 2012 -0400 +++ b/pidgin/gtkplugin.c Wed Jul 18 17:56:49 2012 -0400 @@ -559,14 +559,12 @@ } static gboolean -pidgin_plugins_paint_tooltip(GtkWidget *tipwindow, gpointer data) +pidgin_plugins_paint_tooltip(GtkWidget *tipwindow, cairo_t *cr, gpointer data) { PangoLayout *layout = g_object_get_data(G_OBJECT(tipwindow), "tooltip-plugin"); - cairo_t *cr = gdk_cairo_create(gtk_widget_get_window(tipwindow)); gtk_paint_layout(gtk_widget_get_style(tipwindow), cr, GTK_STATE_NORMAL, FALSE, tipwindow, "tooltip", 6, 6, layout); - cairo_destroy(cr); return TRUE; }
--- a/pidgin/gtkroomlist.c Wed Jul 18 03:42:42 2012 -0400 +++ b/pidgin/gtkroomlist.c Wed Jul 18 17:56:49 2012 -0400 @@ -352,7 +352,7 @@ #define TOOLTIP_BORDER 12 static gboolean -pidgin_roomlist_paint_tooltip(GtkWidget *widget, gpointer user_data) +pidgin_roomlist_paint_tooltip(GtkWidget *widget, cairo_t *cr, gpointer user_data) { PurpleRoomlist *list = user_data; PidginRoomlist *grl = purple_roomlist_get_ui_data(list); @@ -360,7 +360,6 @@ int current_height, max_width; int max_text_width; GtkTextDirection dir = gtk_widget_get_direction(GTK_WIDGET(grl->tree)); - cairo_t *cr = gdk_cairo_create(gtk_widget_get_window(grl->tipwindow)); style = gtk_widget_get_style(grl->tipwindow); @@ -390,7 +389,6 @@ current_height + grl->tip_name_height, grl->tip_layout); } - cairo_destroy(cr); return FALSE; }
--- a/pidgin/pidgintooltip.c Wed Jul 18 03:42:42 2012 -0400 +++ b/pidgin/pidgintooltip.c Wed Jul 18 17:56:49 2012 -0400 @@ -111,7 +111,7 @@ gtk_paint_flat_box(gtk_widget_get_style(widget), cr, GTK_STATE_NORMAL, GTK_SHADOW_OUT, widget, "tooltip", 0, 0, allocation.width, allocation.height); - pidgin_tooltip.paint_tooltip(widget, data); + pidgin_tooltip.paint_tooltip(widget, cr, data); } return FALSE; }
--- a/pidgin/pidgintooltip.h Wed Jul 18 03:42:42 2012 -0400 +++ b/pidgin/pidgintooltip.h Wed Jul 18 17:56:49 2012 -0400 @@ -53,11 +53,13 @@ /** * @param tipwindow The window for the tooltip. + * @param cr The cairo context for drawing. * @param userdata The userdata set during pidgin_tooltip_setup_for_treeview or pidgin_tooltip_show. * * @return @c TRUE if the tooltip was painted correctly, @c FALSE otherwise. */ -typedef gboolean (*PidginTooltipPaint)(GtkWidget *tipwindow, gpointer userdata); +typedef gboolean (*PidginTooltipPaint)(GtkWidget *tipwindow, cairo_t *cr, + gpointer userdata); G_BEGIN_DECLS