On 8 May 2017 at 12:04, Richard Shann <rich...@rshann.plus.com> wrote:
>> But I'd strongly recommend you use CSS classes instead of styling the >> bare element name. >> >> CSS selectors in GTK+ work exactly like the HTML counterpart; you can >> style "div" or "p" directly, but it's often much more appropriate to >> create a specific CSS class, like "green-background", and add it to >> the widget you wish to style. > > I didn't find anything describing creating a GtkWidgetClass in the > gtk3/stable documentation, it seems that there is a field in the > GtkWidget structure pointing to such a structure accessed via > > GTK_WIDGET_GET_CLASS (widget) Yes, this is part of basic GObject usage: each instance has a pointer to its instantiating class structure. > so I imagine that using > > gtk_widget_class_set_css_name (class, name) > > could mean you would get control over the style of that widget and any > others whose class you assigned that name. You don't have *control* over the style. You can *add* to the existing style — which may include undoing what the existing style does, but then you need to know what the style does, or essentially reset CSS properties by using their initial state, see: https://drafts.csswg.org/css-cascade-3/#initial This is how CSS works. The only way for you to control the style of a GTK+ application is to ship your own theme, and load it in place of the user theme. CSS is a *very* powerful set of rules for rendering content using a declarative syntax; it's *really* not a bunch of color definitions, like the style system in GTK+ 2.x. You will need to learn how CSS works in order to use it. > But I will have to wait for > Debian to catch up with Gtk 3.20 before I can seriously look at this. And this is why I suggest you use a CSS class, instead; CSS classes work regardless of what the CSS name of a widget is. Ciao, Emmanuele. -- https://www.bassi.io [@] ebassi [@gmail.com] _______________________________________________ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list