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 412134 - Add API to query style properties from the style
Add API to query style properties from the style
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: .General
unspecified
Other Linux
: Normal enhancement
: ---
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2007-02-26 05:25 UTC by Mariano Suárez-Alvarez
Modified: 2008-11-01 04:15 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Add gtk_style_get_property and friends (5.95 KB, patch)
2007-02-26 05:26 UTC, Mariano Suárez-Alvarez
committed Details | Review

Description Mariano Suárez-Alvarez 2007-02-26 05:25:20 UTC
Currently, if one needs to know the value of a style property for a widget class for which one does not have an instance (imagine you need to paint something in a canvas in the same colors used for even and odd rows in a tree view, for example)

Aparently, apps that do this (firefox and openoffice, e.g., according to mclasen on irc) create a widget and query its style properties.

Here comes a patch that adds:

void gtk_style_get_property (GtkStyle    *style,
                             GType        widget_type,
                             const gchar *property_name,
                             GValue      *value);
void gtk_style_get_valist   (GtkStyle    *style,
                             GType        widget_type,
                             const gchar *first_property_name,
                             va_list      var_args);
void gtk_style_get          (GtkStyle    *style,
                             GType        widget_type,
                             const gchar *first_property_name,
                             ...) G_GNUC_NULL_TERMINATED;
Comment 1 Mariano Suárez-Alvarez 2007-02-26 05:26:37 UTC
Created attachment 83356 [details] [review]
Add gtk_style_get_property and friends
Comment 2 Aaron Bockover 2008-09-23 22:01:25 UTC
This patch looks good to me. It would be nice if someone more involved with GTK itself would take the time to mold this into the tree. 

It would be extremely helpful for those of us writing custom widgets or adapting different toolkits to the GTK look and feel.

It's been 1.5 years since Mariano posted this patch. Some review would be great.
Comment 3 Christian Dywan 2008-09-24 00:01:23 UTC
The idea has an essential flaw: theme engines do not simply look at style properties, they do look at whole hierarchies of widgets and their state. There's some great work going on towards a better theming interface these days, you should read on the gtk-devel mailing list about this or consult a web search engine.

I don't think the proposal makes much sense at this point.
Comment 4 Matthias Clasen 2008-11-01 04:15:30 UTC
2008-11-01  Matthias Clasen  <mclasen@redhat.com>

        Bug 412134 – Add API to query style properties from the style

        * gtk/gtk.symbols:
        * gtk/gtkstyle.[hc]: Add getters for style properties to
        avoid the need for ugly workarounds with dummy widget instances.
        Patch by Mariano Suárez-Alvarez