MCPcopy
hub / github.com/matryer/xbar / newXbarMenu

Method newXbarMenu

app/app.go:337–430  ·  view source on GitHub ↗
(plugin *plugins.Plugin, asSubmenu bool)

Source from the content-addressed store, hash-verified

335}
336
337func (app *app) newXbarMenu(plugin *plugins.Plugin, asSubmenu bool) *menu.Menu {
338 var items []*menu.MenuItem
339 if plugin != nil {
340 items = append(items, &menu.MenuItem{
341 Type: menu.TextType,
342 Label: "Refresh",
343 Accelerator: keys.CmdOrCtrl("r"),
344 Click: func(ctx *menu.CallbackData) {
345 app.onPluginsRefreshMenuClicked(ctx, plugin)
346 },
347 })
348 }
349 items = append(items, &menu.MenuItem{
350 Type: menu.TextType,
351 Label: "Refresh all",
352 Accelerator: keys.Combo("r", keys.CmdOrCtrlKey, keys.ShiftKey),
353 Click: app.onPluginsRefreshAllMenuClicked,
354 })
355 if plugin != nil {
356 items = append(items, menu.Text("Run in terminal…", keys.CmdOrCtrl("t"), func(_ *menu.CallbackData) {
357 err := plugin.RunInTerminal(app.settings.Terminal.AppleScriptTemplate3)
358 if err != nil {
359 _, err2 := app.runtime.Dialog.Message(&dialog.MessageDialog{
360 Type: dialog.ErrorDialog,
361 Title: "Run in terminal",
362 Message: err.Error(),
363 Buttons: []string{"OK"},
364 CancelButton: "OK",
365 })
366 if err2 != nil {
367 log.Println(err2)
368 return
369 }
370 return
371 }
372 }))
373 }
374 items = append(items, menu.Separator())
375 if plugin != nil {
376 items = append(items, &menu.MenuItem{
377 Type: menu.TextType,
378 Label: "Open plugin…",
379 Accelerator: keys.CmdOrCtrl("e"),
380 Click: func(_ *menu.CallbackData) {
381 app.runtime.Window.Show()
382 rel, err := filepath.Rel(pluginDirectory, plugin.Command)
383 if err != nil {
384 log.Println(err)
385 return
386 }
387 app.runtime.Events.Emit("xbar.browser.openInstalledPlugin", map[string]string{
388 "path": rel,
389 })
390 },
391 })
392 }
393 items = append(items, &menu.MenuItem{
394 Type: menu.TextType,

Callers 5

newAppFunction · 0.95
RefreshAllMethod · 0.95
onErrMethod · 0.95
createDefaultMenusMethod · 0.95
onRefreshMethod · 0.95

Calls 3

RunInTerminalMethod · 0.80
ErrorMethod · 0.45

Tested by

no test coverage detected