Skip to content

Commit

Permalink
Init: set accent color from portal feedback (#722)
Browse files Browse the repository at this point in the history
  • Loading branch information
ryonakano authored Jun 16, 2024
1 parent 8ee30d8 commit feaad3f
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions lib/Widgets/Settings.vala
Original file line number Diff line number Diff line change
Expand Up @@ -124,29 +124,27 @@ namespace Granite {
"accent-color"
).get_variant ();

update_color (variant);
accent_color = parse_color (variant);

portal.setting_changed.connect ((scheme, key, value) => {
if (scheme == "org.freedesktop.appearance" && key == "accent-color") {
update_color (value);
accent_color = parse_color (value);
}
});

return;
} catch (Error e) {
debug (e.message);
}
warning (e.message);

// Set a default in case we can't get from system
accent_color = "#3689e6";
// Set a default in case we can't get from system
accent_color = "#3689e6";
}
}

private void update_color (GLib.Variant color) {
private string parse_color (GLib.Variant color) {
double red, green, blue;
color.get ("(ddd)", out red, out green, out blue);

Gdk.RGBA rgba = {(float) red, (float) green, (float) blue, 1};
accent_color = rgba.to_string ();
return rgba.to_string ();
}

private void setup_prefers_color_scheme () {
Expand Down

0 comments on commit feaad3f

Please sign in to comment.