-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixed a regression where Linux theme is not properly detected #1382
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good at a first glance. You should be able to remove the Gio initialization though.
I will try to test your change on my hardware and report back.
@@ -31,6 +31,7 @@ internal partial class LinuxProgram | |||
|
|||
internal LinuxProgram() | |||
{ | |||
Gio.Module.Initialize(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can remove this line. This is part of the sample as the Gio.Module is not initialized automatically.
For Libadwaita and GTK applications this is done automatically via the Gtk.Application
class for all GTK dependencies including Gio.
- Gtk.Application calls
Gtk.Module.Initialize
Gtk.Module.Initialize
calls Gdk.Module.InitializeGdk.Module.Initialze
calls Gio.Module.Initialize
@CodedOre Thanks for testing then I will skip the testing on my side. Making the title bar dark should be possible, too. |
Looking through the docs, I think setting the Though I haven't tried that yet. |
@CodedOre Yes this works, tested on fedora 40 with: var application = Gtk.Application.New("org.gir.core", Gio.ApplicationFlags.FlagsNone);
application.OnActivate += (sender, args) =>
{
var window = Gtk.ApplicationWindow.New((Gtk.Application) sender);
window.Title = "Gtk4 Window";
window.SetDefaultSize(300, 300);
window.GetSettings().GtkApplicationPreferDarkTheme = true;
window.Show();
};
return application.RunWithSynchronizationContext(null); So setting @veler It should work if you use the |
I think I think it is more meant as an "application level setting" defining the developers preference of either a dark or light theme. E.g. in GNOME there are apps, which use a dark theme, even if the user chooses to have a light theme. This is the case for media related apps like video players. I think those apps set this setting to indicate that they prefer a dark theme over the user choise. And If your code detects, the user wants to use a dark theme you set this property to true to adhere to the users wish resulting in a dark titlebar. |
@veler Are you aware that the dbus call might fail regularly in case of old distributions (API not available). In those cases you would not check the GTK theme currently. |
Hey everyone! Thank you all for your feedback, it's super helpful :) |
Alright, I finally got Fedora to work! I'm happy to take suggestions, otherwise I kind of happy with the current state too. I know it's not perfect but it's not a blocking issue. |
Which edition of Fedora did you install? Because the Settings portal, like the other XDG desktop portals, depend on a implementation in the desktop to provide the information. Gnome and Elementary have implemented the new portal, as well as KDE (partially at least). |
I did just check with my Fedora desktop (to be precise, Fedora Silverblue with the Gnome desktop), and it does work fine and is indeed using the portal. |
@veler you could double check if you use "D-Spy" to execute the call to the portal interface manually like I showed in the screenshot. Perhaps you really have some variant / version which does not have this feature available? |
Hey there, I made a virtual machine of Am I understanding correctly it finds "1" ? Also, when I switch the theme to Default, then the value is "0". |
The values from the settings portal looks right to me. If you look at the portal documentation, the value 1 stands for dark mode, while 0 for "no preference". The reason Gnome sets "no preference" instead of "prefer light" on the default setting is that some apps on default would prefer to be dark (like image viewers), while most apps use light as default. |
So, I so notice that as of now, on the default setting the app uses the fallback. So, this could be improved by calling the fallback if the DBus call returns an error (like when it did not find the portal). |
Pull request type
Please check the type of change your PR introduces:
What is the current behavior?
Issue Number: #1381
What is the new behavior?
Use DBus to retrieve the
org.freedesktop.appearance
parameter to detect the theme on Linux Mint, Ubuntu, Fedora.Other information
Quality check
Before creating this PR: