Gtk3 CSS classes for Custom Widgets - Help!



I am designing a desktop tool in C Gtk+3 (v. 3.20.8).

I have devised a custom widget which is intended to appear and react to user input as if it were a button (without the overhead of inheriting GtkButton). Thus, in my ..._widget_init() function, I use gtk_widget_get_style_context() and gtk_style_context_add_class (context, GTK_STYLE_CLASS_BUTTON) . In my ..._widget_draw() function, I use gtk_render_background() and gtk_render_frame() .

Whether or not this actually results as desired depends upon which theme I am using. Specifically, whether CSS button styles are defined using the /type selector/ "button" or the /class selector/ ".button".

I never get the button style if the theme has been composed using the /type selector/ "button"; for example, in Adwaita.

I always get the button style if the theme has uses the /class selector/ ".button".

I have done extensive searches to see if anyone else has brought this to the attention of the Gtk community. So far I have found nothing about it.

As I see it there are two possibilities to remedy this inconsistency:

1) Explicitly specify that all valid gtk-3.0 themes are to be written using supported class names prefixed with '.', OR

2) Modify the Gtk CSS parser to apply user-provided standard class names - the ones defined using the GTK_STYLE_CLASS_... macros - to type names when looking up CSS properties.


Thank you for your time and interest.




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]