diff options
author | Roopesh Chander <roop@roopc.net> | 2019-01-03 01:16:27 +0530 |
---|---|---|
committer | Roopesh Chander <roop@roopc.net> | 2019-01-14 14:52:31 +0530 |
commit | ada7db3dca0a2756f5a24f0fcbdfcbfa8f092457 (patch) | |
tree | 0c135c02af0c08f698a87a7dbd55525f489971f0 /WireGuard/WireGuard/UI/macOS/ViewController/TunnelsListTableViewController.swift | |
parent | macOS: Manage tunnels: Add a filler button (diff) | |
download | wireguard-apple-ada7db3dca0a2756f5a24f0fcbdfcbfa8f092457.tar.xz wireguard-apple-ada7db3dca0a2756f5a24f0fcbdfcbfa8f092457.zip |
macOS: Manage tunnels: Tunnel detail view
Signed-off-by: Roopesh Chander <roop@roopc.net>
Diffstat (limited to '')
-rw-r--r-- | WireGuard/WireGuard/UI/macOS/ViewController/TunnelsListTableViewController.swift | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/WireGuard/WireGuard/UI/macOS/ViewController/TunnelsListTableViewController.swift b/WireGuard/WireGuard/UI/macOS/ViewController/TunnelsListTableViewController.swift index 05aabbe..c99f15b 100644 --- a/WireGuard/WireGuard/UI/macOS/ViewController/TunnelsListTableViewController.swift +++ b/WireGuard/WireGuard/UI/macOS/ViewController/TunnelsListTableViewController.swift @@ -3,9 +3,15 @@ import Cocoa +protocol TunnelsListTableViewControllerDelegate: class { + func tunnelSelected(tunnel: TunnelContainer) + func tunnelListEmpty() +} + class TunnelsListTableViewController: NSViewController { let tunnelsManager: TunnelsManager + weak var delegate: TunnelsListTableViewControllerDelegate? let tableView: NSTableView = { let tableView = NSTableView() @@ -148,6 +154,17 @@ extension TunnelsListTableViewController: NSTableViewDelegate { cell.tunnel = tunnelsManager.tunnel(at: row) return cell } + + func tableViewSelectionDidChange(_ notification: Notification) { + guard tableView.selectedRow >= 0 else { + if tunnelsManager.numberOfTunnels() == 0 { + delegate?.tunnelListEmpty() + } + return + } + let selectedTunnel = tunnelsManager.tunnel(at: tableView.selectedRow) + delegate?.tunnelSelected(tunnel: selectedTunnel) + } } class FillerButton: NSButton { |