From 79f6ee25bd8a1ff061a041f7a721c67ee01dd9fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=BCllner?= Date: Tue, 2 Aug 2022 11:46:28 +0200 Subject: [PATCH] status/network: Use ActiveConnection:state in VPN item The separate :vpn-state property is more fine-grained, but as we aren't using anything beyond what :state provides, we can just as well use that. Part-of: --- js/ui/status/network.js | 30 ++++++++---------------------- 1 file changed, 8 insertions(+), 22 deletions(-) diff --git a/js/ui/status/network.js b/js/ui/status/network.js index 547dadc36..64f44a93e 100644 --- a/js/ui/status/network.js +++ b/js/ui/status/network.js @@ -1437,13 +1437,6 @@ var NMWireguardItem = class extends NMConnectionItem { }; var NMVpnConnectionItem = class extends NMConnectionItem { - isActive() { - if (this._activeConnection == null) - return false; - - return this._activeConnection.vpn_state != NM.VpnConnectionState.DISCONNECTED; - } - _buildUI() { this.labelItem = new PopupMenu.PopupMenuItem(''); this.labelItem.connect('activate', this._toggle.bind(this)); @@ -1459,29 +1452,22 @@ var NMVpnConnectionItem = class extends NMConnectionItem { this.emit('icon-changed'); } - _connectionStateChanged(ac, newstate, reason) { - if (newstate === NM.VpnConnectionState.FAILED && - reason !== NM.VpnConnectionStateReason.NO_SECRETS) + _connectionStateChanged() { + const state = this._activeConnection?.get_state(); + const reason = this._activeConnection?.get_state_reason(); + + if (state === NM.ActiveConnectionState.DEACTIVATED && + reason !== NM.ActiveConnectionStateReason.NO_SECRETS && + reason !== NM.ActiveConnectionStateReason.USER_DISCONNECTED) this.emit('activation-failed'); this.emit('icon-changed'); super._connectionStateChanged(); } - setActiveConnection(activeConnection) { - this._activeConnection?.disconnectObject(this); - - this._activeConnection = activeConnection; - - this._activeConnection?.connectObject('vpn-state-changed', - this._connectionStateChanged.bind(this), this); - - this._sync(); - } - getIndicatorIcon() { if (this._activeConnection) { - if (this._activeConnection.vpn_state < NM.VpnConnectionState.ACTIVATED) + if (this._activeConnection.state < NM.ActiveConnectionState.ACTIVATED) return 'network-vpn-acquiring-symbolic'; else return 'network-vpn-symbolic';