Skip to content

Conversation

@tpikonen
Copy link
Contributor

Add 'ui.gtk.color_scheme' config variable with 'system', 'light' and 'dark' string values. Config observer in main.py changes the color to match the config.

System color scheme is read from freedesktop.org Settings portal via Dbus.

The setting can be changed with a combo box in the preferences window via new function connect_gtk_combo_box_text().

This fixes issue #1194, but only on Linux and with the Settings portal running.

@auouymous
Copy link
Member

It throws an exception for me
AttributeError: 'SessionBus' object has no attribute 'call_async'

And linux users without that portal, mac users and windows users will all see a non-functional setting in preferences, right?

@tpikonen
Copy link
Contributor Author

It throws an exception for me AttributeError: 'SessionBus' object has no attribute 'call_async'

Are you perhaps using the fake dbus module? I'll add a dummy call_async method there, so this should work.

And linux users without that portal, mac users and windows users will all see a non-functional setting in preferences, right?

The 'System' setting will not work in this case, but forcing the light and dark modes should work. This could be either left as is, or a non-compatible platform (fake dbus, windows, mac) could be detected and the system setting removed in that case.

@tpikonen tpikonen force-pushed the portal-settings-dark-mode branch from 842666a to c7529ee Compare December 29, 2023 09:54
@auouymous
Copy link
Member

Yes, I am using fake dbus. The setting should be removed for anyone who can't use it, otherwise we will get a lot of reports that it doesn't work.

@tpikonen tpikonen force-pushed the portal-settings-dark-mode branch from c7529ee to 2d12095 Compare January 2, 2024 13:59
@tpikonen
Copy link
Contributor Author

tpikonen commented Jan 2, 2024

This should now have better chances of working without Dbus or Settings portal. There are 3 kinds of platforms this should work in:

  1. With Dbus and Settings portal running
  2. With Dbus, but without Settings portal
  3. Without Dbus

In the last two cases the 'system' color scheme is interpreted as 'light' and the config key is also changed to 'light' in preferences window initialization. Unfortunately I can easily test only the case where Settings are available.

@auouymous
Copy link
Member

So there is no way to detect gtk-application-prefer-dark-theme in settings.ini to set the default? It ignored my preference and started up in light mode, however, changing the new setting in gpodder did work and did persist across gpodder restarts.

I haven't yet reviewed the patch, but I would like to verify it works on Windows and Mac. If only PRs produced Mac builds, because the Windows build is currently not working.

@tpikonen
Copy link
Contributor Author

tpikonen commented Jan 3, 2024

So there is no way to detect gtk-application-prefer-dark-theme in settings.ini to set the default?

It's probably not possible to detect that this setting is set in the GTK config file (or not).

It can be read at startup and set as default, but it would require an extra 'unset' state in the config key, so that it would only be made once. But this should only be made when a portal is not found, since the default in that case should be the 'system' setting.

@auouymous
Copy link
Member

it would require an extra 'unset' state in the config key

Assuming it is even possible to detect the value, the config key could default to None, and that value triggers the detection.

Add 'ui.gtk.color_scheme' config variable with 'system', 'light' and
'dark' string values. Config observer in main.py changes the color to
match the config.

System color scheme is read from freedesktop.org Settings portal via
Dbus.

The setting can be changed with a combo box in the preferences window
via new function connect_gtk_combo_box_text(). If Settings portal cannot
be found, only 'light' and 'dark' options are available in preferences.
@tpikonen tpikonen force-pushed the portal-settings-dark-mode branch from 2d12095 to 92244d6 Compare January 4, 2024 09:51
@tpikonen
Copy link
Contributor Author

tpikonen commented Jan 4, 2024

Assuming it is even possible to detect the value, the config key could default to None, and that value triggers the detection.

Good idea. Now this detects a non-default dark mode GtkSetting and uses it as default. The whole thing got a bit too complex for my taste, but at least it's backwards compatible.

@auouymous
Copy link
Member

Works for me. The only problem is that it starts up briefly in the system color before it switches to the preference in gpodder. However, there is most likely no way around this, and anyone who can't easily configure 'settings.ini' probably won't mind a short white flash to get dark mode.

I'll review the patch tomorrow.

@auouymous auouymous merged commit f6de1b9 into gpodder:master Jan 23, 2024
@auouymous
Copy link
Member

Thanks for implementing this.

@ushuc
Copy link

ushuc commented Dec 21, 2024

Great addition to gPodder, thanks a lot!

I have some ideas regarding this:

  • System theme detection: Is it possible to add a third entry like "OS setting" (or something like that) to the theme selection list in addition to dark/light? This way gPodder would detect on startup if the OS's theme is set to dark or light mode and adapt accordingly.
  • Contrast refinement (see screenshot): The contrast of the purely white text is quite high in comparison to the dark background. Not easy on the eyes, I think. I would suggest that the text could me more kind of a mid grey color. Like midway between plain white and the grey color of the column title.

grafik

@auouymous
Copy link
Member

* System theme detection: Is it possible to add a third entry like "OS setting" (or something like that) to the theme selection list in addition to dark/light?

Are you using Mac or Windows? The Linux build should have a system option, but Mac and Windows builds do not since gtk's settings is inside the build and probably difficult to edit. We also can't easily access a system setting on Mac and Windows without platform code for each one.

* Contrast refinement (see screenshot): The contrast of the purely white text is quite high in comparison to the dark background. Not easy on the eyes, I think. I would suggest that the text could me more kind of a mid grey color. Like midway between plain white and the grey color of the column title.

That is only possible by changing gtk's theme, on Linux. Mac and Windows users are stuck with the Adwaita theme included in the build.

@ushuc
Copy link

ushuc commented Dec 21, 2024

Thx for the background information. I am on Windows.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants