[gtk+] tests: Use new drawing area APIs in testcairo



commit ca47c752728c050ca7a23d20161e4a049d7c4c73
Author: Benjamin Otte <otte redhat com>
Date:   Fri Nov 18 22:41:15 2016 +0100

    tests: Use new drawing area APIs in testcairo

 tests/testcairo.c |   16 +++++++---------
 1 files changed, 7 insertions(+), 9 deletions(-)
---
diff --git a/tests/testcairo.c b/tests/testcairo.c
index 8c45bc1..e2e22d8 100644
--- a/tests/testcairo.c
+++ b/tests/testcairo.c
@@ -113,16 +113,17 @@ draw_3circles (cairo_t *cr,
   cairo_fill (cr);
 }
 
-static gboolean
-on_draw (GtkWidget *widget,
-         cairo_t   *cr)
+static void
+on_draw (GtkDrawingArea *darea,
+         cairo_t        *cr,
+         int             width,
+         int             height,
+         gpointer        data)
 {
   cairo_surface_t *overlay, *punch, *circles;
   cairo_t *overlay_cr, *punch_cr, *circles_cr;
 
   /* Fill the background */
-  int width = gtk_widget_get_allocated_width (widget);
-  int height = gtk_widget_get_allocated_height (widget);
   double radius = 0.5 * (width < height ? width : height) - 10;
   double xc = width / 2.;
   double yc = height / 2.;
@@ -181,8 +182,6 @@ on_draw (GtkWidget *widget,
   cairo_surface_destroy (overlay);
   cairo_surface_destroy (punch);
   cairo_surface_destroy (circles);
-
-  return FALSE;
 }
 
 int
@@ -200,8 +199,7 @@ main (int argc, char **argv)
   darea = gtk_drawing_area_new ();
   gtk_container_add (GTK_CONTAINER (window), darea);
 
-  g_signal_connect (darea, "draw",
-                   G_CALLBACK (on_draw), NULL);
+  gtk_drawing_area_set_draw_func (GTK_DRAWING_AREA (darea), on_draw, NULL, NULL);
   g_signal_connect (window, "destroy-event",
                    G_CALLBACK (gtk_main_quit), NULL);
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]