summaryrefslogtreecommitdiff
path: root/demos/gtk-utils.c
diff options
context:
space:
mode:
authorManuel Stoeckl <code@mstoeckl.com>2021-10-10 21:29:15 -0400
committerManuel Stoeckl <code@mstoeckl.com>2022-01-12 23:19:39 -0500
commitc6e1af995e3b2af2044faf1b815dc5323af7c691 (patch)
treeaef568ce541c08e32530f1f0aaa586836d831601 /demos/gtk-utils.c
parenteadb82866b0f6a326a61c36f60e5c2be8f7479af (diff)
downloadpixman-c6e1af995e3b2af2044faf1b815dc5323af7c691.tar.gz
demos: port to Gtk3
GTK2 has reached end of life, and GTK3 has been available for a almost a decade. Signed-off-by: Manuel Stoeckl <code@mstoeckl.com> Reviewed-by: Simon Ser <contact@emersion.fr>
Diffstat (limited to 'demos/gtk-utils.c')
-rw-r--r--demos/gtk-utils.c10
1 files changed, 3 insertions, 7 deletions
diff --git a/demos/gtk-utils.c b/demos/gtk-utils.c
index 32d4aec..b3a60ff 100644
--- a/demos/gtk-utils.c
+++ b/demos/gtk-utils.c
@@ -93,15 +93,14 @@ pixbuf_from_argb32 (uint32_t *bits,
}
static gboolean
-on_expose (GtkWidget *widget, GdkEventExpose *expose, gpointer data)
+on_draw (GtkWidget *widget, cairo_t *cr, gpointer user_data)
{
- pixman_image_t *pimage = data;
+ pixman_image_t *pimage = user_data;
int width = pixman_image_get_width (pimage);
int height = pixman_image_get_height (pimage);
int stride = pixman_image_get_stride (pimage);
cairo_surface_t *cimage;
cairo_format_t format;
- cairo_t *cr;
if (pixman_image_get_format (pimage) == PIXMAN_x8r8g8b8)
format = CAIRO_FORMAT_RGB24;
@@ -111,14 +110,11 @@ on_expose (GtkWidget *widget, GdkEventExpose *expose, gpointer data)
cimage = cairo_image_surface_create_for_data (
(uint8_t *)pixman_image_get_data (pimage),
format, width, height, stride);
-
- cr = gdk_cairo_create (widget->window);
cairo_rectangle (cr, 0, 0, width, height);
cairo_set_source_surface (cr, cimage, 0, 0);
cairo_fill (cr);
- cairo_destroy (cr);
cairo_surface_destroy (cimage);
return TRUE;
@@ -170,7 +166,7 @@ show_image (pixman_image_t *image)
break;
}
- g_signal_connect (window, "expose_event", G_CALLBACK (on_expose), copy);
+ g_signal_connect (window, "draw", G_CALLBACK (on_draw), copy);
g_signal_connect (window, "delete_event", G_CALLBACK (gtk_main_quit), NULL);
gtk_widget_show (window);