diff options
author | Robert Ancell <robert.ancell@canonical.com> | 2013-02-08 11:57:39 +1300 |
---|---|---|
committer | Robert Ancell <robert.ancell@canonical.com> | 2013-02-08 11:57:39 +1300 |
commit | 5ab20c16591d13dff5cf3b41f98ae46bfd6e2fa2 (patch) | |
tree | 1e801ad7456601423af6ed45f60f7478f4a976ff /src | |
parent | 4643e1008371882190c7dcc3dfcec12d6008152b (diff) | |
download | ayatana-indicator-bluetooth-5ab20c16591d13dff5cf3b41f98ae46bfd6e2fa2.tar.gz ayatana-indicator-bluetooth-5ab20c16591d13dff5cf3b41f98ae46bfd6e2fa2.tar.bz2 ayatana-indicator-bluetooth-5ab20c16591d13dff5cf3b41f98ae46bfd6e2fa2.zip |
Support existing gsettings key to disable indicator
Diffstat (limited to 'src')
-rw-r--r-- | src/indicator-bluetooth-service.vala | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/src/indicator-bluetooth-service.vala b/src/indicator-bluetooth-service.vala index 21ac4e5..ac84f33 100644 --- a/src/indicator-bluetooth-service.vala +++ b/src/indicator-bluetooth-service.vala @@ -10,6 +10,7 @@ public class BluetoothIndicator { + private Settings settings; private DBusConnection bus; private Indicator.Service indicator_service; private Dbusmenu.Server menu_server; @@ -26,6 +27,13 @@ public class BluetoothIndicator public BluetoothIndicator () throws Error { + settings = new Settings ("com.canonical.indicator.bluetooth"); + settings.changed.connect ((key) => + { + if (key == "visible") + update_visible (); + }); + bus = Bus.get_sync (BusType.SESSION); indicator_service = new Indicator.Service ("com.canonical.indicator.bluetooth"); @@ -117,9 +125,9 @@ public class BluetoothIndicator killswitch_state_changed_cb (killswitch.state); - client.adapter_model.row_inserted.connect (adapters_changed_cb); - client.adapter_model.row_deleted.connect (adapters_changed_cb); - adapters_changed_cb (); + client.adapter_model.row_inserted.connect (update_visible); + client.adapter_model.row_deleted.connect (update_visible); + update_visible (); } private BluetoothMenuItem? find_menu_item (string address) @@ -176,9 +184,9 @@ public class BluetoothIndicator item.update (type, proxy, alias, icon, connected, services, uuids); } - private void adapters_changed_cb () + private void update_visible () { - bluetooth_service._visible = client.adapter_model.iter_n_children (null) > 0; + bluetooth_service._visible = client.adapter_model.iter_n_children (null) > 0 && settings.get_boolean ("visible"); var builder = new VariantBuilder (VariantType.ARRAY); builder.add ("{sv}", "Visible", new Variant.boolean (bluetooth_service._visible)); try |