NetworkMenu: fix VPN connection state
It was always reporting true, even if disconnected. At the same time, add a signal that is emitted when state changes and update the UI accordingly. In the future (with another libnm-glib API break) we should use the NMVPNConnection object to track the connection state, so that we can show if we're connecting or we need authentication. https://bugzilla.gnome.org/show_bug.cgi?id=646380
This commit is contained in:
parent
5b61485143
commit
d1a110d4ca
@ -254,6 +254,11 @@ NMWiredSectionTitleMenuItem.prototype = {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Immediately reset the switch to false, it will be updated appropriately
|
||||||
|
// by state-changed signals in devices (but fixes the VPN not being in sync
|
||||||
|
// if the ActiveConnection object is never seen by libnm-glib)
|
||||||
|
this._switch.setToggleState(false);
|
||||||
|
|
||||||
if (this._switch.state)
|
if (this._switch.state)
|
||||||
this._device.activate();
|
this._device.activate();
|
||||||
else
|
else
|
||||||
@ -940,7 +945,13 @@ NMDeviceVPN.prototype = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
get connected() {
|
get connected() {
|
||||||
return true;
|
return !!this._activeConnection;
|
||||||
|
},
|
||||||
|
|
||||||
|
setActiveConnection: function(activeConnection) {
|
||||||
|
NMDevice.prototype.setActiveConnection.call(this, activeConnection);
|
||||||
|
|
||||||
|
this.emit('active-connection-changed');
|
||||||
},
|
},
|
||||||
|
|
||||||
_shouldShowConnectionList: function() {
|
_shouldShowConnectionList: function() {
|
||||||
@ -1539,6 +1550,9 @@ NMApplet.prototype = {
|
|||||||
device: new NMDeviceVPN(this._client),
|
device: new NMDeviceVPN(this._client),
|
||||||
item: new NMWiredSectionTitleMenuItem(_("VPN Connections"))
|
item: new NMWiredSectionTitleMenuItem(_("VPN Connections"))
|
||||||
};
|
};
|
||||||
|
this._devices.vpn.device.connect('active-connection-changed', Lang.bind(this, function() {
|
||||||
|
this._devices.vpn.item.updateForDevice(this._devices.vpn.device);
|
||||||
|
}));
|
||||||
this._devices.vpn.item.updateForDevice(this._devices.vpn.device);
|
this._devices.vpn.item.updateForDevice(this._devices.vpn.device);
|
||||||
this._devices.vpn.section.addMenuItem(this._devices.vpn.item);
|
this._devices.vpn.section.addMenuItem(this._devices.vpn.item);
|
||||||
this._devices.vpn.section.addMenuItem(this._devices.vpn.device.section);
|
this._devices.vpn.section.addMenuItem(this._devices.vpn.device.section);
|
||||||
|
Loading…
Reference in New Issue
Block a user