From: Roopesh Chander Date: Mon, 18 Mar 2019 06:27:09 +0000 (+0530) Subject: macOS: Tunnels list: Double-click to activate / deactivate X-Git-Tag: 0.0.20190319-1~7 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=121d2232296e936b68268b75560d5ab6f35bf2cd;p=thirdparty%2Fwireguard-apple.git macOS: Tunnels list: Double-click to activate / deactivate Signed-off-by: Roopesh Chander --- 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() {