diff options
author | Alexander Neumann <alexander.neumann@picos-software.com> | 2019-04-23 10:59:06 +0200 |
---|---|---|
committer | Alexander Neumann <alexander.neumann@picos-software.com> | 2019-04-23 11:05:00 +0200 |
commit | 213fbfd27976455a16d4bac82c6c4c16474b9e3b (patch) | |
tree | a4340930327c928b383a508c880790e34e072699 | |
parent | ui: some cleanup in ManageTunnelsWindow (diff) | |
download | wireguard-windows-213fbfd27976455a16d4bac82c6c4c16474b9e3b.tar.xz wireguard-windows-213fbfd27976455a16d4bac82c6c4c16474b9e3b.zip |
ui: when activating an item of the tunnels list, toggle on/off instead of editing
Signed-off-by: Alexander Neumann <alexander.neumann@picos-software.com>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to '')
-rw-r--r-- | ui/manage_tunnels.go | 21 |
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 { |