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 784991 - Support Child Properties
Support Child Properties
Status: RESOLVED OBSOLETE
Product: pygobject
Classification: Bindings
Component: gobject
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: 2017-07-16 02:57 UTC by Dan Yeaw
Modified: 2018-01-10 20:59 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Dan Yeaw 2017-07-16 02:57:20 UTC
Bug 338098 added support for defining object properties using GObject.Property. In pygtk I was creating child properties using a dictionary, for example:
   
    __gchild_properties__ = {
        'weight': (GObject.TYPE_FLOAT,
                   'item weight',
                   'item weight',
                   0,  # min
                   1,  # max
                   .2,  # default
                   GObject.ParamFlags.READWRITE
                  ),
    }

and then:
    for index, (name, pspec) in enumerate(six.iteritems(DockPaned.__gchild_properties__)):
    pspec = list(pspec)
    pspec.insert(0, name)
    Gtk.ContainerClass.install_child_property(DockPaned, index + 1, tuple(pspec))

Unfortunately with PyGObject this gives a TypeError: argument pspec: Expected GObject.ParamSpec, but got tuple

There needs to be a way to create child properties through install_child_property. What if we defined these properties using a new GObject.ChildProperty solution similar to what was added for other normal properties?
Comment 1 Dan Yeaw 2017-07-19 02:36:04 UTC
I figured out that I can change my code to make use of GObject.param_spec_float to create a pspec, for example:

    Gtk.ContainerClass.install_child_property(DockPaned, 2, GObject.param_spec_float('weight', 'item weight', 'item weight', 0, 1, .2, GObject.ParamFlags.READWRITE))

TypeError: argument pspec: Expected GObject.ParamSpec, but got gobject.GParamSpec

Could we fix this by calling the override decorator from the overrides/__init__ module to force the gobject.GParamSpec type to be a GObject.ParamSpec?
Comment 2 GNOME Infrastructure Team 2018-01-10 20:59:47 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to GNOME's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/pygobject/issues/138.