Widget theming: GtkWidget vs GtkStyleContext
- From: Lukas Middelberg <lukas middelberg-bi net>
- To: gtk-list gnome org
- Subject: Widget theming: GtkWidget vs GtkStyleContext
- Date: Sun, 09 Oct 2016 21:54:26 +0200
Hey guys,
I am kind of confused by the way Gtk handles widget theming. I know 
that styling information is stored
in a GtkStyleContext object corresponding to the GtkWidget to be 
themed. However, if I want to install a
new style property into a widget, I need to use methods defined in 
GtkWidget:
Gtk.Widget.install_style_property ()
Gtk.Widget.install_style_property_parser ()
Also, the methods for retrieving properties seem kind of redundant -
StyleContext                                   Widget
============                                   ======
Gtk.StyleContext.get_style_property ()   vs    
Gtk.Widget.style_get_property ()
Gtk.StyleContext.get_style_valist ()     vs    
Gtk.Widget.style_get_valist ()
Gtk.StyleContext.get_valist ()
Gtk.StyleContext.@get ()                 vs    Gtk.Widget.style_get ()
 (at least that's the vala syntax)
                                               Gtk.Widget.find_style_property ()
                                              
Gtk.Widget.list_style_properties ()
Why is that? In what ways do e.g. StyleContext.get_style_property and 
Widget.style_get_property differ?
Which one of them should I use in order to be able to theme custom 
widgets?
Also, please consider this example:
If I subclass GtkWidget and register a custom property "dummy", I can 
access that property using
   myobj.style_get ("dummy", out somevariable);
whereas this fails saying "Style property 'dummy' is not registered":
   myobj.get_style_context ().@get (Gtk.StateFlags.NORMAL, "dummy", 
out somevariable);
(I put the full example into a pastebin: http://sprunge.us/BQKP)
In what ways are the StyleContext methods different from the GtkWidget 
ones? How come I can access custom-defined
style properties from GtkWidget but not from GtkStyleContext?
Can someone please clear me up?
Thanks a ton,
Lukas
[
Date Prev][
Date Next]   [
Thread Prev][
Thread Next]   
[
Thread Index]
[
Date Index]
[
Author Index]