aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--ui/manage_tunnels.go21
1 files changed, 20 insertions, 1 deletions
diff --git a/ui/manage_tunnels.go b/ui/manage_tunnels.go
index f2719ff5..cc4fadaf 100644
--- a/ui/manage_tunnels.go
+++ b/ui/manage_tunnels.go
@@ -81,7 +81,7 @@ func NewManageTunnelsWindow(icon *walk.Icon, logger *ringlogger.Ringlogger) (*Ma
splitter.SetFixed(tunnelsContainer, true)
mtw.tunnelsView, _ = NewTunnelsView(tunnelsContainer)
- mtw.tunnelsView.ItemActivated().Attach(mtw.onEditTunnel)
+ mtw.tunnelsView.ItemActivated().Attach(mtw.onTunnelsViewItemActivated)
mtw.tunnelsView.CurrentIndexChanged().Attach(mtw.updateConfView)
// ToolBar actions
@@ -348,6 +348,25 @@ func (mtw *ManageTunnelsWindow) TunnelDeleted() *walk.StringEvent {
// Handlers
+func (mtw *ManageTunnelsWindow) onTunnelsViewItemActivated() {
+ if mtw.tunnelTracker.InTransition() {
+ return
+ }
+
+ var err error
+ var title string
+ tunnel := mtw.tunnelsView.CurrentTunnel()
+ activeTunnel := mtw.tunnelTracker.ActiveTunnel()
+ if tunnel != nil && activeTunnel != nil && tunnel.Name == activeTunnel.Name {
+ err, title = mtw.tunnelTracker.DeactivateTunnel(), "Deactivating tunnel failed"
+ } else {
+ err, title = mtw.tunnelTracker.ActivateTunnel(tunnel), "Activating tunnel failed"
+ }
+ if err != nil {
+ walk.MsgBox(mtw, title, fmt.Sprintf("Error: %s", err.Error()), walk.MsgBoxIconError)
+ }
+}
+
func (mtw *ManageTunnelsWindow) onEditTunnel() {
tunnel := mtw.tunnelsView.CurrentTunnel()
if tunnel == nil {