Skip to content

Commit

Permalink
Use Granite.Settings
Browse files Browse the repository at this point in the history
  • Loading branch information
meisenzahl committed Apr 10, 2021
1 parent f0737dd commit a2da4bb
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 42 deletions.
36 changes: 4 additions & 32 deletions src/AccentColor/AccentColorManager.vala
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,9 @@
private const string STYLESHEET_PREFIX = "io.elementary.stylesheet.";
private const string TAG_ACCENT_COLOR = "Xmp.xmp.io.elementary.AccentColor";

private Gala.AccountsService? gala_accounts_service = null;

private Settings background_settings;
private Settings interface_settings;
private Granite.Settings granite_settings;

private NamedColor[] theme_colors = {
new NamedColor () {
Expand Down Expand Up @@ -86,43 +85,16 @@
construct {
background_settings = new Settings ("org.gnome.desktop.background");
interface_settings = new Settings (INTERFACE_SCHEMA);

string? user_path = null;
try {
FDO.Accounts? accounts_service = GLib.Bus.get_proxy_sync (
GLib.BusType.SYSTEM,
"org.freedesktop.Accounts",
"/org/freedesktop/Accounts"
);

user_path = accounts_service.find_user_by_name (GLib.Environment.get_user_name ());
} catch (Error e) {
critical (e.message);
}

if (user_path != null) {
try {
gala_accounts_service = GLib.Bus.get_proxy_sync (
GLib.BusType.SYSTEM,
"org.freedesktop.Accounts",
user_path
);

((DBusProxy)gala_accounts_service).g_properties_changed.connect (() => {
update_accent_color ();
});
} catch (Error e) {
warning ("Unable to get AccountsService proxy, accent color preference may be incorrect");
}
}
granite_settings = Granite.Settings.get_default ();

background_settings.changed["picture-uri"].connect (update_accent_color);
granite_settings.notify["prefers-accent-color"].connect (update_accent_color);

update_accent_color ();
}

private void update_accent_color () {
bool set_accent_color_based_on_wallpaper = gala_accounts_service.prefers_accent_color == 0;
bool set_accent_color_based_on_wallpaper = granite_settings.prefers_accent_color == Granite.Settings.AccentColor.NO_PREFERENCE;

if (set_accent_color_based_on_wallpaper) {
var picture_uri = background_settings.get_string ("picture-uri");
Expand Down
9 changes: 0 additions & 9 deletions src/GalaAccountsServicePlugin.vala

This file was deleted.

1 change: 0 additions & 1 deletion src/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ gala_bin_sources = files(
'DBus.vala',
'DBusAccelerator.vala',
'DockThemeManager.vala',
'GalaAccountsServicePlugin.vala',
'InternalUtils.vala',
'KeyboardManager.vala',
'Main.vala',
Expand Down

0 comments on commit a2da4bb

Please sign in to comment.