From: Roopesh Chander Date: Tue, 5 Feb 2019 11:09:19 +0000 (+0530) Subject: macOS: Select tunnel after adding it with 'Add empty tunnel' X-Git-Tag: 0.0.20190207-1~24 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=02a96d45669dddf5c7743ba8c013f58a004a97e8;p=thirdparty%2Fwireguard-apple.git macOS: Select tunnel after adding it with 'Add empty tunnel' Signed-off-by: Roopesh Chander --- diff --git a/WireGuard/WireGuard/UI/macOS/ViewController/TunnelsListTableViewController.swift b/WireGuard/WireGuard/UI/macOS/ViewController/TunnelsListTableViewController.swift index 46f6bcb..e83e616 100644 --- a/WireGuard/WireGuard/UI/macOS/ViewController/TunnelsListTableViewController.swift +++ b/WireGuard/WireGuard/UI/macOS/ViewController/TunnelsListTableViewController.swift @@ -141,6 +141,7 @@ class TunnelsListTableViewController: NSViewController { @objc func handleAddEmptyTunnelAction() { let tunnelEditVC = TunnelEditViewController(tunnelsManager: tunnelsManager, tunnel: nil) + tunnelEditVC.delegate = self presentAsSheet(tunnelEditVC) } @@ -237,6 +238,18 @@ class TunnelsListTableViewController: NSViewController { } } +extension TunnelsListTableViewController: TunnelEditViewControllerDelegate { + func tunnelSaved(tunnel: TunnelContainer) { + if let tunnelIndex = tunnelsManager.index(of: tunnel), tunnelIndex >= 0 { + self.selectTunnel(at: tunnelIndex) + } + } + + func tunnelEditingCancelled() { + // Nothing to do + } +} + extension TunnelsListTableViewController { func tunnelAdded(at index: Int) { tableView.insertRows(at: IndexSet(integer: index), withAnimation: .slideLeft)