From 4ebf07c725d72512c466731d2762baab2b88190e Mon Sep 17 00:00:00 2001 From: Giovanni Campagna Date: Fri, 25 Mar 2011 17:12:38 +0100 Subject: [PATCH] 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 file changed, 17 insertions(+), 1 deletion(-) diff --git a/js/ui/status/network.js b/js/ui/status/network.js index 0bb38004f..189af8004 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();