From 29cff0115268ba5b21613a922f18555a7c34ec21 Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Sun, 5 May 2019 13:51:26 +0200 Subject: ui: improve update logging and tray logic --- ui/aboutdialog.go | 2 +- ui/managewindow.go | 1 + ui/tray.go | 17 +++++++++++++++-- ui/tunnelspage.go | 2 -- 4 files changed, 17 insertions(+), 5 deletions(-) (limited to 'ui') diff --git a/ui/aboutdialog.go b/ui/aboutdialog.go index 0b6a294d..da8f7f9f 100644 --- a/ui/aboutdialog.go +++ b/ui/aboutdialog.go @@ -31,7 +31,7 @@ func onAbout(owner walk.Form) { dlg.SetFont(font) iv, _ := walk.NewImageView(dlg) - logo, _ := walk.NewIconFromResourceWithSize("$wireguard.ico", walk.Size{owner.DPI() * 4 / 3, owner.DPI() * 4 / 3}) //TODO: calculate DPI dynamically + logo, _ := walk.NewIconFromResourceWithSize("$wireguard.ico", walk.Size{dlg.DPI() * 4 / 3, dlg.DPI() * 4 / 3}) //TODO: calculate DPI dynamically iv.SetCursor(walk.CursorHand()) iv.MouseUp().Attach(func(x, y int, button walk.MouseButton) { if button == walk.LeftButton { diff --git a/ui/managewindow.go b/ui/managewindow.go index 5e14419a..dd2de7f5 100644 --- a/ui/managewindow.go +++ b/ui/managewindow.go @@ -118,6 +118,7 @@ func (mtw *ManageTunnelsWindow) UpdateFound() { if mtw.updatePage != nil { return } + mtw.SetTitle(mtw.Title() + " (out of date)") updatePage, err := NewUpdatePage() if err == nil { mtw.updatePage = updatePage diff --git a/ui/tray.go b/ui/tray.go index 0597f589..c5902359 100644 --- a/ui/tray.go +++ b/ui/tray.go @@ -73,9 +73,9 @@ func (tray *Tray) setup() error { {separator: true}, {separator: true}, {label: "&Manage tunnels...", handler: tray.onManageTunnels, enabled: true, defawlt: true}, - {label: "&Import tunnel(s) from file...", handler: tray.mtw.tunnelsPage.onImport, enabled: true}, + {label: "&Import tunnel(s) from file...", handler: tray.onImport, enabled: true}, {separator: true}, - {label: "&About WireGuard", handler: func() { onAbout(tray.mtw) }, enabled: true}, + {label: "&About WireGuard", handler: tray.onAbout, enabled: true}, {label: "&Exit", handler: onQuit, enabled: true}, } { var action *walk.Action @@ -320,3 +320,16 @@ func (tray *Tray) onManageTunnels() { } tray.mtw.Show() } + +func (tray *Tray) onAbout() { + if tray.mtw.Visible() { + onAbout(tray.mtw) + } else { + onAbout(nil) + } +} + +func (tray *Tray) onImport() { + tray.mtw.Show() + tray.mtw.tunnelsPage.onImport() +} diff --git a/ui/tunnelspage.go b/ui/tunnelspage.go index dc86d776..a4bbcd79 100644 --- a/ui/tunnelspage.go +++ b/ui/tunnelspage.go @@ -444,8 +444,6 @@ 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...", -- cgit v1.2.3-59-g8ed1b