[gnome-shell/wip/aggregate-menu: 60/75] network: Revamp menu visibility when the network manager is offline



commit 3eaa351f577f5eb467f2abf67b147768746be819
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Thu Jun 6 16:46:07 2013 -0400

    network: Revamp menu visibility when the network manager is offline
    
    Remove the old hideDevices/showNormal code that was unbalanced and
    just a bit weird, and add everything to one big section we hide/show.

 js/ui/status/network.js |   38 ++++++++++----------------------------
 1 files changed, 10 insertions(+), 28 deletions(-)
---
diff --git a/js/ui/status/network.js b/js/ui/status/network.js
index c5cca6a..f092986 100644
--- a/js/ui/status/network.js
+++ b/js/ui/status/network.js
@@ -1397,28 +1397,31 @@ const NMApplet = new Lang.Class({
         this._nmDevices = [];
         this._devices = { };
 
+        this._section = new PopupMenu.PopupMenuSection();
+        this.menu.addMenuItem(this._section);
+
         this._devices.wired = {
             section: new PopupMenu.PopupMenuSection(),
             devices: [ ],
         };
-        this.menu.addMenuItem(this._devices.wired.section);
+        this._section.addMenuItem(this._devices.wired.section);
 
         this._devices.wireless = {
             section: new PopupMenu.PopupMenuSection(),
             devices: [ ],
         };
-        this.menu.addMenuItem(this._devices.wireless.section);
+        this._section.addMenuItem(this._devices.wireless.section);
 
         this._devices.wwan = {
             section: new PopupMenu.PopupMenuSection(),
             devices: [ ],
         };
-        this.menu.addMenuItem(this._devices.wwan.section);
+        this._section.addMenuItem(this._devices.wwan.section);
 
         this._vpnSection = new NMVPNSection(this._client);
         this._vpnSection.connect('activation-failed', Lang.bind(this, this._onActivationFailed));
         this._vpnSection.connect('icon-changed', Lang.bind(this, this._updateIcon));
-        this.menu.addMenuItem(this._vpnSection.section);
+        this._section.addMenuItem(this._vpnSection.section);
 
         this._readConnections();
         this._readDevices();
@@ -1758,34 +1761,13 @@ const NMApplet = new Lang.Class({
         }
     },
 
-    _hideDevices: function() {
-        this._devicesHidden = true;
-
-        for (let category in this._devices)
-            this._devices[category].section.actor.hide();
-    },
-
-    _showNormal: function() {
-        if (!this._devicesHidden) // nothing to do
-            return;
-        this._devicesHidden = false;
-
-        for (let category in this._devices)
-            this._devices[category].section.actor.show();
-    },
-
     _syncNMState: function() {
         this.mainIcon.visible = this._client.manager_running;
         this.actor.visible = this.mainIcon.visible;
 
-        if (!this._client.networking_enabled) {
-            this.setIcon('network-offline-symbolic');
-            this._hideDevices();
-            return;
-        }
-
-        this._showNormal();
         this._updateIcon();
+
+        this._section.actor.visible = this._client.networking_enabled;
     },
 
     _updateIcon: function() {
@@ -1793,7 +1775,7 @@ const NMApplet = new Lang.Class({
         let hasApIcon = false;
         let hasMobileIcon = false;
 
-        if (!this._mainConnection) {
+        if (!this._client.networking_enabled || !this._mainConnection) {
             this.setIcon('network-offline-symbolic');
         } else {
             let dev = this._mainConnection._primaryDevice;


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