Re: How to find CSS style syntax changes between Gtk 3.12 and Gtk 3.22
- From: Emmanuele Bassi <ebassi gmail com>
- To: Richard Shann <richard rshann plus com>
- Cc: "gtk-app-devel-list gnome org" <gtk-app-devel-list gnome org>
- Subject: Re: How to find CSS style syntax changes between Gtk 3.12 and Gtk 3.22
- Date: Wed, 10 May 2017 18:34:47 +0100
On 2017-05-08 at 13:57, Richard Shann wrote:
On Mon, 2017-05-08 at 12:28 +0100, Emmanuele Bassi wrote:
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;
Is that something different from the GtkWidgetClass that the widget has?
CSS classes are not related to widget classes.
https://developer.mozilla.org/en-US/docs/Web/CSS/Class_selectors
Are there a gtk_css_class_new() and a gtk_widget_assign_css_class()
functions to use them?
You want `GtkStyleContext` and `gtk_style_context_add_class()`:
https://developer.gnome.org/gtk3/stable/GtkWidget.html#gtk-widget-get-style-context
https://developer.gnome.org/gtk3/stable/GtkStyleContext.html#gtk-style-context-add-class
I'm completely at sea.
You probably want to read the API reference, then:
https://developer.gnome.org/gtk3/stable/theming.html
Additionally, you may want to read online resources about CSS.
Meanwhile for anyone with an application that has
to compile with versions of Gtk+ before and after version 3.20 here is
the code that is currently working for me to set the background color of
a widget:
8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><
static gchar *get_css_selector (GtkWidget *w)
{
static gchar *ret = NULL;
#if ((GTK_MAJOR_VERSION==3) && (GTK_MINOR_VERSION>=20))
g_free (ret);
ret = g_ascii_strdown (g_strdup (g_type_name (G_TYPE_FROM_INSTANCE (w))), -1);
return ret+3;
#else
ret = (gchar *)g_type_name (G_TYPE_FROM_INSTANCE (w));
return ret;
#endif
}
Please, don't do this.
This won't work for various widgets, and there's no guarantee it'll ever
work at all. There is *no* programmatic relationship between the CSS
element name and the type name.
For instance, `GtkRadioMenuItem` has a CSS element name called
`menuitem` and a sub-element called `radio`, with a `left` or `right`
class depending on the text direction. Thus, the selector is going to
be:
menuitem radio { ... }
The GtkSeparatorMenuItem, on the other hand, has a single CSS element
name called `separator`.
Ciao,
Emmanuele.
--
https://www.bassi.io
[@] ebassi [@gmail.com]
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]