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 494500 - gnomecanvas.path_def_new() doesn't provide a way to build a closed path
gnomecanvas.path_def_new() doesn't provide a way to build a closed path
Status: RESOLVED FIXED
Product: gnome-python
Classification: Deprecated
Component: general
CVS HEAD
Other All
: Normal major
: ---
Assigned To: Nobody's working on this now (help wanted and appreciated)
Python bindings maintainers
Depends on:
Blocks:
 
 
Reported: 2007-11-07 08:46 UTC by Moriyoshi Koizumi
Modified: 2007-11-24 17:56 UTC
See Also:
GNOME target: ---
GNOME version: Unversioned Enhancement



Description Moriyoshi Koizumi 2007-11-07 08:46:56 UTC
Please describe the problem:
The toplevel function path_def_new() of gnomecanvas module, which is responsible for building a GnomeCanvasPathDef object from a sequence of tuples, always leaves the built path unclosed, apparently does not allow users to close it afterwards. A path needs to be closed when it is presented as a filled object.

The following patch adds a feature to the above path_def_new() function that allows the constant ART_END (as gnomecanvas.END) to be used for a path closing marker, which previously had no meaning as a path code.

Index: canvasmodule.c
===================================================================
--- canvasmodule.c	(revision 592)
+++ canvasmodule.c	(working copy)
@@ -85,6 +85,7 @@
     add_item(MOVETO_OPEN);
     add_item(CURVETO);
     add_item(LINETO);
+    add_item(END);
 #undef add_item
 	
     pycanvas_register_classes (d);
Index: canvas.override
===================================================================
--- canvas.override	(revision 592)
+++ canvas.override	(working copy)
@@ -566,6 +566,9 @@
 	    break;
 
 	case ART_END:
+            gnome_canvas_path_def_closepath(path);
+            break;
+
 	default:
 	    gnome_canvas_path_def_unref(path);
 	    return PyErr_Format(PyExc_ValueError, "invalid path code %i",


Steps to reproduce:
import gtk
import gnomecanvas

canvas = gnomecanvas.Canvas(aa = True)

c1 = canvas.root().add(
    gnomecanvas.CanvasGroup,
    x = 0, y = 10)

c2 = canvas.root().add(
    gnomecanvas.CanvasGroup,
    x = 0, y = 50)

c1.add(
    gnomecanvas.CanvasBpath,
    cap_style = gtk.gdk.CAP_BUTT,
    bpath =  gnomecanvas.path_def_new([
        (gnomecanvas.MOVETO, 30, 0),
        (gnomecanvas.LINETO, 40, 0),
        (gnomecanvas.CURVETO, 70, 0, 70, 30, 40, 30),
        (gnomecanvas.LINETO, 30, 30),
        (gnomecanvas.CURVETO, 0, 30, 0, 0, 10, 0)
        ]),
    fill_color = 'red', outline_color = 'black',
    width_units = 4.0)

c2.add(
    gnomecanvas.CanvasBpath,
    cap_style = gtk.gdk.CAP_BUTT,
    bpath =  gnomecanvas.path_def_new([
        (gnomecanvas.MOVETO, 30, 0),
        (gnomecanvas.LINETO, 40, 0),
        (gnomecanvas.CURVETO, 70, 0, 70, 30, 40, 30),
        (gnomecanvas.LINETO, 30, 30),
        (gnomecanvas.CURVETO, 0, 30, 0, 0, 10, 0),
        (gnomecanvas.END,)
        ]),
    fill_color = 'red', outline_color = 'black',
    width_units = 4.0)

canvas.set_size_request(80, 120)
canvas.set_scroll_region(0, 0, 80, 120)

wnd = gtk.Window(gtk.WINDOW_TOPLEVEL)
wnd.connect("destroy", lambda widget: gtk.main_quit())
wnd.add(canvas)

wnd.show_all()

gtk.main()



Actual results:


Expected results:


Does this happen every time?


Other information:
Comment 1 Gustavo Carneiro 2007-11-24 17:56:55 UTC
This problem has been fixed in the development version. The fix will be available in the next major software release. Thank you for your bug report.