macOS: Add tunnel management menu items

Signed-off-by: Roopesh Chander <roop@roopc.net>
This commit is contained in:
Roopesh Chander 2018-12-29 00:42:02 +05:30
parent 51a2c272b9
commit fb1607d4a2
2 changed files with 24 additions and 0 deletions

View File

@ -220,3 +220,8 @@
"alertSystemErrorMessageTunnelConfigurationStale" = "The configuration is stale."; "alertSystemErrorMessageTunnelConfigurationStale" = "The configuration is stale.";
"alertSystemErrorMessageTunnelConfigurationReadWriteFailed" = "Reading or writing the configuration failed."; "alertSystemErrorMessageTunnelConfigurationReadWriteFailed" = "Reading or writing the configuration failed.";
"alertSystemErrorMessageTunnelConfigurationUnknown" = "Unknown system error."; "alertSystemErrorMessageTunnelConfigurationUnknown" = "Unknown system error.";
// Mac status bar menu
"macMenuManageTunnels" = "Manage tunnels";
"macMenuImportTunnels" = "Import tunnel(s) from file...";

View File

@ -11,6 +11,8 @@ class StatusMenu: NSMenu {
self.tunnelsManager = tunnelsManager self.tunnelsManager = tunnelsManager
super.init(title: "WireGuard Status Bar Menu") super.init(title: "WireGuard Status Bar Menu")
addTunnelMenuItems() addTunnelMenuItems()
addItem(NSMenuItem.separator())
addTunnelManagementItems()
} }
required init(coder decoder: NSCoder) { required init(coder decoder: NSCoder) {
@ -31,4 +33,21 @@ class StatusMenu: NSMenu {
guard let tunnel = sender.representedObject as? TunnelContainer else { return } guard let tunnel = sender.representedObject as? TunnelContainer else { return }
print("Tunnel \(tunnel.name) clicked") print("Tunnel \(tunnel.name) clicked")
} }
func addTunnelManagementItems() {
let manageItem = NSMenuItem(title: tr("macMenuManageTunnels"), action: #selector(manageTunnelsClicked), keyEquivalent: "")
manageItem.target = self
addItem(manageItem)
let importItem = NSMenuItem(title: tr("macMenuImportTunnels"), action: #selector(importTunnelsClicked), keyEquivalent: "")
importItem.target = self
addItem(importItem)
}
@objc func manageTunnelsClicked() {
print("Unimplemented")
}
@objc func importTunnelsClicked() {
print("Unimplemented")
}
} }