Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 23 additions & 5 deletions src/Background/BackgroundSource.vala
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ namespace Gala {
"picture-opacity",
"picture-options",
"picture-uri",
"picture-uri-dark",
"primary-color",
"secondary-color"
};
Expand Down Expand Up @@ -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 () {
Expand All @@ -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
Expand All @@ -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 ();
Expand Down