Sync dark theme preference for GTK3 applications
ClosedPublic

Authored by gikari on Dec 13 2019, 12:37 PM.

Details

Summary

Previously preference of dark GTK3 theme was set by checkbox in GTK KCM. Now, the checkbox is removed and preference is set according to color scheme, the user set in Colors KCMm, using the same heuristic, used for filter combobox in that KCM.

This makes sense, because, suppose the user set Adwaita GTK3 theme, and their color scheme is something dark. Therefore their overall theme is supposedly dark, so Adwaita needs to be dark too.

Note, however, that this preference is somewhat buggy. It does not work in flatpak apps, it can't be autoreloaded with xsettingsd, and also it is applied after some time has passed (this is hypothetical). You can check these statements, using the present checkbox in GTK KCM.

Depends on D25872

Test Plan

  1. Apply Adwaita GTK3 Theme
  2. Reload kded5
  3. Apply dark color scheme
  4. Wait some time
  5. (Re)open GTK3 app
  6. App should use Dark color scheme
  7. Apply light color scheme
  8. Wait some time
  9. Reopen GTK3 app
  10. App should use Light color scheme

Diff Detail

Repository
R99 KDE Gtk Configuration Tool
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
gikari created this revision.Dec 13 2019, 12:37 PM
Restricted Application added a project: Plasma. · View Herald TranscriptDec 13 2019, 12:37 PM
Restricted Application added a subscriber: plasma-devel. · View Herald Transcript
gikari requested review of this revision.Dec 13 2019, 12:37 PM
gikari edited the test plan for this revision. (Show Details)Dec 13 2019, 12:38 PM
gikari added a reviewer: VDG.
GB_2 added a subscriber: GB_2.Dec 14 2019, 4:14 PM

Works perfectly fine for me without waiting.

cblack accepted this revision.Dec 14 2019, 4:30 PM

Code looks fine to me.

For flatpaks not respecting the setting preference, have you checked that the dark theme variant is installed? f-d-o runtime doesn't offer an Adwaita-dark stub, while GNOME runtime does.

As for xsettingsd, I'm not sure if it synchronises the dark theme preference. That doesn't appear to be in the xsettings spec afaik.

This revision is now accepted and ready to land.Dec 14 2019, 4:30 PM

For flatpaks not respecting the setting preference, have you checked that the dark theme variant is installed?

Yes, I have installed the theme. But after changing the value in gtk configs nothing happens. It could also be the result of my local setup bugs (because as the @GB_2 said, the patch works for him flawlessly). So I think he (or someone else) should test it.

There is a bug about flatpak not using selected GTK theme on X11. It is because it can only be done by letting the xsettingd to control the theme of the flatpak app. So, to test dark-theme preference sync you need to add to the ~/.config/xsettingsd/xsettingsd.conf this line:

Net/ThemeName "Adwaita"

check the dark theme preference checkbox in old GTK KCM and then relaunch xsettingsd. The flatpak app should be dark.

GB_2 added a comment.Dec 17 2019, 6:35 PM

For flatpaks not respecting the setting preference, have you checked that the dark theme variant is installed?

Yes, I have installed the theme. But after changing the value in gtk configs nothing happens. It could also be the result of my local setup bugs (because as the @GB_2 said, the patch works for him flawlessly). So I think he (or someone else) should test it.

There is a bug about flatpak not using selected GTK theme on X11. It is because it can only be done by letting the xsettingd to control the theme of the flatpak app. So, to test dark-theme preference sync you need to add to the ~/.config/xsettingsd/xsettingsd.conf this line:

Net/ThemeName "Adwaita"

check the dark theme preference checkbox in old GTK KCM and then relaunch xsettingsd. The flatpak app should be dark.

No, looks like there is no way to make this option work for Flatpak apps, because it can't be set with xsettingsd.

apol accepted this revision.Dec 18 2019, 5:05 PM
gikari updated this revision to Diff 71806.Dec 18 2019, 5:18 PM

Rebase on master

@broulik do I need your revision to land this?

@apol is the maintainer and @broulik hasn't raised any objections, so I'd say you're good to go.

This revision was automatically updated to reflect the committed changes.