From 47f546f13782e0f3a6501b38d8e02d3f0f7e32e6 Mon Sep 17 00:00:00 2001 From: lenemter Date: Wed, 14 May 2025 12:34:17 +0300 Subject: [PATCH 1/2] Settings: remove AccountsService fallback --- lib/Widgets/Settings.vala | 66 +-------------------------------------- 1 file changed, 1 insertion(+), 65 deletions(-) diff --git a/lib/Widgets/Settings.vala b/lib/Widgets/Settings.vala index 67bfb061b..f0a5b0138 100644 --- a/lib/Widgets/Settings.vala +++ b/lib/Widgets/Settings.vala @@ -4,16 +4,6 @@ */ namespace Granite { - [DBus (name = "io.elementary.pantheon.AccountsService")] - private interface Pantheon.AccountsService : Object { - public abstract int prefers_color_scheme { get; set; } - } - - [DBus (name = "org.freedesktop.Accounts")] - interface FDO.Accounts : Object { - public abstract string find_user_by_name (string username) throws GLib.Error; - } - /** * Granite.Settings provides a way to share Pantheon desktop settings with applications. */ @@ -59,9 +49,6 @@ namespace Granite { /** * Whether the user would prefer if apps use a dark or light color scheme or if the user has expressed no preference. - * - * To access this from a Flatpak application, add an entry with the value `'--system-talk-name=org.freedesktop.Accounts'` - * in the `finish-args` array of your Flatpak manifest. */ public ColorScheme prefers_color_scheme { get { @@ -75,19 +62,6 @@ namespace Granite { } } - private string? _user_path = null; - private string user_path { - get { - if (_user_path == null) { - setup_user_path (); - } - return _user_path; - } - private set { - _user_path = value; - } - } - private static GLib.Once instance; public static unowned Granite.Settings get_default () { return instance.once (() => { @@ -95,26 +69,10 @@ namespace Granite { }); } - private FDO.Accounts? accounts_service = null; - private Pantheon.AccountsService? pantheon_act = null; private Portal.Settings? portal = null; private Settings () {} - private void setup_user_path () { - try { - 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); - } - } - private void setup_accent_color () { try { if (portal == null) { @@ -167,30 +125,8 @@ namespace Granite { prefers_color_scheme = (ColorScheme) value.get_uint32 (); } }); - return; - } catch (Error e) { - debug ("cannot use the portal, using the AccountsService: %s", e.message); - } - - try { - pantheon_act = GLib.Bus.get_proxy_sync ( - GLib.BusType.SYSTEM, - "org.freedesktop.Accounts", - user_path, - GLib.DBusProxyFlags.GET_INVALIDATED_PROPERTIES - ); - - prefers_color_scheme = (ColorScheme) pantheon_act.prefers_color_scheme; - - ((GLib.DBusProxy) pantheon_act).g_properties_changed.connect ((changed, invalid) => { - var color_scheme = changed.lookup_value ("PrefersColorScheme", new VariantType ("i")); - if (color_scheme != null) { - prefers_color_scheme = (ColorScheme) color_scheme.get_int32 (); - } - }); - return; } catch (Error e) { - critical (e.message); + debug ("cannot use the portal: %s", e.message); } // Set a default in case we can't get from system From 8a121636b0f7e4f15f7d9d547e94c7136e2745bd Mon Sep 17 00:00:00 2001 From: lenemter Date: Wed, 14 May 2025 12:35:38 +0300 Subject: [PATCH 2/2] Update copyright year --- lib/Widgets/Settings.vala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Widgets/Settings.vala b/lib/Widgets/Settings.vala index f0a5b0138..a2049659d 100644 --- a/lib/Widgets/Settings.vala +++ b/lib/Widgets/Settings.vala @@ -1,5 +1,5 @@ /*- - * Copyright 2021 elementary, Inc. (https://elementary.io) + * Copyright 2021-2025 elementary, Inc. (https://elementary.io) * SPDX-License-Identifier: LGPL-2.1-or-later */