macOS: Add tunnel management menu items

This commit is contained in:
Roopesh Chander 2018-12-29 00:42:02 +05:30
parent 93d7bfa12c
commit 3d97b59a4f
2 changed files with 24 additions and 0 deletions

View File

@ -220,3 +220,8 @@
"alertSystemErrorMessageTunnelConfigurationStale" = "The configuration is stale.";
"alertSystemErrorMessageTunnelConfigurationReadWriteFailed" = "Reading or writing the configuration failed.";
"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
super.init(title: "WireGuard Status Bar Menu")
addTunnelMenuItems()
addItem(NSMenuItem.separator())
addTunnelManagementItems()
}
required init(coder decoder: NSCoder) {
@ -31,4 +33,21 @@ class StatusMenu: NSMenu {
guard let tunnel = sender.representedObject as? TunnelContainer else { return }
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")
}
}