[gnome-shell] status/network: Disable modem connection when windows aren't allowed



commit 25793b9d9759dd5e75e6aa4ffc069ebe1ea4af09
Author: Florian Müllner <fmuellner gnome org>
Date:   Mon Jun 7 17:49:57 2021 +0200

    status/network: Disable modem connection when windows aren't allowed
    
    The item launches the corresponding Settings panel when activated, which
    doesn't work when windows are disabled by the session mode. Rather than
    failing silently, turn the item insensitive.
    
    Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1874>

 js/ui/status/network.js | 12 ++++++++++++
 1 file changed, 12 insertions(+)
---
diff --git a/js/ui/status/network.js b/js/ui/status/network.js
index 5487fde40f..6e7878d20c 100644
--- a/js/ui/status/network.js
+++ b/js/ui/status/network.js
@@ -563,6 +563,10 @@ var NMDeviceModem = class extends NMConnectionDevice {
                 this._iconChanged();
             });
         }
+
+        this._sessionUpdatedId =
+            Main.sessionMode.connect('updated', this._sessionUpdated.bind(this));
+        this._sessionUpdated();
     }
 
     get category() {
@@ -573,6 +577,10 @@ var NMDeviceModem = class extends NMConnectionDevice {
         launchSettingsPanel('network', 'connect-3g', this._device.get_path());
     }
 
+    _sessionUpdated() {
+        this._autoConnectItem.sensitive = Main.sessionMode.hasWindows;
+    }
+
     destroy() {
         if (this._operatorNameId) {
             this._mobileDevice.disconnect(this._operatorNameId);
@@ -582,6 +590,10 @@ var NMDeviceModem = class extends NMConnectionDevice {
             this._mobileDevice.disconnect(this._signalQualityId);
             this._signalQualityId = 0;
         }
+        if (this._sessionUpdatedId) {
+            Main.sessionMode.disconnect(this._sessionUpdatedId);
+            this._sessionUpdatedId = 0;
+        }
 
         super.destroy();
     }


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