CSS class priority

Hi all:

I’m modifying a program to use CSS instead of fixed colors, and I want the global theme to have priority over the local one. I mean: my program has its own CSS files where I define several things, and one specific thing is the foreground/background color of an element. But I want that the current global theme would be able to overwrite that if desired. This is: if the global theme (let’s say… Yaru :wink: ) contains an specific definition for a class, I want to use that instead the one in my file, but if the global theme doesn’t define that, I want to use the definition in my .css file. But I want that only for that specific widget. For everything else I want the default behavior (whichever it is).

How can I achieve that? I tried changing the order in which I call gtk_style_context_add_class() but doesn’t seem to work…

Thanks.

As far as I can see, you cannot prioritize style classes, only stylesheets.

That is, if you use GTK_STYLE_PROVIDER_PRIORITY_FALLBACK when adding the app’s style provider, then the regular theme takes precendence.