[gtk+] testgtk: Use draw signal in layout test
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] testgtk: Use draw signal in layout test
- Date: Sun, 26 Sep 2010 13:43:01 +0000 (UTC)
commit e194bc14fd3ac97de1de7c463aaac8879fb9e00f
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 a7f9445..e51635d 100644
--- a/tests/testgtk.c
+++ b/tests/testgtk.c
@@ -9697,29 +9697,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++)
@@ -9730,8 +9732,6 @@ layout_expose_handler (GtkWidget *widget, GdkEventExpose *event)
cairo_fill (cr);
- cairo_destroy (cr);
-
return FALSE;
}
@@ -9784,8 +9784,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]