mirror of
https://github.com/elementary/gala.git
synced 2024-08-17 11:00:28 +03:00
Use dark wallpaper (#1709)
Co-authored-by: Danielle Foré <danielle@elementary.io>
This commit is contained in:
parent
6f38ee7464
commit
0de3128cff
@ -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 ();
|
||||
|
Loading…
Reference in New Issue
Block a user