GtkApplication style does not seem to be applied


In my application, I set an application level CSS stylesheet using the method described under “Custom CSS” at

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:


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.