summaryrefslogtreecommitdiff
path: root/gtk/gtkbuiltinicon.c
diff options
context:
space:
mode:
authorBenjamin Otte <otte@redhat.com>2016-11-16 20:51:53 +0100
committerBenjamin Otte <otte@redhat.com>2016-11-16 20:51:53 +0100
commit6d9725f7fdc97bbb5c04a22fb3f664bda686f048 (patch)
tree6136f438a45980687705e66150e2c27b954995ff /gtk/gtkbuiltinicon.c
parentc22a9a03f91d47dd729eee40990adee67134a688 (diff)
downloadgtk+-6d9725f7fdc97bbb5c04a22fb3f664bda686f048.tar.gz
snapshot: Add infrastructure to snapshot CSS images
Use this infrastructure to render builtin images. Which means from now on, GtkCheckbutton, GtkSpinner and a few others use snapshots.
Diffstat (limited to 'gtk/gtkbuiltinicon.c')
-rw-r--r--gtk/gtkbuiltinicon.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/gtk/gtkbuiltinicon.c b/gtk/gtkbuiltinicon.c
index ab294afc22..547fc35a2a 100644
--- a/gtk/gtkbuiltinicon.c
+++ b/gtk/gtkbuiltinicon.c
@@ -145,6 +145,26 @@ gtk_builtin_icon_draw (GtkCssGadget *gadget,
return FALSE;
}
+static gboolean
+gtk_builtin_icon_snapshot (GtkCssGadget *gadget,
+ GtkSnapshot *snapshot,
+ int x,
+ int y,
+ int width,
+ int height)
+{
+ GtkBuiltinIconPrivate *priv = gtk_builtin_icon_get_instance_private (GTK_BUILTIN_ICON (gadget));
+
+ gtk_snapshot_translate_2d (snapshot, x, y);
+ gtk_css_style_snapshot_icon (gtk_css_gadget_get_style (gadget),
+ snapshot,
+ width, height,
+ priv->image_type);
+ gtk_snapshot_translate_2d (snapshot, -x, -y);
+
+ return FALSE;
+}
+
static void
gtk_builtin_icon_style_changed (GtkCssGadget *gadget,
GtkCssStyleChange *change)
@@ -165,6 +185,7 @@ gtk_builtin_icon_class_init (GtkBuiltinIconClass *klass)
gadget_class->get_preferred_size = gtk_builtin_icon_get_preferred_size;
gadget_class->allocate = gtk_builtin_icon_allocate;
gadget_class->draw = gtk_builtin_icon_draw;
+ gadget_class->snapshot = gtk_builtin_icon_snapshot;
gadget_class->style_changed = gtk_builtin_icon_style_changed;
}