iconhelper: Implement snapshot

This commit is contained in:
Benjamin Otte 2016-12-15 05:58:22 +01:00
parent d9619abb11
commit 3ba5c70028

View File

@ -131,8 +131,8 @@ gtk_icon_helper_get_preferred_size (GtkCssGadget *gadget,
} }
static gboolean static gboolean
gtk_icon_helper_draw (GtkCssGadget *gadget, gtk_icon_helper_real_snapshot (GtkCssGadget *gadget,
cairo_t *cr, GtkSnapshot *snapshot,
int x, int x,
int y, int y,
int width, int width,
@ -142,10 +142,13 @@ gtk_icon_helper_draw (GtkCssGadget *gadget,
int icon_width, icon_height; int icon_width, icon_height;
_gtk_icon_helper_get_size (self, &icon_width, &icon_height); _gtk_icon_helper_get_size (self, &icon_width, &icon_height);
_gtk_icon_helper_draw (self, gtk_snapshot_translate_2d (snapshot,
cr,
x + (width - icon_width) / 2, x + (width - icon_width) / 2,
y + (height - icon_height) / 2); y + (height - icon_height) / 2);
gtk_icon_helper_snapshot (self, snapshot);
gtk_snapshot_translate_2d (snapshot,
- (x + (width - icon_width) / 2),
- (y + (height - icon_height) / 2));
return FALSE; return FALSE;
} }
@ -196,7 +199,7 @@ gtk_icon_helper_class_init (GtkIconHelperClass *klass)
GObjectClass *object_class = G_OBJECT_CLASS (klass); GObjectClass *object_class = G_OBJECT_CLASS (klass);
gadget_class->get_preferred_size = gtk_icon_helper_get_preferred_size; gadget_class->get_preferred_size = gtk_icon_helper_get_preferred_size;
gadget_class->draw = gtk_icon_helper_draw; gadget_class->snapshot = gtk_icon_helper_real_snapshot;
gadget_class->style_changed = gtk_icon_helper_style_changed; gadget_class->style_changed = gtk_icon_helper_style_changed;
object_class->constructed = gtk_icon_helper_constructed; object_class->constructed = gtk_icon_helper_constructed;