aboutsummaryrefslogtreecommitdiffstats
path: root/WireGuard/WireGuard/UI/macOS/ViewController
diff options
context:
space:
mode:
authorRoopesh Chander <roop@roopc.net>2019-01-03 23:16:44 +0530
committerRoopesh Chander <roop@roopc.net>2019-01-14 14:52:32 +0530
commitde12c27d5bdb6bec583c24435eac7d63e7ba3f9a (patch)
tree6c043855ce1b4675bcaee4f671fa9e89a4772599 /WireGuard/WireGuard/UI/macOS/ViewController
parentmacOS: Manage tunnels: Set window title (diff)
downloadwireguard-apple-de12c27d5bdb6bec583c24435eac7d63e7ba3f9a.tar.xz
wireguard-apple-de12c27d5bdb6bec583c24435eac7d63e7ba3f9a.zip
macOS: Manage tunnels: Select first tunnel on showing the window
Signed-off-by: Roopesh Chander <roop@roopc.net>
Diffstat (limited to '')
-rw-r--r--WireGuard/WireGuard/UI/macOS/ViewController/TunnelsListTableViewController.swift8
1 files changed, 8 insertions, 0 deletions
diff --git a/WireGuard/WireGuard/UI/macOS/ViewController/TunnelsListTableViewController.swift b/WireGuard/WireGuard/UI/macOS/ViewController/TunnelsListTableViewController.swift
index 5ceb2a1b..310d13ab 100644
--- a/WireGuard/WireGuard/UI/macOS/ViewController/TunnelsListTableViewController.swift
+++ b/WireGuard/WireGuard/UI/macOS/ViewController/TunnelsListTableViewController.swift
@@ -61,6 +61,7 @@ class TunnelsListTableViewController: NSViewController {
override func loadView() {
tableView.dataSource = self
tableView.delegate = self
+ selectFirstTunnel()
let scrollView = NSScrollView()
scrollView.hasVerticalScroller = true
@@ -148,6 +149,13 @@ class TunnelsListTableViewController: NSViewController {
@objc func exportTunnelsClicked() {
print("exportTunnelsClicked")
}
+
+ @discardableResult
+ private func selectFirstTunnel() -> Bool {
+ guard tunnelsManager.numberOfTunnels() > 0 else { return false }
+ tableView.selectRowIndexes(IndexSet(integer: 0), byExtendingSelection: false)
+ return true
+ }
}
extension TunnelsListTableViewController: NSTableViewDataSource {