summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Otte <otte@redhat.com>2018-04-02 08:19:51 +0200
committerBenjamin Otte <otte@redhat.com>2018-04-05 14:56:39 +0200
commitc85547667fb7fb12c102baf0c715ea7185040bbb (patch)
treefc527cd42a7fc76d37832859b84c5044efadcb8f
parenta595a4c2ce4f851a4804bfbd273e953cacff5e25 (diff)
downloadgtk+-c85547667fb7fb12c102baf0c715ea7185040bbb.tar.gz
testgtk: Take an actual snapshot of a widget
Don't just draw the widget, take the paintable of it instead!
-rw-r--r--tests/testgtk.c23
1 files changed, 4 insertions, 19 deletions
diff --git a/tests/testgtk.c b/tests/testgtk.c
index 94cb785d02..2f242bacde 100644
--- a/tests/testgtk.c
+++ b/tests/testgtk.c
@@ -6795,29 +6795,14 @@ snapshot_widget_event (GtkWidget *widget,
res_widget = gtk_widget_get_toplevel (res_widget);
if (res_widget)
{
- cairo_surface_t *surface;
GtkWidget *window, *image;
- GdkPixbuf *pixbuf;
- int width, height;
- cairo_t *cr;
+ GdkPaintable *paintable;
- width = gtk_widget_get_allocated_width (res_widget);
- height = gtk_widget_get_allocated_height (res_widget);
-
- surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, width, height);
-
- cr = cairo_create (surface);
- gtk_widget_draw (res_widget, cr);
- cairo_destroy (cr);
-
- pixbuf = gdk_pixbuf_get_from_surface (surface,
- 0, 0,
- width, height);
- cairo_surface_destroy (surface);
+ paintable = gtk_widget_paintable_new (res_widget);
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
- image = gtk_image_new_from_pixbuf (pixbuf);
- g_object_unref (pixbuf);
+ image = gtk_image_new_from_paintable (paintable);
+ g_object_unref (paintable);
gtk_container_add (GTK_CONTAINER (window), image);
gtk_widget_show (window);