Skip to content
This repository has been archived by the owner on Feb 1, 2024. It is now read-only.

Commit

Permalink
Kelp GUI: allow copy paste keyboard shortcuts and add to menu bar alo…
Browse files Browse the repository at this point in the history
…ng with Quit option
  • Loading branch information
nikhilsaraf committed Apr 27, 2020
1 parent 79f8028 commit 3dfb14a
Showing 1 changed file with 26 additions and 9 deletions.
35 changes: 26 additions & 9 deletions cmd/server_amd64.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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 {
Expand Down

0 comments on commit 3dfb14a

Please sign in to comment.