[gnome-shell/wip/rstrode/login-screen-extensions: 26/134] status/network: Only list wifi networks that can be activated




commit 2356714a91742053d08fe1500091f61c2eae6e6e
Author: Florian Müllner <fmuellner gnome org>
Date:   Mon Jun 7 18:28:32 2021 +0200

    status/network: Only list wifi networks that can be activated
    
    Setting up a connection for an Enterprise WPA(2) encrypted wireless
    network requires Settings. That's not available when windows are
    disabled via the session mode, so filter out affected entries.

 js/ui/status/network.js | 29 ++++++++++++++++++++++++++++-
 1 file changed, 28 insertions(+), 1 deletion(-)
---
diff --git a/js/ui/status/network.js b/js/ui/status/network.js
index 99cabc256c..92413d9b31 100644
--- a/js/ui/status/network.js
+++ b/js/ui/status/network.js
@@ -1,5 +1,5 @@
 // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
-const { Clutter, Gio, GLib, GObject, NM, St } = imports.gi;
+const { Clutter, Gio, GLib, GObject, Meta, NM, St } = imports.gi;
 const Mainloop = imports.mainloop;
 const Signals = imports.signals;
 
@@ -760,6 +760,11 @@ var NMWirelessDialog = class extends ModalDialog.ModalDialog {
             this._scanTimeoutId = 0;
         }
 
+        if (this._syncVisibilityId) {
+            Meta.later_remove(this._syncVisibilityId);
+            this._syncVisibilityId = 0;
+        }
+
         super.destroy();
     }
 
@@ -1090,9 +1095,31 @@ var NMWirelessDialog = class extends ModalDialog.ModalDialog {
             this._itemBox.insert_child_at_index(network.item.actor, newPos);
         }
 
+        this._queueSyncItemVisibility();
         this._syncView();
     }
 
+    _queueSyncItemVisibility() {
+        if (this._syncVisibilityId)
+            return;
+
+        this._syncVisibilityId = Meta.later_add(
+            Meta.LaterType.BEFORE_REDRAW,
+            () => {
+                const { hasWindows } = Main.sessionMode;
+                const { WPA2_ENT, WPA_ENT } = NMAccessPointSecurity;
+
+                for (const network of this._networks) {
+                    const [firstAp] = network.accessPoints;
+                    network.item.visible =
+                        hasWindows ||
+                        network.connections.length > 0 ||
+                        (firstAp._secType !== WPA2_ENT && firstAp._secType !== WPA_ENT);
+                }
+                return GLib.SOURCE_REMOVE;
+            });
+    }
+
     _accessPointRemoved(device, accessPoint) {
         let res = this._findExistingNetwork(accessPoint);
 


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