[gnome-shell] bluetooth: Use g-s-d to turn off Bluetooth



commit 981a536cb5ec8417a65271dd7299360c8e353fa4
Author: Bastien Nocera <hadess hadess net>
Date:   Tue Nov 26 14:06:41 2013 +0100

    bluetooth: Use g-s-d to turn off Bluetooth
    
    https://bugzilla.gnome.org/show_bug.cgi?id=719341

 js/ui/status/bluetooth.js |   22 +++++++++++++++++++++-
 1 files changed, 21 insertions(+), 1 deletions(-)
---
diff --git a/js/ui/status/bluetooth.js b/js/ui/status/bluetooth.js
index edcc04e..7a34f99 100644
--- a/js/ui/status/bluetooth.js
+++ b/js/ui/status/bluetooth.js
@@ -2,6 +2,7 @@
 
 const Clutter = imports.gi.Clutter;
 const GLib = imports.gi.GLib;
+const Gio = imports.gi.Gio;
 const GnomeBluetoothApplet = imports.gi.GnomeBluetoothApplet;
 const GnomeBluetooth = imports.gi.GnomeBluetooth;
 const Lang = imports.lang;
@@ -12,6 +13,17 @@ const MessageTray = imports.ui.messageTray;
 const PanelMenu = imports.ui.panelMenu;
 const PopupMenu = imports.ui.popupMenu;
 
+const BUS_NAME = 'org.gnome.SettingsDaemon.Rfkill';
+const OBJECT_PATH = '/org/gnome/SettingsDaemon/Rfkill';
+
+const RfkillManagerInterface = '<node> \
+<interface name="org.gnome.SettingsDaemon.Rfkill"> \
+<property name="BluetoothAirplaneMode" type="b" access="readwrite" /> \
+</interface> \
+</node>';
+
+const RfkillManagerProxy = Gio.DBusProxy.makeProxyWrapper(RfkillManagerInterface);
+
 const Indicator = new Lang.Class({
     Name: 'BTIndicator',
     Extends: PanelMenu.SystemIndicator,
@@ -22,12 +34,20 @@ const Indicator = new Lang.Class({
         this._indicator = this._addIndicator();
         this._indicator.icon_name = 'bluetooth-active-symbolic';
 
+        this._proxy = new RfkillManagerProxy(Gio.DBus.session, BUS_NAME, OBJECT_PATH,
+                                             Lang.bind(this, function(proxy, error) {
+                                                 if (error) {
+                                                     log(error.message);
+                                                     return;
+                                                 }
+                                             }));
+
         // The Bluetooth menu only appears when Bluetooth is in use,
         // so just statically build it with a "Turn Off" menu item.
         this._item = new PopupMenu.PopupSubMenuMenuItem(_("Bluetooth"), true);
         this._item.icon.icon_name = 'bluetooth-active-symbolic';
         this._item.menu.addAction(_("Turn Off"), Lang.bind(this, function() {
-            this._applet.killswitch_state = GnomeBluetooth.KillswitchState.SOFT_BLOCKED;
+            this._proxy.BluetoothAirplaneMode = true;
         }));
         this._item.menu.addSettingsAction(_("Bluetooth Settings"), 'gnome-bluetooth-panel.desktop');
         this.menu.addMenuItem(this._item);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]