[gnome-shell] status/network: Use ActiveConnection:state in VPN item



commit 79f6ee25bd8a1ff061a041f7a721c67ee01dd9fd
Author: Florian Müllner <fmuellner gnome org>
Date:   Tue Aug 2 11:46:28 2022 +0200

    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: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2406>

 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 547dadc361..64f44a93ec 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';


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