aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/ui/manage_tunnels.go
diff options
context:
space:
mode:
authorAlexander Neumann <alexander.neumann@picos-software.com>2019-04-23 10:59:06 +0200
committerAlexander Neumann <alexander.neumann@picos-software.com>2019-04-23 11:05:00 +0200
commitbe9a44890c0e9749cd2079f78f21e6b3d6217d4f (patch)
treea4340930327c928b383a508c880790e34e072699 /ui/manage_tunnels.go
parentui: some cleanup in ManageTunnelsWindow (diff)
downloadwireguard-windows-be9a44890c0e9749cd2079f78f21e6b3d6217d4f.tar.xz
wireguard-windows-be9a44890c0e9749cd2079f78f21e6b3d6217d4f.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>
Diffstat (limited to 'ui/manage_tunnels.go')
-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 {