The development version of gedit now has a much more complete support of light and dark themes, and switching between them from the desktop setting.
How it looks
With the Solarized Dark color scheme for the main text area, and the Adwaita dark GTK theme:
The Preferences dialog:
Possibilities and limitations
It's possible to follow the system style (the desktop-wide setting that is applied to all the applications at once), or to force the light or dark theme variant.
For the main text area a color scheme must be applied. There are thus two color schemes to choose: for the light versus dark theme variants, to automatically switch the color scheme.
The Preferences dialog also allows you to choose a dark color scheme when a light theme variant is in effect, or vice-versa. If this was not possible, it would have been annoying to some people.
There is however a minor limitation: the Classic and Tango
color schemes are supported only with the light theme variant, because some
colors are inherited from the theme and the other colors have been defined
with a light theme in mind (see
this issue on GitLab
with a screenshot of the text being unreadable).
So when the dark theme is applied, it is not possible to select Classic or
Tango and their descriptions become "Unsupported for the dark theme variant"
(by the way, it's better to keep them in the list and show an explanation; if
Classic and Tango suddenly disappear from the list, you would have thought
that there is a bug somewhere).
It is also documented in the user manual, if you're curious.
Technical details
The heavy-lifting is done by libhandy, and the actual dark theme (the Adwaita one) comes from GTK and its CSS engine.
Some work was left to do in libgedit-gtksourceview for the color/style schemes; in libgedit-tepl for the components in the Preferences dialog plus a few other things; and finally in gedit to integrate what libgedit-tepl provides.
In gedit there are now two GSettings keys for the color schemes, plus another
key for the theme-variant, as can be seen in this dconf watch
demo session:
$ dconf watch / /org/gnome/gedit/preferences/editor/style-scheme-for-dark-theme-variant 'oblivion' /org/gnome/gedit/preferences/ui/theme-variant 'light' /org/gnome/gedit/preferences/editor/style-scheme-for-light-theme-variant 'classic'
Conclusion
This feature was asked by many people and it's finally there. It will be available in gedit 48, the next stable version to be released soon if everything goes well.
Do not hesitate to get in touch and provide a feedback, be it for this feature or for other things.
This article was written by Sébastien Wilmet, currently the main gedit developer.