summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Otte <otte@redhat.com>2018-04-02 08:04:39 +0200
committerBenjamin Otte <otte@redhat.com>2018-04-05 14:56:39 +0200
commitf974b4850351acb277b6f44ef78c49ee2b7c223b (patch)
tree07a831d1ef5c52e45df5281e19a1e4fc6b9a497b
parentc74854fe49841b478ce32bc064aa07de82bb9abb (diff)
downloadgtk+-f974b4850351acb277b6f44ef78c49ee2b7c223b.tar.gz
widgetpaintable: Implement get_current_image()
Now that snapshot and empty paintables exist, this is rather trivial.
-rw-r--r--gtk/gtkwidgetpaintable.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/gtk/gtkwidgetpaintable.c b/gtk/gtkwidgetpaintable.c
index 948beb1b23..4ed58a0465 100644
--- a/gtk/gtkwidgetpaintable.c
+++ b/gtk/gtkwidgetpaintable.c
@@ -125,13 +125,22 @@ static GdkPaintable *
gtk_widget_paintable_paintable_get_current_image (GdkPaintable *paintable)
{
GtkWidgetPaintable *self = GTK_WIDGET_PAINTABLE (paintable);
+ GtkSnapshot *snapshot;
+ int width, height;
self->contents_invalid = FALSE;
self->size_invalid = FALSE;
- g_warning ("FIXME: Implement once we can create paintables from render nodes");
+ width = gdk_paintable_get_intrinsic_width (paintable);
+ height = gdk_paintable_get_intrinsic_width (paintable);
+ if (width == 0 || height == 0)
+ return gdk_paintable_new_empty (width, height);
- return NULL;
+ snapshot = gtk_snapshot_new (FALSE, "WidgetPaintableCurrentImage");
+ gdk_paintable_snapshot (GDK_PAINTABLE (self),
+ snapshot,
+ width, height);
+ return gtk_snapshot_free_to_paintable (snapshot, &(graphene_size_t) { width, height });
}
static int