From 9b1b2bc0ce96c5bbc367e3256b27665a5ed09f65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Tue, 17 Jun 2025 14:05:27 -0700 Subject: [PATCH] Use settings from Daemon --- data/gschema.xml | 10 ---------- data/meson.build | 6 ------ src/Services/Manager.vala | 11 ++--------- src/Widgets/DisplayWidget.vala | 4 ++-- src/Widgets/PopoverWidget.vala | 11 ++--------- 5 files changed, 6 insertions(+), 36 deletions(-) delete mode 100644 data/gschema.xml diff --git a/data/gschema.xml b/data/gschema.xml deleted file mode 100644 index 495cdc33..00000000 --- a/data/gschema.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - true - Sets the last bluetooth state to re-apply on reboot - - - - diff --git a/data/meson.build b/data/meson.build index af8e63ca..eda08257 100644 --- a/data/meson.build +++ b/data/meson.build @@ -6,9 +6,3 @@ i18n.merge_file( install: true, install_dir: datadir / 'metainfo' ) - -install_data( - 'gschema.xml', - rename: 'io.elementary.desktop.wingpanel.bluetooth.gschema.xml', - install_dir: datadir / 'glib-2.0' / 'schemas' -) diff --git a/src/Services/Manager.vala b/src/Services/Manager.vala index 15f3c32b..3ac9f873 100644 --- a/src/Services/Manager.vala +++ b/src/Services/Manager.vala @@ -28,7 +28,7 @@ public class BluetoothIndicator.Services.ObjectManager : Object { public bool is_connected {get; private set; default = false; } construct { - settings = new Settings ("io.elementary.desktop.wingpanel.bluetooth"); + settings = new Settings ("io.elementary.desktop.bluetooth"); create_manager.begin (); } @@ -53,13 +53,6 @@ public class BluetoothIndicator.Services.ObjectManager : Object { object_manager.object_removed.connect ((object) => { object.get_interfaces ().foreach ((iface) => on_interface_removed (object, iface)); }); - - settings.changed["bluetooth-enabled"].connect (() => { - var enabled = settings.get_boolean ("bluetooth-enabled"); - if (enabled != this.is_powered) { - set_state_from_settings.begin (); - } - }); } catch (Error e) { critical (e.message); } @@ -230,7 +223,7 @@ public class BluetoothIndicator.Services.ObjectManager : Object { } public async void set_state_from_settings () { - yield set_global_state (settings.get_boolean ("bluetooth-enabled")); + yield set_global_state (settings.get_boolean ("enabled")); } public static bool compare_devices (Device device, Device other) { diff --git a/src/Widgets/DisplayWidget.vala b/src/Widgets/DisplayWidget.vala index 545e7ae4..ecb438e6 100644 --- a/src/Widgets/DisplayWidget.vala +++ b/src/Widgets/DisplayWidget.vala @@ -45,8 +45,8 @@ public class BluetoothIndicator.Widgets.DisplayWidget : Gtk.Bin { }; gesture_click.pressed.connect (() => { object_manager.settings.set_boolean ( - "bluetooth-enabled", - !object_manager.settings.get_boolean ("bluetooth-enabled") + "enabled", + !object_manager.settings.get_boolean ("enabled") ); }); } diff --git a/src/Widgets/PopoverWidget.vala b/src/Widgets/PopoverWidget.vala index 9209cb5a..297b00b2 100644 --- a/src/Widgets/PopoverWidget.vala +++ b/src/Widgets/PopoverWidget.vala @@ -29,9 +29,7 @@ public class BluetoothIndicator.Widgets.PopoverWidget : Gtk.Box { construct { orientation = VERTICAL; - main_switch = new Granite.SwitchModelButton (_("Bluetooth")) { - active = object_manager.get_global_state () - }; + main_switch = new Granite.SwitchModelButton (_("Bluetooth")); main_switch.get_style_context ().add_class (Granite.STYLE_CLASS_H4_LABEL); devices_list = new Gtk.ListBox (); @@ -72,8 +70,6 @@ public class BluetoothIndicator.Widgets.PopoverWidget : Gtk.Box { add (show_settings_button); } - main_switch.active = object_manager.get_global_state (); - update_ui_state (object_manager.get_global_state ()); show_all (); @@ -81,10 +77,7 @@ public class BluetoothIndicator.Widgets.PopoverWidget : Gtk.Box { ((Widgets.Device) row).toggle_device.begin (); }); - main_switch.notify["active"].connect (() => { - warning ("main switch toggle - active %s", main_switch.active.to_string ()); - object_manager.settings.set_boolean ("bluetooth-enabled", main_switch.active); - }); + object_manager.settings.bind ("enabled", main_switch, "active", DEFAULT); show_settings_button.clicked.connect (() => { try {