aboutsummaryrefslogtreecommitdiffstats
path: root/WireGuard/WireGuard/UI/macOS/ViewController
diff options
context:
space:
mode:
authorRoopesh Chander <roop@roopc.net>2019-01-04 18:33:46 +0530
committerRoopesh Chander <roop@roopc.net>2019-01-14 14:52:32 +0530
commitdfc4b37518144f711aaab8e92e316e0ba87c6460 (patch)
tree8f9836cd26cae7bc35db0c7e82f692f919496130 /WireGuard/WireGuard/UI/macOS/ViewController
parentmacOS: Manage tunnels: Export log pulldown menu implementation (diff)
downloadwireguard-apple-dfc4b37518144f711aaab8e92e316e0ba87c6460.tar.xz
wireguard-apple-dfc4b37518144f711aaab8e92e316e0ba87c6460.zip
macOS: Manage tunnels: Update tunnels list on changes
Signed-off-by: Roopesh Chander <roop@roopc.net>
Diffstat (limited to '')
-rw-r--r--WireGuard/WireGuard/UI/macOS/ViewController/ManageTunnelsRootViewController.swift9
-rw-r--r--WireGuard/WireGuard/UI/macOS/ViewController/TunnelsListTableViewController.swift18
2 files changed, 23 insertions, 4 deletions
diff --git a/WireGuard/WireGuard/UI/macOS/ViewController/ManageTunnelsRootViewController.swift b/WireGuard/WireGuard/UI/macOS/ViewController/ManageTunnelsRootViewController.swift
index 71dc8b82..c951b45b 100644
--- a/WireGuard/WireGuard/UI/macOS/ViewController/ManageTunnelsRootViewController.swift
+++ b/WireGuard/WireGuard/UI/macOS/ViewController/ManageTunnelsRootViewController.swift
@@ -6,6 +6,7 @@ import Cocoa
class ManageTunnelsRootViewController: NSViewController {
let tunnelsManager: TunnelsManager
+ var tunnelsListVC: TunnelsListTableViewController?
let tunnelDetailContainerView = NSView()
var tunnelDetailContentVC: NSViewController?
@@ -34,11 +35,11 @@ class ManageTunnelsRootViewController: NSViewController {
view.trailingAnchor.constraint(equalTo: container.trailingAnchor, constant: horizontalSpacing)
])
- let tunnelsListVC = TunnelsListTableViewController(tunnelsManager: tunnelsManager)
- tunnelsListVC.delegate = self
- let tunnelsListView = tunnelsListVC.view
+ tunnelsListVC = TunnelsListTableViewController(tunnelsManager: tunnelsManager)
+ tunnelsListVC!.delegate = self
+ let tunnelsListView = tunnelsListVC!.view
- addChild(tunnelsListVC)
+ addChild(tunnelsListVC!)
view.addSubview(tunnelsListView)
view.addSubview(tunnelDetailContainerView)
diff --git a/WireGuard/WireGuard/UI/macOS/ViewController/TunnelsListTableViewController.swift b/WireGuard/WireGuard/UI/macOS/ViewController/TunnelsListTableViewController.swift
index 2d0b6fea..c7d691f0 100644
--- a/WireGuard/WireGuard/UI/macOS/ViewController/TunnelsListTableViewController.swift
+++ b/WireGuard/WireGuard/UI/macOS/ViewController/TunnelsListTableViewController.swift
@@ -206,6 +206,24 @@ class TunnelsListTableViewController: NSViewController {
}
}
+extension TunnelsListTableViewController {
+ func tunnelAdded(at index: Int) {
+ tableView.insertRows(at: IndexSet(integer: index), withAnimation: .slideLeft)
+ }
+
+ func tunnelModified(at index: Int) {
+ tableView.reloadData(forRowIndexes: IndexSet(integer: index), columnIndexes: IndexSet(integer: 0))
+ }
+
+ func tunnelMoved(from oldIndex: Int, to newIndex: Int) {
+ tableView.moveRow(at: oldIndex, to: newIndex)
+ }
+
+ func tunnelRemoved(at index: Int) {
+ tableView.removeRows(at: IndexSet(integer: index), withAnimation: .slideLeft)
+ }
+}
+
extension TunnelsListTableViewController: NSTableViewDataSource {
func numberOfRows(in tableView: NSTableView) -> Int {
return tunnelsManager.numberOfTunnels()