[gnome-shell] status/network: Hide sections if networking is disabled



commit cd9284e48fe7d7ba3c234fcf528b3db5f23cc94e
Author: Florian Müllner <fmuellner gnome org>
Date:   Sun Aug 7 01:58:02 2022 +0200

    status/network: Hide sections if networking is disabled
    
    When moving to quick settings, we will no longer have a single
    parent we can hide instead.
    
    This is only really needed for VPN - devices go away when networking
    is disabled, connections (as in: configuration) do not - but it's
    simpler to just handle this in the base class than adding a
    _shouldBeVisible() method the VPN section can override.
    
    Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2408>

 js/ui/status/network.js | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
---
diff --git a/js/ui/status/network.js b/js/ui/status/network.js
index 9e2ef3a8b8..14df7978bc 100644
--- a/js/ui/status/network.js
+++ b/js/ui/status/network.js
@@ -1342,6 +1342,9 @@ const NMSection = GObject.registerClass({
 
         this._client?.disconnectObject(this);
         this._client = client;
+        this._client?.connectObject(
+            'notify::networking-enabled', () => this._sync(),
+            this);
 
         this._items.forEach(item => item.destroy());
         this._items.clear();
@@ -1461,7 +1464,8 @@ const NMSection = GObject.registerClass({
     }
 
     _sync() {
-        this.visible = this._items.size > 0;
+        this.visible =
+            this._client?.networking_enabled && this._items.size > 0;
         this._updateItemsVisibility();
         this._updateChecked();
         this._itemBinding.source = this._getPrimaryItem();
@@ -1875,9 +1879,6 @@ class Indicator extends PanelMenu.SystemIndicator {
         this._client.bind_property('nm-running',
             this, 'visible',
             GObject.BindingFlags.SYNC_CREATE);
-        this._client.bind_property('networking-enabled',
-            this.menu.actor, 'visible',
-            GObject.BindingFlags.SYNC_CREATE);
 
         this._client.connectObject(
             'notify::primary-connection', () => this._syncMainConnection(),


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