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>
This commit is contained in:
Florian Müllner 2022-08-02 11:46:28 +02:00
parent 9bca544dd6
commit 79f6ee25bd

View File

@ -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';