[gtk+/rendering-cleanup-next: 138/154] testgtk: Use draw signal in layout test



commit fac3f3860923fc9da03e7d7b969144d504f20b54
Author: Benjamin Otte <otte redhat com>
Date:   Thu Sep 9 03:39:43 2010 +0200

    testgtk: Use draw signal in layout test

 tests/testgtk.c |   30 +++++++++++++++---------------
 1 files changed, 15 insertions(+), 15 deletions(-)
---
diff --git a/tests/testgtk.c b/tests/testgtk.c
index e93e7ea..6b73a3e 100644
--- a/tests/testgtk.c
+++ b/tests/testgtk.c
@@ -9696,29 +9696,31 @@ create_mainloop (GtkWidget *widget)
     gtk_widget_destroy (window);
 }
 
-gboolean
-layout_expose_handler (GtkWidget *widget, GdkEventExpose *event)
+static gboolean
+layout_draw_handler (GtkWidget *widget, cairo_t *cr)
 {
   GtkLayout *layout;
   GdkWindow *bin_window;
-  cairo_t *cr;
-
-  gint i,j;
+  GdkRectangle clip;
+  gint i,j,x,y;
   gint imin, imax, jmin, jmax;
 
   layout = GTK_LAYOUT (widget);
   bin_window = gtk_layout_get_bin_window (layout);
 
-  if (event->window != bin_window)
+  if (!gtk_cairo_should_draw_window (cr, bin_window))
     return FALSE;
   
-  imin = (event->area.x) / 10;
-  imax = (event->area.x + event->area.width + 9) / 10;
+  gdk_window_get_position (bin_window, &x, &y);
+  cairo_translate (cr, x, y);
 
-  jmin = (event->area.y) / 10;
-  jmax = (event->area.y + event->area.height + 9) / 10;
+  gdk_cairo_get_clip_rectangle (cr, &clip);
+
+  imin = (clip.x) / 10;
+  imax = (clip.x + clip.width + 9) / 10;
 
-  cr = gdk_cairo_create (bin_window);
+  jmin = (clip.y) / 10;
+  jmax = (clip.y + clip.height + 9) / 10;
 
   for (i=imin; i<imax; i++)
     for (j=jmin; j<jmax; j++)
@@ -9729,8 +9731,6 @@ layout_expose_handler (GtkWidget *widget, GdkEventExpose *event)
   
   cairo_fill (cr);
 
-  cairo_destroy (cr);
-
   return FALSE;
 }
 
@@ -9783,8 +9783,8 @@ void create_layout (GtkWidget *widget)
       gtk_layout_set_vadjustment (layout, vadjustment);
 
       gtk_widget_set_events (layout_widget, GDK_EXPOSURE_MASK);
-      g_signal_connect (layout, "expose_event",
-			G_CALLBACK (layout_expose_handler), NULL);
+      g_signal_connect (layout, "draw",
+			G_CALLBACK (layout_draw_handler), NULL);
 
       gtk_layout_set_size (layout, 1600, 128000);
 



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