Re: How to find CSS style syntax changes between Gtk 3.12 and Gtk 3.22



On Wed, 2017-05-10 at 18:34 +0100, Emmanuele Bassi wrote:
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

Thank you for the references. I had seen that stuff but was lost right
at the start, it would seem that a background in HTML would be helpful,
and


Additionally, you may want to read online resources about CSS.

some notion about what CSS is. So I will have a lot of reading to do. 

But, meanwhile, I see that the code I posted (which I didn't originate,
just cooked up from someone else's earlier posting) did use
`GtkStyleContext` though not 'gtk_style_context_add_class()' but rather
'gtk_style_context_add_provider()' so perhaps it is ok code, if the
lookup of the css selector were more robust.
I append a copy, in case anyone cares to point out deficiencies.

Richard Shann

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><
void set_background_color(GtkWidget *w, gchar *color)
{
GtkCssProvider *gcp;
GtkStyleContext *gsc;
gsc = gtk_widget_get_style_context(w);
gchar *type = get_css_selector(w);
gchar *str = g_strdup_printf ("%s {background-color: %s;}", type, color); //g_print ("%s", str);
gcp= gtk_css_provider_new();
gtk_css_provider_load_from_data(gcp, str, -1, 0);
g_free (str);
gtk_style_context_add_provider(gsc, GTK_STYLE_PROVIDER(gcp), 
    GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
}
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><





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