diff options
author | Javier Jardón <jjardon@gnome.org> | 2010-08-16 00:37:47 +0200 |
---|---|---|
committer | Javier Jardón <jjardon@gnome.org> | 2010-08-22 18:28:06 +0200 |
commit | e80db673b1d2416eb2fecda92c6193c8d317fba5 (patch) | |
tree | a15906480bd2e058a62d530301f92d13a4662701 /demos/gtk-demo/drawingarea.c | |
parent | 6a28e7b16404b6481496b763bc60b47cbae21bdb (diff) | |
download | gtk+-e80db673b1d2416eb2fecda92c6193c8d317fba5.tar.gz |
demos/gtk-demo/drawingarea.c: Use accessor functions to access GtkWidget
Diffstat (limited to 'demos/gtk-demo/drawingarea.c')
-rw-r--r-- | demos/gtk-demo/drawingarea.c | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/demos/gtk-demo/drawingarea.c b/demos/gtk-demo/drawingarea.c index 84f3958c73..b0fbb071e9 100644 --- a/demos/gtk-demo/drawingarea.c +++ b/demos/gtk-demo/drawingarea.c @@ -25,15 +25,17 @@ scribble_configure_event (GtkWidget *widget, GdkEventConfigure *event, gpointer data) { + GtkAllocation allocation; cairo_t *cr; if (surface) cairo_surface_destroy (surface); - surface = gdk_window_create_similar_surface (widget->window, + gtk_widget_get_allocation (widget, &allocation); + surface = gdk_window_create_similar_surface (gtk_widget_get_window (widget), CAIRO_CONTENT_COLOR, - widget->allocation.width, - widget->allocation.height); + allocation.width, + allocation.height); /* Initialize the surface to white */ cr = cairo_create (surface); @@ -55,7 +57,7 @@ scribble_expose_event (GtkWidget *widget, { cairo_t *cr; - cr = gdk_cairo_create (widget->window); + cr = gdk_cairo_create (gtk_widget_get_window (widget)); cairo_set_source_surface (cr, surface, 0, 0); gdk_cairo_rectangle (cr, &event->area); @@ -89,7 +91,7 @@ draw_brush (GtkWidget *widget, cairo_destroy (cr); /* Now invalidate the affected region of the drawing area. */ - gdk_window_invalidate_rect (widget->window, + gdk_window_invalidate_rect (gtk_widget_get_window (widget), &update_rect, FALSE); } @@ -146,6 +148,7 @@ checkerboard_expose (GtkWidget *da, GdkEventExpose *event, gpointer data) { + GtkAllocation allocation; gint i, j, xcount, ycount; cairo_t *cr; @@ -159,17 +162,18 @@ checkerboard_expose (GtkWidget *da, * works. */ - cr = gdk_cairo_create (da->window); + cr = gdk_cairo_create (gtk_widget_get_window (da)); gdk_cairo_rectangle (cr, &event->area); cairo_clip (cr); + gtk_widget_get_allocation (da, &allocation); xcount = 0; i = SPACING; - while (i < da->allocation.width) + while (i < allocation.width) { j = SPACING; ycount = xcount % 2; /* start with even/odd depending on row */ - while (j < da->allocation.height) + while (j < allocation.height) { if (ycount % 2) cairo_set_source_rgb (cr, 0.45777, 0, 0.45777); |