[gnome-shell/wip/aggregate-menu: 49/74] network: Don't make the toplevel keep a list of connections



commit c4565cf62e195e3cb8ea5ce7cf246bfd035935e6
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Wed Jul 17 01:10:42 2013 -0400

    network: Don't make the toplevel keep a list of connections
    
    Instead, simply pass the settings object around.

 js/ui/status/network.js |   26 ++++++++------------------
 1 files changed, 8 insertions(+), 18 deletions(-)
---
diff --git a/js/ui/status/network.js b/js/ui/status/network.js
index 0b40860..fa775e2 100644
--- a/js/ui/status/network.js
+++ b/js/ui/status/network.js
@@ -117,11 +117,13 @@ const NMDevice = new Lang.Class({
     Name: 'NMDevice',
     Abstract: true,
 
-    _init: function(client, device, connections) {
+    _init: function(client, device, settings) {
         this._client = client;
         this._setDevice(device);
 
         this._connections = [];
+
+        let connections = settings.list_connections();
         connections.forEach(Lang.bind(this, this.checkConnection));
 
         this._activeConnection = null;
@@ -463,7 +465,7 @@ const NMDeviceModem = new Lang.Class({
     Extends: NMDevice,
     category: NMConnectionCategory.WWAN,
 
-    _init: function(client, device, connections) {
+    _init: function(client, device, settings) {
         device._description = _("Mobile broadband");
         this.mobileDevice = null;
 
@@ -495,7 +497,7 @@ const NMDeviceModem = new Lang.Class({
             }));
         }
 
-        this.parent(client, device, connections);
+        this.parent(client, device, settings);
     },
 
     destroy: function() {
@@ -562,12 +564,12 @@ const NMDeviceWireless = new Lang.Class({
     Name: 'NMDeviceWireless',
     Extends: NMDevice,
 
-    _init: function(client, device, connections) {
+    _init: function(client, device, settings) {
         this.category = NMConnectionCategory.WIRELESS;
 
         this._networks = [ ];
 
-        this.parent(client, device, connections);
+        this.parent(client, device, settings);
 
         let accessPoints = device.get_access_points() || [ ];
         accessPoints.forEach(Lang.bind(this, function(ap) {
@@ -1222,7 +1224,6 @@ const NMApplet = new Lang.Class({
             return;
 
         this._activeConnections = [ ];
-        this._connections = [ ];
 
         this._mainConnection = null;
         this._mainConnectionIconChangedId = 0;
@@ -1250,7 +1251,6 @@ const NMApplet = new Lang.Class({
         this._vpnSection.connect('icon-changed', Lang.bind(this, this._updateIcon));
         this._section.addMenuItem(this._vpnSection.section);
 
-        this._readConnections();
         this._readDevices();
         this._syncNMState();
 
@@ -1330,7 +1330,7 @@ const NMApplet = new Lang.Class({
 
         let wrapperClass = this._dtypes[device.get_device_type()];
         if (wrapperClass) {
-            let wrapper = new wrapperClass(this._client, device, this._connections);
+            let wrapper = new wrapperClass(this._client, device, this._settings);
             this._addDeviceWrapper(wrapper);
 
             this._nmDevices.push(device);
@@ -1531,12 +1531,6 @@ const NMApplet = new Lang.Class({
         connection._updatedId = connection.connect('updated', Lang.bind(this, this._updateConnection));
 
         this._updateConnection(connection);
-        this._connections.push(connection);
-    },
-
-    _readConnections: function() {
-        let connections = this._settings.list_connections();
-        connections.forEach(Lang.bind(this, this._addConnection));
     },
 
     _newConnection: function(settings, connection) {
@@ -1545,10 +1539,6 @@ const NMApplet = new Lang.Class({
     },
 
     _connectionRemoved: function(connection) {
-        let pos = this._connections.indexOf(connection);
-        if (pos != -1)
-            this._connections.splice(connection, 1);
-
         let section = connection._section;
 
         if (section == NMConnectionCategory.INVALID)


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