aboutsummaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2019-06-19 19:32:15 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2019-06-26 13:28:17 +0200
commitee7592f8f46660260b6d265d69410c8e6617f4fa (patch)
tree2385ecf6defd321f9fb07b0886dfa4bc02f4d9b9 /ui
parentui: avoid flicker on toolbar when closing modal (diff)
downloadwireguard-windows-ee7592f8f46660260b6d265d69410c8e6617f4fa.tar.xz
wireguard-windows-ee7592f8f46660260b6d265d69410c8e6617f4fa.zip
ui: bind shortcuts using new api
Diffstat (limited to 'ui')
-rw-r--r--ui/logpage.go5
-rw-r--r--ui/tunnelspage.go8
2 files changed, 8 insertions, 5 deletions
diff --git a/ui/logpage.go b/ui/logpage.go
index 2356c4d1..9410875f 100644
--- a/ui/logpage.go
+++ b/ui/logpage.go
@@ -53,24 +53,25 @@ func NewLogPage() (*LogPage, error) {
copyAction.SetShortcut(walk.Shortcut{walk.ModControl, walk.KeyC})
copyAction.Triggered().Attach(lp.onCopy)
contextMenu.Actions().Add(copyAction)
+ lp.ShortcutActions().Add(copyAction)
selectAllAction := walk.NewAction()
selectAllAction.SetText("Select &all")
selectAllAction.SetShortcut(walk.Shortcut{walk.ModControl, walk.KeyA})
selectAllAction.Triggered().Attach(lp.onSelectAll)
contextMenu.Actions().Add(selectAllAction)
+ lp.ShortcutActions().Add(selectAllAction)
saveAction := walk.NewAction()
saveAction.SetText("&Save to file")
saveAction.SetShortcut(walk.Shortcut{walk.ModControl, walk.KeyS})
saveAction.Triggered().Attach(lp.onSave)
contextMenu.Actions().Add(saveAction)
+ lp.ShortcutActions().Add(saveAction)
lp.logView.SetContextMenu(contextMenu)
setSelectionStatus := func() {
copyAction.SetEnabled(len(lp.logView.SelectedIndexes()) > 0)
selectAllAction.SetEnabled(len(lp.logView.SelectedIndexes()) < len(lp.model.items))
}
lp.logView.SelectedIndexesChanged().Attach(setSelectionStatus)
- contextMenu.Actions().AttachShortcuts(lp.logView)
- contextMenu.Actions().AttachShortcuts(lp)
stampCol := walk.NewTableViewColumn()
stampCol.SetName("Stamp")
diff --git a/ui/tunnelspage.go b/ui/tunnelspage.go
index ab3e2d48..26a0a291 100644
--- a/ui/tunnelspage.go
+++ b/ui/tunnelspage.go
@@ -185,11 +185,13 @@ func (tp *TunnelsPage) CreateToolbar() {
importAction2.SetShortcut(walk.Shortcut{walk.ModControl, walk.KeyO})
importAction2.Triggered().Attach(tp.onImport)
contextMenu.Actions().Add(importAction2)
+ tp.ShortcutActions().Add(importAction2)
addAction2 := walk.NewAction()
addAction2.SetText("Add empty tunnel...")
addAction2.SetShortcut(walk.Shortcut{walk.ModControl, walk.KeyN})
addAction2.Triggered().Attach(tp.onAddTunnel)
contextMenu.Actions().Add(addAction2)
+ tp.ShortcutActions().Add(addAction2)
exportAction2 := walk.NewAction()
exportAction2.SetText("Export all tunnels to zip...")
exportAction2.Triggered().Attach(tp.onExportTunnels)
@@ -200,6 +202,7 @@ func (tp *TunnelsPage) CreateToolbar() {
editAction.SetShortcut(walk.Shortcut{walk.ModControl, walk.KeyE})
editAction.Triggered().Attach(tp.onEditTunnel)
contextMenu.Actions().Add(editAction)
+ tp.ShortcutActions().Add(editAction)
cloneAction := walk.NewAction()
cloneAction.SetText("Clone selected tunnel...")
cloneAction.Triggered().Attach(tp.onCloneTunnel)
@@ -209,17 +212,16 @@ func (tp *TunnelsPage) CreateToolbar() {
deleteAction2.SetShortcut(walk.Shortcut{0, walk.KeyDelete})
deleteAction2.Triggered().Attach(tp.onDelete)
contextMenu.Actions().Add(deleteAction2)
+ tp.listView.ShortcutActions().Add(deleteAction2)
tp.listView.SetContextMenu(contextMenu)
selectAllAction := walk.NewAction()
selectAllAction.SetText("Select all")
selectAllAction.SetShortcut(walk.Shortcut{walk.ModControl, walk.KeyA})
selectAllAction.Triggered().Attach(tp.onSelectAll)
contextMenu.Actions().Add(selectAllAction)
+ tp.listView.ShortcutActions().Add(selectAllAction)
tp.listView.SetContextMenu(contextMenu)
- contextMenu.Actions().AttachShortcuts(tp.listView)
- contextMenu.Actions().AttachShortcuts(tp)
-
setSelectionOrientedOptions := func() {
selected := len(tp.listView.SelectedIndexes())
all := len(tp.listView.model.tunnels)