NetworkMenu: add VPN settings menu item
Add a menu item that launches the VPN page of the network panel, or the network panel generically if multiple VPNs are configured. https://bugzilla.gnome.org/show_bug.cgi?id=709167
This commit is contained in:
parent
fa4c481aed
commit
1f786df462
@ -9,6 +9,7 @@ const NetworkManager = imports.gi.NetworkManager;
|
|||||||
const NMClient = imports.gi.NMClient;
|
const NMClient = imports.gi.NMClient;
|
||||||
const NMGtk = imports.gi.NMGtk;
|
const NMGtk = imports.gi.NMGtk;
|
||||||
const Signals = imports.signals;
|
const Signals = imports.signals;
|
||||||
|
const Shell = imports.gi.Shell;
|
||||||
const St = imports.gi.St;
|
const St = imports.gi.St;
|
||||||
|
|
||||||
const Animation = imports.ui.animation;
|
const Animation = imports.ui.animation;
|
||||||
@ -1417,15 +1418,39 @@ const NMVPNSection = new Lang.Class({
|
|||||||
|
|
||||||
_init: function(client) {
|
_init: function(client) {
|
||||||
this.parent(client);
|
this.parent(client);
|
||||||
|
|
||||||
|
this._vpnSettings = new PopupMenu.PopupMenuItem('');
|
||||||
|
this.item.menu.addMenuItem(this._vpnSettings);
|
||||||
|
this._vpnSettings.connect('activate', Lang.bind(this, this._onSettingsActivate));
|
||||||
|
|
||||||
this._sync();
|
this._sync();
|
||||||
},
|
},
|
||||||
|
|
||||||
_sync: function() {
|
_sync: function() {
|
||||||
let nItems = this._connectionItems.size;
|
let nItems = this._connectionItems.size;
|
||||||
this.item.actor.visible = (nItems > 0);
|
this.item.actor.visible = (nItems > 0);
|
||||||
|
|
||||||
|
if (nItems > 1)
|
||||||
|
this._vpnSettings.label.text = _("Network Settings");
|
||||||
|
else
|
||||||
|
this._vpnSettings.label.text = _("VPN Settings");
|
||||||
|
|
||||||
this.parent();
|
this.parent();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
_onSettingsActivate: function() {
|
||||||
|
let nItems = this._connectionItems.size;
|
||||||
|
if (nItems > 1) {
|
||||||
|
let appSys = Shell.AppSystem.get_default();
|
||||||
|
let app = appSys.lookup_app('gnome-network-panel.desktop');
|
||||||
|
app.launch(0, -1);
|
||||||
|
} else {
|
||||||
|
let connection = this._connections[0];
|
||||||
|
Util.spawnApp(['gnome-control-center', 'network', 'show-device',
|
||||||
|
connection.get_path()]);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
_getDescription: function() {
|
_getDescription: function() {
|
||||||
return _("VPN");
|
return _("VPN");
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user