After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 653844 - Cairo example is broken
Cairo example is broken
Status: RESOLVED FIXED
Product: pygobject
Classification: Bindings
Component: general
Git master
Other Linux
: Normal normal
: ---
Assigned To: Nobody's working on this now (help wanted and appreciated)
Python bindings maintainers
Depends on:
Blocks:
 
 
Reported: 2011-07-02 01:10 UTC by Javier Hernández
Modified: 2011-07-07 18:13 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
proposed patch (971 bytes, patch)
2011-07-02 01:10 UTC, Javier Hernández
needs-work Details | Review
Fixed previous patch (942 bytes, patch)
2011-07-07 09:04 UTC, Timo Vanwynsberghe
committed Details | Review

Description Javier Hernández 2011-07-02 01:10:28 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 1 johnp 2011-07-05 16:05:15 UTC
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
>
Comment 2 Timo Vanwynsberghe 2011-07-07 09:03:31 UTC
(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.
Comment 3 Timo Vanwynsberghe 2011-07-07 09:04:30 UTC
Created attachment 191437 [details] [review]
Fixed previous patch
Comment 4 Javier Hernández 2011-07-07 09:15:35 UTC
Review of attachment 191437 [details] [review]:

it works
Comment 5 johnp 2011-07-07 18:13:06 UTC
Committed to invoke-rewrite branch which will become master, thanks