GtkApplication style does not seem to be applied

Hi,

In my application, I set an application level CSS stylesheet using the method described under “Custom CSS” at
https://developer.gnome.org/CustomStyle/.

In my “custom.css” file I have the following rule:

.nopadding { padding: 0; }

and one of the buttons in my UI has the style “nopadding” added to it. However, when I compile the application, the button is still shown with a padding.

If I run the application with GTK_DEBUG=interactive, I can see that the button does have the class added to it:

button:prelight:backgrop:dir-ltr[1/2].nopadding

and I can also see under the “Resources” tab that my “custom.css” stylesheet is loaded as a resource.

What is even more interesting is that if I copy/paste the content of the “custom.css” file into the “CSS” tab of the interactive debugging, the button gets correctly formatted and the padding disappears.

Can someone help me understand why the style is not being applied through the resource file? Thank you.

I think I figured it out.

My application is using a composite object for the application that is derived from GtkApplication. I was initializing and setting the screen style provider in the application initialize callback when I should have been doing it in the activate callback. After switching the code around, it all works.

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.