Why and how libadwaita prevents theming?

  1. Yes, the stylesheets are built into the .so binary. This because the stylesheets are part of the API, you should not change them randomly because doing so will break apps.
  2. Yes, same as answer 1.
  3. It does not actually unload any other stylesheets but instead it changes the default stylesheet to an empty one. Then it loads the appropriate Adwaita stylesheets on top of it according to the current user preference (dark mode, high contrast, etc). To achieve this it calls gtk_style_context_add_provider_for_display to load and gtk_style_context_remove_provider_for_display to unload stylesheets. If you switch between dark mode and high contrast then libadwaita will call these functions many times at runtime. Any app can call also these functions to load and unload stylesheets at any time. They can be called in response to mode/contrast changes but also in response to anything else the app developer desires.
  4. Realistically no, because then the apps will have no styles and they will look and behave badly. If you really want to see what happens you can comment out the line that loads the stylesheet and rebuild libadwaita, and you will see the breakage.

Edit: BTW, I just remember one other thing. Another way to change the gtk-theme-name setting without recompiling is to open GTK Inspector (Ctrl+Shift+I or Ctrl+Shift+D) and go to Global → Settings → GTK Theme. Though this also is pretty much only useful for testing non-libadwaita apps, it is practically guaranteed to break Adwaita apps.

2 Likes