[pygtk] New constructor style in PyGTK 2.8

Gustavo J. A. M. Carneiro gjc at inescporto.pt
Thu Mar 23 23:41:05 WST 2006


On Qui, 2006-03-23 at 16:31 +0100, Jacob Kroon wrote:
> Jacob Kroon wrote:
> > Gustavo J. A. M. Carneiro wrote:
> >> On Qui, 2006-03-23 at 15:30 +0100, Jacob Kroon wrote:
> >>  
> >>> Hi,
> >>>
> >>> I'm converting my defs file to use the new constructor style in 
> >>> pygtk 2.8, I have read
> >>>
> >>> http://live.gnome.org/PyGTK/WhatsNew28#update-constructors
> >>>
> >>> and have run into some questons:
> >>>
> >>> 1. Is ok to leave out the "new-constructor foo_bar_type" fields in 
> >>> the override file ? It seems to work fine anyway.
> >>>     
> >>
> >>   If you omit "new-constructor foo_bar_type" you'll get into trouble
> >> when trying to do use constructor properties, like gobject.new(FooBar,
> >> prop_foo=123).  You really shouldn't omit it.
> >>
> >>  
> >>> 2. In the defs file I've simply put:
> >>> ...
> >>>  (properties
> >>>   ("arg1" "arg1")
> >>>   ("arg2" "arg2")
> >>>  )
> >>>
> >>>    and this also seems to work. Are there any special reasons for 
> >>> using (argname="xxx") like the website explains ?
> >>>     
> >>
> >>   I'm not sure what ("arg1" "arg1") does, probably the second "arg1" is
> >> simply ignored.  In any case, (argname="xxx") is optional.  We needed
> >> that in pygtk itself in order to preserve API compatibility.  If you
> >> don't need to preserve API, or if the property name is the same as the
> >> parameter name, you can leave it out.
> >>
> >>   
> > Ok I think I understand then, thanks.
> >
> The generated code looks exactly the same though, wether I omit the 
> "new-constructor" lines, or put them in there...

  The wrapper itself looks the same, but check the xxx_register_classes;
you'll see another pygobject API call for each type with declared new
constructor, like pyg_set_object_has_new_constructor(FOO_TYPE_BAR).

> (just to be clear, I made a type previously, i guess it should be 
> "new-constructor FOO_TYPE_BAR")
> 
> --Jacob
> 
-- 
Gustavo J. A. M. Carneiro
<gjc at inescporto.pt> <gustavo at users.sourceforge.net>
The universe is always one step beyond logic.



More information about the pygtk mailing list