Skip to content

Refactor loading CSS

Will Thompson requested to merge wip/wjt/style-contexts-oh-my into master

I noticed after merging !182 (merged) that it would load the CSS every time the account page is instantiated, not once per process.

It's harmless, as demonstrated by the fact that two other pages turn out to do the same thing.

Still:

  • Factor out some common code to load CSS from a resource path
  • Use it throughout
  • Consistently load CSS in class_init
  • Delete some unused CSS
  • Remove some useless g_resources_register calls

Thanks to Emmanuele Bassi and Bilal Elmoussaoui for their pointers, particularly libadwaita's automatic loading of per-application stylesheets. As noted in one of the commit messages:

This project keeps a number of CSS files next to the widgets they apply to. (You might expect from the current layout that they apply only to the page at hand, but in fact they are global.)

Libadwaita can automatically load certain resources, but not when arranged in this way. It may in future be desirable to centralize all CSS rules in one file, and namespace them better.

Merge request reports