Subject: bug#53457: 29.0.50; pgtk: [Request] Expose GtkSettings to emacs

From: Po Lu <[email-masked]>
Date: Tue, 25 Jan 2022 15:21:22 +0800

[I didn't notice you forgot to CC the bug tracker earlier.  Please use
"Reply All" to reply, so that the bug tracker stays copied in.]

Maximiliano Sandoval <[email-masked]> writes:

>> Not what I recall, where the GTK developers say libadwatia (not
>> individual applications) is supposed to set a dark stylesheet if the
>> user wants to use one.

>> The right way to enable a dark stylesheet is to open GNOME Tweaks, and
>> set the stylesheet to "Adwatia Dark".

> These two affirmations are not correct.

[..]

> Applications which want to follow the GNOME human interface guidelines
> can make use of libhandy in GTK 3 (where they have to explicitly
> opt-in to follow the user preference) or libadwaita in GTK 4. These
> libraries will listed to the dbus for changes of the
> xdg-desktop-portal backed setting and refresh the stylesheet
> accordingly. Libhandy in fact uses "gtk-application-prefer-dark-theme"
> internally to set dark mode [1].
>
> Only when using lib{handy,adwaita}, the
> "gtk-application-prefer-dark-theme" setting should not be used at all,
> since it conflicts with the user preference.
>
> Emacs is not an application targeting the GNOME environment therefore
> it should probably not use either of these libraries. The way forward
> is to either take care of these steps or provide the tools for the
> users to do it.

That suggests the way forward is to provide a build option which will
let Emacs utilize libhandy, or libadwatia, for the people who use GNOME
and are willing to listen to whatever GNOME tells them.

> Right now it is not possible to declare that Emacs should use a dark
> stylesheet.

No, it is possible.  The proper solution is to tell GTK to use a dark
theme, through either GNOME Tweaks or by using gsettings manually, both
of which are not "hacks".

The latter option is explictly supported by the GTK developers.  The
former is not, but it is in use by so many people (many more than the
people using desktop environments which have added support for this new
XDG protocol, none of which have been released yet), that it's hard to
imagine it going away any time soon.

> In short the "Adwaita-dark" setting in gnome-tweaks is a hack that
> will only cause conflicts with the user's preference and is
> incompatible with time based scheduling for dark mode.

Why would it be incompatible with such a feature?

Thanks.