macOS: Manage tunnels: Tunnel detail view
Signed-off-by: Roopesh Chander <roop@roopc.net>
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user