From e1754d6fe872bb20189a5e93f7bca0f8547e167a Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Sat, 4 May 2019 00:36:44 +0200 Subject: ui: specify default action in tray Signed-off-by: Jason A. Donenfeld --- ui/tray.go | 5 +++-- ui/tunnelspage.go | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/ui/tray.go b/ui/tray.go index 44d63d2b..4a11984a 100644 --- a/ui/tray.go +++ b/ui/tray.go @@ -63,12 +63,13 @@ func (tray *Tray) setup() error { enabled bool hidden bool separator bool + defawlt bool }{ {label: "Status: Unknown"}, {label: "Networks: None", hidden: true}, {separator: true}, {separator: true}, - {label: "&Manage tunnels...", handler: tray.onManageTunnels, enabled: true}, + {label: "&Manage tunnels...", handler: tray.onManageTunnels, enabled: true, defawlt: true}, {label: "&Import tunnel(s) from file...", handler: tray.mtw.tunnelsPage.onImport, enabled: true}, {separator: true}, {label: "&About WireGuard", handler: func() { onAbout(tray.mtw) }, enabled: true}, @@ -82,6 +83,7 @@ func (tray *Tray) setup() error { action.SetText(item.label) action.SetEnabled(item.enabled) action.SetVisible(!item.hidden) + action.SetDefault(item.defawlt) if item.handler != nil { action.Triggered().Attach(item.handler) } @@ -292,7 +294,6 @@ func (tray *Tray) UpdateFound() { if icon, err := iconProvider.UpdateAvailableImage(); err == nil { action.SetImage(icon) } - //TODO: Make bold action.Triggered().Attach(func() { tray.mtw.Show() tray.mtw.tabs.SetCurrentIndex(2) diff --git a/ui/tunnelspage.go b/ui/tunnelspage.go index 18e9e255..dc86d776 100644 --- a/ui/tunnelspage.go +++ b/ui/tunnelspage.go @@ -134,6 +134,7 @@ func (tp *TunnelsPage) CreateToolbar() { importActionImage, _ := walk.NewBitmapFromIcon(importActionIcon, imageSize) importAction.SetImage(importActionImage) importAction.SetShortcut(walk.Shortcut{walk.ModControl, walk.KeyO}) + importAction.SetDefault(true) importAction.Triggered().Attach(tp.onImport) addAction := walk.NewAction() addAction.SetText("Add empty tunnel") -- cgit v1.2.3-59-g8ed1b