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 646536 - Cannot install Gtk.Widget style properties
Cannot install Gtk.Widget style properties
Status: RESOLVED OBSOLETE
Product: pygobject
Classification: Bindings
Component: introspection
2.28.x
Other Linux
: Normal normal
: ---
Assigned To: Nobody's working on this now (help wanted and appreciated)
Python bindings maintainers
Depends on: 685275
Blocks:
 
 
Reported: 2011-04-02 15:14 UTC by ulrik sverdrup
Modified: 2018-01-10 20:07 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description ulrik sverdrup 2011-04-02 15:14:34 UTC
I used gtk.widget_class_install_style_property in my app before, and trying to simply replace that with Gtk.WidgetClass.install_style_property does not seem effective, I get the error message:
TypeError: unbound method install_style_property() must be called with WidgetClass instance as first argument (got GObjectMeta instance instead)

Is this a libgtk2 but or a pygobject bug? I need to be able to pass the (Python) subclass of Gtk.Bin into install_style_property.

Is there a different preferred method to add style properties that can be used as a workaround?

thank you.
Comment 1 johnp 2011-04-04 17:30:57 UTC
I'm not sure about style properties but we don't support Gtk2, only Gtk3 for introspection.  PyGtk is still the preferred way to write Gtk2 apps.  If there is an issue with style properties in Gtk3, that does need to be fixed.
Comment 2 ulrik sverdrup 2011-04-05 00:55:55 UTC
Ok, a question then from someone who has not fit the whole of GTK and PyGTK into the brain yet, even though I've used it a lot.

What's the easiest way forward to port my application (Kupfer).

I've "translated" it whole, reported bugs on missing annotations and what I can see only the style properties are missing for it to run under pygi. Frankly, I didn't know if it was using gtk3 or gtk2 :-)

Anyway, is there a good path for porting? So porting to "gtk2 over introspection" doesn't exist as an option?

thanks.
Comment 3 John Stowers 2011-04-05 01:10:12 UTC
We don't recommend porting to introspection if you will continue to use GTK+-2.0. The overrides and codepaths for GTK-3.0 are not as well tested and likely more buggy. You should explicity require a GTK version using

import gi
gi.require_version("Gtk", "3.0")

I can't answer the rest of your question confidently i'm afraid. Theming changed in GTK+-3.0 a lot, and you might be hitting some of that transition here. I really like the new kupfer UI, but I fear it might need to be re-implemented using the new CSS theming....
Comment 4 ulrik sverdrup 2011-04-06 00:33:33 UTC
(I was porting against gir1.2-gtk-2.0 + pygobject 2.28 + libgtk 2.24.3 packages from Debian's experimental)

Thank you for the straight information. I'm seeing the introspection data being prepared in Debian, and yet it is suggested here that it will never be really useful for GTK 2. For me, I think the porting will simply have to begin at a later time then, going straight to GTK 3.

Nice that you like the new kupfer :-)  I don't think its a too big undertaking to eventually port the style properties etc.
Comment 5 johnp 2011-04-06 03:29:33 UTC
Yes, we should stop building Gtk2 girs by default.  There is nothing saying someone won't come along and fix the issues but I don't think it will ever be 100%.  There is just too much legacy code that is not wrappable.
Comment 6 John Stowers 2011-04-06 03:35:58 UTC
> GTK+-2.0. The overrides and codepaths for GTK-3.0 are not as well tested and
> likely more buggy. You should explicity require a GTK version using

Bah, of course I meant GTK-2.0 here.
Comment 7 ulrik sverdrup 2011-05-03 21:52:09 UTC
Ok, so after some more porting work... I'm porting to Gtk3 instead.

After finishing up all my merge conflicts, I feel like I was fooled here, because this same bug happens with Gtk3.

TypeError: unbound method install_style_property() must be called with WidgetClass instance as first argument (got GObjectMeta instance instead)

GTK 3.0.8
pygobject 2.28.3
Comment 8 John Stowers 2011-05-03 22:05:59 UTC
(In reply to comment #7)
> Ok, so after some more porting work... I'm porting to Gtk3 instead.
> 
> After finishing up all my merge conflicts, I feel like I was fooled here,
> because this same bug happens with Gtk3.
> 
> TypeError: unbound method install_style_property() must be called with
> WidgetClass instance as first argument (got GObjectMeta instance instead)
> 
> GTK 3.0.8
> pygobject 2.28.3

AFIAK, install_style_property and StyleProperty is the gtk+-2 API (depreciated in favour of the css based stylecontext)

With gtk+-3 theming went to GtkStyleContext and properties via css are installed using

gtk_style_properties_new() (of course the pygobject version)

and installed with

gtk_style_properties_register()

Glad to hear you are porting to gtk+-3. I just finished the gnome-sudoku port, which used quite a lot of custom widget drawing/cairo/theming/stylecontext API. Feel free to take a look over the commit logs for some inspiration
Comment 9 John Stowers 2011-05-03 22:14:37 UTC
hmm, on further reflection only about half of what I said may have been true... 

I still think install_style_property is gtk+-2 API, but looking at the gtk+-3 docs perhaps the equivilent registration of css is done with the theming engine, something like

gtk_theming_engine_register

in both cases im not sure of the state of this binding in PyGObject (i have not yet ported custom colors on gnome-sudoku)
Comment 10 ulrik sverdrup 2011-05-04 12:35:20 UTC
Thanks for this information. I will look at your port, but I think I will also need to wait for a more mature version and a larger porting guide, right now I'm stuck with my custom GtkBin subclass not being shown/drawn at all.

There are also issues such as the 'allocation' object passed to the size-allocate handler is an opaque unusable object (can't access its value).
Comment 11 johnp 2011-05-04 16:42:17 UTC
allocation object should be fine with the latest versions of pygobject.  File a bug if not.  As for subclassing GtkBin, we need to fix how we handle forall (e.g. we need to implement callable C callbacks when passed into a python callback).  I have a proof of concept but we won't support full subclassing like that until PyGObject 3.
Comment 12 Martin Pitt 2012-04-23 17:41:40 UTC
Keeping this open, as currently there is no way to produce a WidgetClass instance, and neither a GObject.ParamSpec object using GI.
Comment 13 Simon Feltman 2014-07-27 09:08:30 UTC
Now that bug 685218 has landed, Widget.install_style_property() is available, but we still need to unify GObject.ParamSpec (introspection) and gobject.GParamSpec (static bindings). Marking this as depending on bug 685275.
Comment 14 GNOME Infrastructure Team 2018-01-10 20:07:36 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/13.