GNOME Bugzilla – Bug 653844
Cairo example is broken
Last modified: 2011-07-07 18:13:12 UTC
Created attachment 191135 [details] [review] proposed patch I realized that this example is broken, since "expose-event" might be replaced by the "draw" signal. I've attached a fix for this issue. Regards!
Comment on attachment 191135 [details] [review] proposed patch >From 8ca9a5578b5a3ac6e179f3a5feb50d699fdd4903 Mon Sep 17 00:00:00 2001 >From: =?UTF-8?q?Javier=20Hern=C3=A1ndez?= <jhernandez@emergya.es> >Date: Sat, 2 Jul 2011 03:04:48 +0200 >Subject: [PATCH] Fixing cairo demo > >--- > examples/cairo-demo.py | 6 +++--- > 1 files changed, 3 insertions(+), 3 deletions(-) > >diff --git a/examples/cairo-demo.py b/examples/cairo-demo.py >index 72a0533..7204cdc 100755 >--- a/examples/cairo-demo.py >+++ b/examples/cairo-demo.py >@@ -79,8 +79,8 @@ def fill_shapes(ctx, x, y): > def stroke_shapes(ctx, x, y): > draw_shapes(ctx, x, y, False) > >-def expose (da, event): >- ctx = Gdk.cairo_create(da.window) >+def draw (da, event): >+ ctx = Gdk.cairo_create(da.get_window()) This is wrong. It should be: def draw (da, event, ctx): You shouldn't create a new context inside of the draw event. > > ctx.set_source_rgb(0, 0, 0) > >@@ -114,7 +114,7 @@ def main(): > > drawingarea = Gtk.DrawingArea() > win.add(drawingarea) >- drawingarea.connect('expose_event', expose) >+ drawingarea.connect('draw', draw) > > win.show_all() > Gtk.main() >-- >1.7.5.4 >
(In reply to comment #1) > >-def expose (da, event): > >- ctx = Gdk.cairo_create(da.window) > >+def draw (da, event): > >+ ctx = Gdk.cairo_create(da.get_window()) > > This is wrong. It should be: > def draw (da, event, ctx): Actually, this is wrong too. The draw signal only passes the widget and Cairo context. I'll attach a patch which corrects this.
Created attachment 191437 [details] [review] Fixed previous patch
Review of attachment 191437 [details] [review]: it works
Committed to invoke-rewrite branch which will become master, thanks