[gnome-shell] NetworkStatus: hide the only connection for wired devices



commit 4ebf07c725d72512c466731d2762baab2b88190e
Author: Giovanni Campagna <gcampagna src gnome org>
Date:   Fri Mar 25 17:12:38 2011 +0100

    NetworkStatus: hide the only connection for wired devices
    
    For wired devices (actually, ethernet devices), hide the connection
    list when there is only one connection (either automatic or stored).
    The device can be operated with the associated switch.

 js/ui/status/network.js |   18 +++++++++++++++++-
 1 files changed, 17 insertions(+), 1 deletions(-)
---
diff --git a/js/ui/status/network.js b/js/ui/status/network.js
index 0bb3800..189af80 100644
--- a/js/ui/status/network.js
+++ b/js/ui/status/network.js
@@ -449,8 +449,10 @@ NMDevice.prototype = {
             obj.item.destroy();
         this._connections.splice(pos, 1);
 
-        if (this._connections.length == 0) {
+        if (this._connections.length <= 1) {
             // We need to show the automatic connection again
+            // (or in the case of NMDeviceWired, we want to hide
+            // the only explicit connection)
             this._clearSection();
             this._createSection();
         }
@@ -678,6 +680,20 @@ NMDeviceWired.prototype = {
         return true;
     },
 
+    _createSection: function() {
+        NMDevice.prototype._createSection.call(this);
+
+        // if we have only one connection (normal or automatic)
+        // we hide the connection list, and use the switch to control
+        // the device
+        // we can do it here because addConnection and removeConnection
+        // both call _createSection at some point
+        if (this._connections.length <= 1)
+            this.section.actor.hide();
+        else
+            this.section.actor.show();
+    },
+
     _createAutomaticConnection: function() {
         let connection = new NetworkManager.Connection();
         connection._uuid = NetworkManager.utils_uuid_generate();



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