Improve light/dark theme support with OS preferences lookup
Followup of #8509 (closed), but moved to GIMP 3.2 milestone, because it's not a priority right now and our dark theme support works quite OK so far.
Basically Freedesktop now has an API for light/dark style preferences:
- Page on GNOME wiki. Since we don't plan to use libadwaita or libhandy so far, the section of interest is the other section which has some useful C code sample to get inspired from.
- Some blog post
- Some other blog post
We should study a bit the rationale. I say this in particular as what is particularly interesting is that this is a 3-state settings: prefer-light, prefer-dark and default (I also wonder if there were cases where someone might set their OS to dark, but might want exceptionally GIMP to be light? Right now, this is not possible, but with such setting, it would). Yet in the second blog post, they say:
Similarly, when communicating this preference to users, it likely shouldn’t be a choice between “light” and “dark.” Instead, it should be phrased as “prefer dark style” or similar.
Which kinda contradicts the 3-state logic. So we should look further on it.
Also there is the discussion about whether GIMP should follow the system settings as a default, or stay dark by default. Typically in the GNOME wiki link, their second case is:
Apps that didn't have a preference but used dark appearance by default (e.g. Photos or Videos) should be dark unless the system prefers light appearance, such as for the high contrast mode. […]
Lastly, we should look how to set the theme to "prefer light". It's not clear to me how it's done with GTK+3 themes (the sample explains how to get the FD setting, not how to apply it to GTK themes). We have a trick to prefer the dark theme, not one to prefer the light themes (unlike for instance libadwaita where they apparently have a ADW_COLOR_SCHEME_FORCE_LIGHT
).
Some TODOs:
-
Study the Freedesktop settings rationale. -
Check how to force/prefer light theme with GTK+3 themes. -
Decide what should be GIMP default behavior regarding theme. -
Check how similar settings are handled in other OSes, and implement if possible at least a similar logic with macOS and Windows API (apparently they both have similar OS settings, though it might not be a 3-state, maybe it's just prefer-dark
vs default for these).