aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoopesh Chander <roop@roopc.net>2019-03-18 11:57:09 +0530
committerRoopesh Chander <roop@roopc.net>2019-03-18 12:03:41 +0530
commit2a7dcac25863b650e412a5e5bae6dad054d75a91 (patch)
treed881f2c2ce82aed571ff7bcd1a782ff92c54cb2b
parentmacOS: Tunnels list: Don't allow empty selection (diff)
downloadwireguard-apple-2a7dcac25863b650e412a5e5bae6dad054d75a91.tar.xz
wireguard-apple-2a7dcac25863b650e412a5e5bae6dad054d75a91.zip
macOS: Tunnels list: Double-click to activate / deactivate
-rw-r--r--WireGuard/WireGuard/UI/macOS/ViewController/TunnelsListTableViewController.swift13
1 files changed, 13 insertions, 0 deletions
diff --git a/WireGuard/WireGuard/UI/macOS/ViewController/TunnelsListTableViewController.swift b/WireGuard/WireGuard/UI/macOS/ViewController/TunnelsListTableViewController.swift
index 0dffd48..f922f61 100644
--- a/WireGuard/WireGuard/UI/macOS/ViewController/TunnelsListTableViewController.swift
+++ b/WireGuard/WireGuard/UI/macOS/ViewController/TunnelsListTableViewController.swift
@@ -78,6 +78,8 @@ class TunnelsListTableViewController: NSViewController {
tableView.dataSource = self
tableView.delegate = self
+ tableView.doubleAction = #selector(listDoubleClicked(sender:))
+
let isSelected = selectTunnelInOperation() || selectTunnel(at: 0)
if !isSelected {
delegate?.tunnelsListEmpty()
@@ -242,6 +244,17 @@ class TunnelsListTableViewController: NSViewController {
}
}
+ @objc func listDoubleClicked(sender: AnyObject) {
+ let tunnelIndex = tableView.clickedRow
+ guard tunnelIndex >= 0 && tunnelIndex < tunnelsManager.numberOfTunnels() else { return }
+ let tunnel = tunnelsManager.tunnel(at: tunnelIndex)
+ if tunnel.status == .inactive {
+ tunnelsManager.startActivation(of: tunnel)
+ } else if tunnel.status == .active {
+ tunnelsManager.startDeactivation(of: tunnel)
+ }
+ }
+
@discardableResult
private func selectTunnel(at index: Int) -> Bool {
if index < tunnelsManager.numberOfTunnels() {