diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2019-04-27 16:39:06 +0200 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2019-04-27 16:39:06 +0200 |
commit | 793549f644302f08f5c1b28451a98ffd0eecf0d1 (patch) | |
tree | c154e97a58a9a98af9a3fe316285ee3fdd0b22a3 /ui | |
parent | ui: enable double buffering on confview (diff) | |
download | wireguard-windows-793549f644302f08f5c1b28451a98ffd0eecf0d1.tar.xz wireguard-windows-793549f644302f08f5c1b28451a98ffd0eecf0d1.zip |
ui: fix UI hide/quit logic
Diffstat (limited to 'ui')
-rw-r--r-- | ui/managewindow.go | 3 | ||||
-rw-r--r-- | ui/tunnelspage.go | 2 | ||||
-rw-r--r-- | ui/ui.go | 20 |
3 files changed, 17 insertions, 8 deletions
diff --git a/ui/managewindow.go b/ui/managewindow.go index 85c55844..c4d6dc3c 100644 --- a/ui/managewindow.go +++ b/ui/managewindow.go @@ -46,7 +46,8 @@ func NewManageTunnelsWindow() (*ManageTunnelsWindow, error) { mtw.SetLayout(walk.NewVBoxLayout()) mtw.Closing().Attach(func(canceled *bool, reason walk.CloseReason) { // "Close to tray" instead of exiting application - onQuit() + *canceled = true + mtw.Hide() }) mtw.VisibleChanged().Attach(func() { if mtw.Visible() { diff --git a/ui/tunnelspage.go b/ui/tunnelspage.go index a3ecf0c0..86ab1235 100644 --- a/ui/tunnelspage.go +++ b/ui/tunnelspage.go @@ -321,6 +321,8 @@ func (tp *TunnelsPage) onDelete() { } func (tp *TunnelsPage) onImport() { + tp.Form().Show() // Since the tray calls us sometimes, always make our parent visible. + dlg := walk.FileDialog{ Filter: "Configuration Files (*.zip, *.conf)|*.zip;*.conf|All Files (*.*)|*.*", Title: "Import tunnel(s) from file...", @@ -20,6 +20,8 @@ import "C" var iconProvider *IconProvider +var shouldQuitManagerWhenExiting = false + func RunUI() { runtime.LockOSThread() @@ -37,28 +39,32 @@ func RunUI() { walk.MsgBox(nil, "Unable to initialize icon provider", fmt.Sprint(err), walk.MsgBoxIconError) return } - defer iconProvider.Dispose() mtw, err := NewManageTunnelsWindow() if err != nil { panic(err) } - defer mtw.Dispose() tray, err := NewTray(mtw) if err != nil { panic(err) } - defer tray.Dispose() mtw.Run() + tray.Dispose() + mtw.Dispose() + iconProvider.Dispose() + + if shouldQuitManagerWhenExiting { + _, err := service.IPCClientQuit(true) + if err != nil { + walk.MsgBox(nil, "Error Exiting WireGuard", fmt.Sprintf("Unable to exit service due to: %s. You may want to stop WireGuard from the service manager.", err), walk.MsgBoxIconError) + } + } } func onQuit() { - _, err := service.IPCClientQuit(true) - if err != nil { - walk.MsgBox(nil, "Error Exiting WireGuard", fmt.Sprintf("Unable to exit service due to: %s. You may want to stop WireGuard from the service manager.", err), walk.MsgBoxIconError) - } + shouldQuitManagerWhenExiting = true walk.App().Exit(0) } |