GNOME Bugzilla – Bug 692379
Style providers added as GTK_STYLE_PROVIDER_PRIORITY_FALLBACK do not always provide fallback support
Last modified: 2014-05-13 15:47: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!
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
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.
After, irc discussion, I added a documentation clarification. Going to close this