aboutsummaryrefslogtreecommitdiffstats
path: root/WireGuard/WireGuard/UI/macOS/ViewController/TunnelsListTableViewController.swift
diff options
context:
space:
mode:
Diffstat (limited to 'WireGuard/WireGuard/UI/macOS/ViewController/TunnelsListTableViewController.swift')
-rw-r--r--WireGuard/WireGuard/UI/macOS/ViewController/TunnelsListTableViewController.swift17
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 {