From 3dfb14a3dffcea2ddeb474501cc24185158f0932 Mon Sep 17 00:00:00 2001 From: Nikhil Saraf <1028334+nikhilsaraf@users.noreply.github.com> Date: Mon, 27 Apr 2020 17:54:57 +0530 Subject: [PATCH] Kelp GUI: allow copy paste keyboard shortcuts and add to menu bar along with Quit option --- cmd/server_amd64.go | 35 ++++++++++++++++++++++++++--------- 1 file changed, 26 insertions(+), 9 deletions(-) diff --git a/cmd/server_amd64.go b/cmd/server_amd64.go index f320999e6..a8b6eb2a8 100644 --- a/cmd/server_amd64.go +++ b/cmd/server_amd64.go @@ -565,6 +565,28 @@ func openBrowser(url string, openBrowserWg *sync.WaitGroup) { func openElectron(trayIconPath *kelpos.OSPath, url string) { log.Printf("opening URL in electron: %s", url) + quitMenuItemOption := &astilectron.MenuItemOptions{ + Label: astilectron.PtrStr("Quit"), + Visible: astilectron.PtrBool(true), + Enabled: astilectron.PtrBool(true), + OnClick: astilectron.Listener(func(e astilectron.Event) (deleteListener bool) { + quit() + return false + }), + } + mainMenuItemOptions := []*astilectron.MenuItemOptions{ + &astilectron.MenuItemOptions{ + Label: astilectron.PtrStr("File"), + SubMenu: []*astilectron.MenuItemOptions{ + quitMenuItemOption, + }, + }, + &astilectron.MenuItemOptions{ + Label: astilectron.PtrStr("Edit"), + Role: astilectron.MenuItemRoleEditMenu, + }, + } + e := bootstrap.Run(bootstrap.Options{ AstilectronOptions: astilectron.Options{ AppName: "Kelp", @@ -585,15 +607,10 @@ func openElectron(trayIconPath *kelpos.OSPath, url string) { Image: astilectron.PtrStr(trayIconPath.Native()), }, TrayMenuOptions: []*astilectron.MenuItemOptions{ - &astilectron.MenuItemOptions{ - Label: astilectron.PtrStr("Quit"), - Visible: astilectron.PtrBool(true), - Enabled: astilectron.PtrBool(true), - OnClick: astilectron.Listener(func(e astilectron.Event) (deleteListener bool) { - quit() - return false - }), - }, + quitMenuItemOption, + }, + MenuOptions: []*astilectron.MenuItemOptions{ + &astilectron.MenuItemOptions{SubMenu: mainMenuItemOptions}, }, }) if e != nil {