[pygtk] pygtk-codegen, enum/flags issue
Gustavo J. A. M. Carneiro
gjc at inescporto.pt
Wed May 31 02:35:39 WST 2006
On Ter, 2006-05-30 at 08:26 +0100, Magnus Therning wrote:
> There's a patch for libwnck so that it implements a method for setting
> the geometry for a window (wnck_window_set_geometry() in the patch for
> GNOME bug 342899[1]). In my attempts to add a python binding for this
> I've run into some problems with one of the enums:
>
> wnck.c: In function '_wrap_wnck_window_set_geometry':
> wnck.c:1562: error: 'WNCK_TYPE_WINDOW_MOVERESIZEMASK' undeclared (first use in this function)
> wnck.c:1562: error: (Each undeclared identifier is reported only once
> wnck.c:1562: error: for each function it appears in.)
> wnck.c: In function 'pywnck_add_constants':
> wnck.c:2009: error: 'WNCK_TYPE_WINDOW_MOVERESIZEMASK' undeclared (first use in this function)
>
> The patch is at the end of the email.
>
> I have two questions:
> 1. What's the difference between enum and flags for pygtk-codegen, and
> when should I use which?
enums are mutually exclusive values; flags are values that can be
combined in a single 'set' value, like bit masks.
> 2. How do i derive the gtype-id? (I seem to have done it right for
> WnckWindowGravity but not for WnckWindowMoveResizeMask.)
gtype-id is guessed by h2def.py, but most libraries out there are not
bindings-friendly and don't bother to register GType's for enums and
flags. Metacity is one of those. My advice is, simply remove the
gtype-id, so pygtk-codegen will simply generate code to register the
values as simple int constants.
>
> /M
>
> 1. http://bugzilla.gnome.org/show_bug.cgi?id=342899
>
>
> Index: python-gnome2-extras/gnome-python-extras-2.12.1/wnck/wnck.defs
> ===================================================================
> --- python-gnome2-extras.orig/gnome-python-extras-2.12.1/wnck/wnck.defs 2006-05-30 07:55:33.000000000 +0100
> +++ python-gnome2-extras/gnome-python-extras-2.12.1/wnck/wnck.defs 2006-05-30 08:10:34.000000000 +0100
> @@ -132,6 +132,36 @@
> )
> )
>
> +(define-enum WindowGravity
> + (in-module "Wnck")
> + (c-name "WnckWindowGravity")
> + (gtype-id "WNCK_TYPE_WINDOW_GRAVITY")
> + (values
> + '("current" "WNCK_WINDOW_GRAVITY_CURRENT")
> + '("northwest" "WNCK_WINDOW_GRAVITY_NORTHWEST")
> + '("north" "WNCK_WINDOW_GRAVITY_NORTH")
> + '("northeast" "WNCK_WINDOW_GRAVITY_NORTHEAST")
> + '("west" "WNCK_WINDOW_GRAVITY_WEST")
> + '("center" "WNCK_WINDOW_GRAVITY_CENTER")
> + '("east" "WNCK_WINDOW_GRAVITY_EAST")
> + '("southwest" "WNCK_WINDOW_GRAVITY_SOUTHWEST")
> + '("south" "WNCK_WINDOW_GRAVITY_SOUTH")
> + '("southeast" "WNCK_WINDOW_GRAVITY_SOUTHEAST")
> + )
> +)
> +
> +(define-enum WindowMoveResizeMask
> + (in-module "Wnck")
> + (c-name "WnckWindowMoveResizeMask")
> + (gtype-id "WNCK_TYPE_WINDOW_MOVERESIZEMASK")
> + (values
> + '("change-x" "WNCK_WINDOW_CHANGE_X")
> + '("change-y" "WNCK_WINDOW_CHANGE_Y")
> + '("change-width" "WNCK_WINDOW_CHANGE_WIDTH")
> + '("change-height" "WNCK_WINDOW_CHANGE_HEIGHT")
> + )
> +)
> +
>
> ;; From /usr/include/libwnck-1.0/libwnck/application.h
>
> @@ -1033,6 +1063,20 @@
> )
> )
>
> +(define-method set_geometry
> + (of-object "WnckWindow")
> + (c-name "wnck_window_set_geometry")
> + (return-type "none")
> + (parameters
> + '("WnckWindowGravity" "gravity")
> + '("WnckWindowMoveResizeMask" "geometry_mask")
> + '("int" "x")
> + '("int" "y")
> + '("int" "width")
> + '("int" "height")
> + )
> +)
> +
> (define-method is_visible_on_workspace
> (of-object "WnckWindow")
> (c-name "wnck_window_is_visible_on_workspace")
>
> _______________________________________________
> pygtk mailing list pygtk at daa.com.au
> http://www.daa.com.au/mailman/listinfo/pygtk
> Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
--
Gustavo J. A. M. Carneiro
<gjc at inescporto.pt> <gustavo at users.sourceforge.net>
The universe is always one step beyond logic.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 2289 bytes
Desc: not available
Url : http://www.daa.com.au/pipermail/pygtk/attachments/20060530/e6487f88/smime.bin
More information about the pygtk
mailing list