[gnome-shell/wip/message-tray-menu: 102/109] network: Remove setActiveConnection/clearActiveConnection
- From: Jasper St. Pierre <jstpierre src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell/wip/message-tray-menu: 102/109] network: Remove setActiveConnection/clearActiveConnection
- Date: Thu, 9 May 2013 15:44:55 +0000 (UTC)
commit eda953097f3abb870f443d42fc78d32d19f869ee
Author: Jasper St. Pierre <jstpierre mecheye net>
Date: Fri Apr 26 21:44:59 2013 -0400
network: Remove setActiveConnection/clearActiveConnection
This can be more easily achieved by listening for changes to
the device's active-connection property. VPN will still need
support to track active connections, as it does not have an
associated device. But as VPN can track multiple active
connections, rename setActiveConnection/clearActiveConnection
to addActiveConnection/removeActiveConnection.
js/ui/status/network.js | 28 ++++++++++++++--------------
1 files changed, 14 insertions(+), 14 deletions(-)
---
diff --git a/js/ui/status/network.js b/js/ui/status/network.js
index 2fef8a5..b07c09c 100644
--- a/js/ui/status/network.js
+++ b/js/ui/status/network.js
@@ -244,6 +244,7 @@ const NMDevice = new Lang.Class({
this.device = device;
this.device._delegate = this;
this._stateChangedId = this.device.connect('state-changed', Lang.bind(this,
this._deviceStateChanged));
+ this._activeConnectionChangedId = this.device.connect('notify::active-connection',
Lang.bind(this, this._activeConnectionChanged));
} else if (this.device) {
this.device._delegate = null;
@@ -299,11 +300,9 @@ const NMDevice = new Lang.Class({
return this.device && this.device.state == NetworkManager.DeviceState.ACTIVATED;
},
- clearActiveConnection: function(activeConnection) {
- this.setActiveConnection(null);
- },
+ _activeConnectionChanged: function() {
+ let activeConnection = this.device.active_connection;
- setActiveConnection: function(activeConnection) {
if (activeConnection == this._activeConnection)
// nothing to do
return;
@@ -780,7 +779,7 @@ const NMDeviceWireless = new Lang.Class({
this._activeNetwork = this._networks[res.network];
}
- // we don't refresh the view here, setActiveConnection will
+ // we don't refresh the view here, _activeConnectionChanged will
},
_getApSecurityType: function(accessPoint) {
@@ -1256,13 +1255,13 @@ const NMVPNSection = new Lang.Class({
this._syncConnectionItem(activeConnection, activeConnection._connection);
},
- clearActiveConnection: function(activeConnection) {
+ removeActiveConnection: function(activeConnection) {
activeConnection._connection._activeConnection = null;
activeConnection.disconnect(activeConnection._stateChangedId);
this._syncConnectionItem(null, activeConnection._connection);
},
- setActiveConnection: function(activeConnection) {
+ addActiveConnection: function(activeConnection) {
activeConnection._connection._activeConnection = activeConnection;
activeConnection._stateChangedId = activeConnection.connect('vpn-state-changed',
Lang.bind(this,
this._connectionStateChanged));
@@ -1548,9 +1547,9 @@ const NMApplet = new Lang.Class({
for (let i = 0; i < closedConnections.length; i++) {
let active = closedConnections[i];
- if (active._primaryDevice) {
- active._primaryDevice.clearActiveConnection(active);
- active._primaryDevice = null;
+ if (active._vpnSection) {
+ active._vpnSection.removeDevice(active);
+ active._vpnSection = null;
}
if (active._inited) {
active.disconnect(active._notifyStateId);
@@ -1610,14 +1609,15 @@ const NMApplet = new Lang.Class({
active_vpn = a;
if (!a._primaryDevice) {
- if (a._type != NetworkManager.SETTING_VPN_SETTING_NAME)
+ if (a._type != NetworkManager.SETTING_VPN_SETTING_NAME) {
// This list is guaranteed to have one device in it.
a._primaryDevice = a.get_devices()[0]._delegate;
- else
+ } else {
a._primaryDevice = this._vpnSection;
+ a._vpnSection = this._vpnSection;
- if (a._primaryDevice)
- a._primaryDevice.setActiveConnection(a);
+ this._vpnSection.addActiveConnection(a);
+ }
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]