After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 692379 - Style providers added as GTK_STYLE_PROVIDER_PRIORITY_FALLBACK do not always provide fallback support
Style providers added as GTK_STYLE_PROVIDER_PRIORITY_FALLBACK do not always p...
Status: RESOLVED NOTABUG
Product: gtk+
Classification: Platform
Component: Class: GtkStyleContext
3.10.x
Other Linux
: Normal normal
: ---
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2013-01-23 12:58 UTC by Michael Webster
Modified: 2014-05-13 15:47 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Michael Webster 2013-01-23 12:58:07 UTC
I have an application, for which I wish to provide a couple named style classes.  For example, my .css file contains:

.custom-style-class-name {
    some stuff: 10px;
}

I want to provide this as a fallback in the event the current user's theme does not have this class name included in it, so I add a new provider using gtk_style_context_add_provider_for_screen with a priority of _FALLBACK.

In my application, I add a gtk_style_context_add_class (context, "custom-style-class-name")

My application fails to see this custom class name in my app-supplied .css file. (but sees a theme-supplied version.)

If I switch to _APPLICATION priority, it works fine, but it overrides current theme's definition, which I don't want.


Now, if on the other hand I define a custom style like this:

MyCustomClassName {
    some stuff: 10px;
}

And I again add it as a _FALLBACK provider, this works perfectly (or at least how I envision that it should work) - my application can see this style information, and uses it automatically if the theme does not provide for it.  If it exists in the theme, the application uses the theme-provided information.



Is this intended behavior?  I am just beginning to scratch the surface of theme and style-related stuff with GTK, but it seems to me that the behavior should be identical, regardless of how the style class is applied.

Thanks!
Comment 1 Michael Webster 2014-05-09 21:08:41 UTC
Hi - I'd like to work on fixing this.  I seem to run into the issue fairly often where I would have like to use these mechanisms.

I'd like to confirm this is actually a bug and not 'working as intended' for whatever reason.

Thanks
Comment 2 Benjamin Otte (Company) 2014-05-13 15:05:26 UTC
The issue with cascading (ie lower priority stylesheets) is that they aren't consulted if there is _any_ kind of definition in a higher priority stylesheet. So specificity doesn't matter at all.

That means if a theme has this:

* {
  padding: 0px;
}

you will not be able to override padding at all in a lower priority theme. This is not pripority specific, this is strictly about which style provider is loaded first by GTK.

I have no idea if that's the issue you're running into, your example wasn't clear enough for that. I just wanted to point it out.


This is btw why I consider this whole approach of shipping custom CSS with lower priority and relying on the cascade a pretty futile approach that won't work.
Comment 3 Matthias Clasen 2014-05-13 15:47:07 UTC
After, irc discussion, I added a documentation clarification. Going to close this