[gnome-shell/wip/hadess/new-gnome-bluetooth: 2/2] status/bluetooth: Fix wedged state




commit 6e0a0f26b53c0257aa9f4ff3bff517d0ae25fbb8
Author: Bastien Nocera <hadess hadess net>
Date:   Tue Jan 18 11:14:47 2022 +0100

    status/bluetooth: Fix wedged state
    
    Fix a state where toggling the main Bluetooth switch in the header will
    always show the "Bluetooth Off" menu header with "Turn Off" as the only
    option.
    
    To reproduce, with Bluetooth enabled and working, run
    "hciconfig hci0 down" as root, and check the status menu.
    
    See gnome-bluetooth!102 and gnome-control-center!1148
    
    Fixes: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/4857

 js/ui/status/bluetooth.js | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
---
diff --git a/js/ui/status/bluetooth.js b/js/ui/status/bluetooth.js
index 3e49a5591d..8d6577b23f 100644
--- a/js/ui/status/bluetooth.js
+++ b/js/ui/status/bluetooth.js
@@ -25,6 +25,7 @@ class Indicator extends PanelMenu.SystemIndicator {
         this._indicator = this._addIndicator();
         this._indicator.icon_name = 'bluetooth-active-symbolic';
         this._hadSetupDevices = global.settings.get_boolean(HAD_BLUETOOTH_DEVICES_SETUP);
+        this._client = new GnomeBluetooth.Client();
 
         this._proxy = new RfkillManagerProxy(Gio.DBus.session, BUS_NAME, OBJECT_PATH,
                                              (proxy, error) => {
@@ -43,6 +44,8 @@ class Indicator extends PanelMenu.SystemIndicator {
         this._toggleItem = new PopupMenu.PopupMenuItem('');
         this._toggleItem.connect('activate', () => {
             this._proxy.BluetoothAirplaneMode = !this._proxy.BluetoothAirplaneMode;
+            if (!this._proxy.BluetoothAirplaneMode)
+                this._client.default_adapter_powered = true;
         });
         this._item.menu.addMenuItem(this._toggleItem);
 
@@ -52,7 +55,6 @@ class Indicator extends PanelMenu.SystemIndicator {
         this._syncId = 0;
         this._adapter = null;
 
-        this._client = new GnomeBluetooth.Client();
         this._store = this._client.get_devices();
         this._deviceNotifyConnected = [];
         this._client.connect('device-removed', (c, path) => {
@@ -146,6 +148,6 @@ class Indicator extends PanelMenu.SystemIndicator {
         else
             this._item.label.text = _('Bluetooth On');
 
-        this._toggleItem.label.text = this._proxy.BluetoothAirplaneMode ? _('Turn On') : _('Turn Off');
+        this._toggleItem.label.text = this._proxy.BluetoothAirplaneMode && 
this._client.default_adapter_powered ? _('Turn On') : _('Turn Off');
     }
 });


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