Use dark wallpaper (#1709)

Co-authored-by: Danielle Foré <danielle@elementary.io>
This commit is contained in:
Leo 2023-07-19 05:19:07 +09:00 committed by GitHub
parent 6f38ee7464
commit 0de3128cff
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -23,6 +23,7 @@ namespace Gala {
"picture-opacity",
"picture-options",
"picture-uri",
"picture-uri-dark",
"primary-color",
"secondary-color"
};
@ -67,6 +68,9 @@ namespace Gala {
}
}
});
unowned var granite_settings = Granite.Settings.get_default ();
granite_settings.notify["prefers-color-scheme"].connect (() => changed ());
}
private void monitors_changed () {
@ -91,11 +95,7 @@ namespace Gala {
var style = settings.get_enum ("picture-options");
if (style != GDesktop.BackgroundStyle.NONE) {
var uri = settings.get_string ("picture-uri");
if (Uri.parse_scheme (uri) != null)
filename = File.new_for_uri (uri).get_path ();
else
filename = uri;
filename = get_background_path ();
}
// Animated backgrounds are (potentially) per-monitor, since
@ -114,6 +114,24 @@ namespace Gala {
return backgrounds[monitor_index];
}
private string get_background_path () {
if (Granite.Settings.get_default ().prefers_color_scheme == DARK) {
var uri = settings.get_string ("picture-uri-dark");
var path = File.new_for_uri (uri).get_path ();
if (FileUtils.test (path, EXISTS)) {
return path;
}
}
var uri = settings.get_string ("picture-uri");
var path = File.new_for_uri (uri).get_path ();
if (FileUtils.test (path, EXISTS)) {
return path;
}
return uri;
}
private void background_changed (Background background) {
background.changed.disconnect (background_changed);
background.destroy ();