Re: Gtk3 CSS classes for Custom Widgets - Help!



Hi,

Le 16/02/2018 à 12:12, Randall Sawyer a écrit :
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).

This sounds a fairly odd way to proceed, as if it has all the properties
of a GtkButton it would seem a whole lot easier to use a GtkButton as a
basis and just react to its various changes… and you wouldn't have to
extensively try and pretend being a GtkButton which you are not. But
well, maybe I don't know your code.

[…]

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.

That's unlucky, because there is just gtk_widget_class_set_css_name()
[1] which seems to be exactly what you are looking for -- e.g. set the
CSS node name, not *class* name.

[1]
https://developer.gnome.org/gtk3/stable/GtkWidget.html#gtk-widget-class-set-css-name

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

It's not an inconsistency, it's just the difference between a CSS node
and a CSS class name.  In CSS you got node name, classes and ID, so you
do in GTK, which maps them to widget class' CSS name
(gtk_widget_class_set_css_name()), classes on the style context, and
widget name (gtk_widget_set_name()) respectively.

Regards,
Colomban


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