diff --git a/v2/internal/runtime/runtime.go b/v2/internal/runtime/runtime.go index 4452a761c..bbc413fff 100644 --- a/v2/internal/runtime/runtime.go +++ b/v2/internal/runtime/runtime.go @@ -21,7 +21,7 @@ type Runtime struct { } // New creates a new runtime -func New(serviceBus *servicebus.ServiceBus, menu *menu.Menu, trayMenu *menu.TrayOptions, contextMenus *menu.ContextMenus) *Runtime { +func New(serviceBus *servicebus.ServiceBus, menu *menu.Menu, trayMenu *menu.Tray, contextMenus *menu.ContextMenus) *Runtime { result := &Runtime{ Browser: newBrowser(), Events: newEvents(serviceBus), diff --git a/v2/internal/runtime/tray.go b/v2/internal/runtime/tray.go index 07d96f979..f0dd6eb28 100644 --- a/v2/internal/runtime/tray.go +++ b/v2/internal/runtime/tray.go @@ -8,8 +8,9 @@ import ( // Tray defines all Tray related operations type Tray interface { + NewTray(id string) *menu.Tray On(menuID string, callback func(*menu.MenuItem)) - Update() + Update(tray ...*menu.Tray) GetByID(menuID string) *menu.MenuItem RemoveByID(id string) bool SetLabel(label string) @@ -18,11 +19,11 @@ type Tray interface { type trayRuntime struct { bus *servicebus.ServiceBus - trayMenu *menu.TrayOptions + trayMenu *menu.Tray } // newTray creates a new Menu struct -func newTray(bus *servicebus.ServiceBus, menu *menu.TrayOptions) Tray { +func newTray(bus *servicebus.ServiceBus, menu *menu.Tray) Tray { return &trayRuntime{ bus: bus, trayMenu: menu, @@ -37,7 +38,16 @@ func (t *trayRuntime) On(menuID string, callback func(*menu.MenuItem)) { }) } -func (t *trayRuntime) Update() { +// NewTray creates a new Tray item +func (t *trayRuntime) NewTray(trayID string) *menu.Tray { + return &menu.Tray{ + ID: trayID, + } +} + +func (t *trayRuntime) Update(tray ...*menu.Tray) { + + //trayToUpdate := t.trayMenu t.bus.Publish("tray:update", t.trayMenu) } diff --git a/v2/internal/subsystem/runtime.go b/v2/internal/subsystem/runtime.go index 257db3919..878cfcd28 100644 --- a/v2/internal/subsystem/runtime.go +++ b/v2/internal/subsystem/runtime.go @@ -24,7 +24,7 @@ type Runtime struct { } // NewRuntime creates a new runtime subsystem -func NewRuntime(bus *servicebus.ServiceBus, logger *logger.Logger, menu *menu.Menu, trayMenu *menu.TrayOptions, contextMenus *menu.ContextMenus) (*Runtime, error) { +func NewRuntime(bus *servicebus.ServiceBus, logger *logger.Logger, menu *menu.Menu, trayMenu *menu.Tray, contextMenus *menu.ContextMenus) (*Runtime, error) { // Register quit channel quitChannel, err := bus.Subscribe("quit") diff --git a/v2/internal/subsystem/tray.go b/v2/internal/subsystem/tray.go index 1da5fde58..8baee96de 100644 --- a/v2/internal/subsystem/tray.go +++ b/v2/internal/subsystem/tray.go @@ -26,14 +26,14 @@ type Tray struct { logger logger.CustomLogger // The tray menu - trayMenu *menu.TrayOptions + trayMenu *menu.Tray // Service Bus bus *servicebus.ServiceBus } // NewTray creates a new menu subsystem -func NewTray(trayMenu *menu.TrayOptions, bus *servicebus.ServiceBus, +func NewTray(trayMenu *menu.Tray, bus *servicebus.ServiceBus, logger *logger.Logger) (*Tray, error) { // Register quit channel diff --git a/v2/pkg/menu/trayoptions.go b/v2/pkg/menu/tray.go similarity index 84% rename from v2/pkg/menu/trayoptions.go rename to v2/pkg/menu/tray.go index b058097d8..1701daf85 100644 --- a/v2/pkg/menu/trayoptions.go +++ b/v2/pkg/menu/tray.go @@ -1,7 +1,11 @@ package menu -// TrayOptions are the options -type TrayOptions struct { +// Tray are the options +type Tray struct { + + // The ID of this tray + ID string + // Label is the text we wish to display in the tray Label string diff --git a/v2/pkg/options/mac/mac.go b/v2/pkg/options/mac/mac.go index da0be63b9..2c74c8fe6 100644 --- a/v2/pkg/options/mac/mac.go +++ b/v2/pkg/options/mac/mac.go @@ -9,6 +9,6 @@ type Options struct { WebviewIsTransparent bool WindowBackgroundIsTranslucent bool Menu *menu.Menu - Tray *menu.TrayOptions + Tray *menu.Tray ContextMenus *menu.ContextMenus } diff --git a/v2/pkg/options/options.go b/v2/pkg/options/options.go index f1fba76cb..f37808d1b 100644 --- a/v2/pkg/options/options.go +++ b/v2/pkg/options/options.go @@ -25,7 +25,7 @@ type App struct { DevTools bool RGBA int ContextMenus *menu.ContextMenus - Tray *menu.TrayOptions + Tray *menu.Tray Menu *menu.Menu Mac *mac.Options Logger logger.Logger `json:"-"` @@ -41,8 +41,8 @@ func MergeDefaults(appoptions *App) { } -func GetTray(appoptions *App) *menu.TrayOptions { - var result *menu.TrayOptions +func GetTray(appoptions *App) *menu.Tray { + var result *menu.Tray switch runtime.GOOS { case "darwin": if appoptions.Mac != nil { diff --git a/v2/test/kitchensink/main.go b/v2/test/kitchensink/main.go index b3f3adfe4..c72a95174 100644 --- a/v2/test/kitchensink/main.go +++ b/v2/test/kitchensink/main.go @@ -28,7 +28,7 @@ func main() { // Comment out line below to see Window.SetTitle() work TitleBar: mac.TitleBarHiddenInset(), Menu: createApplicationMenu(), - Tray: &menu.TrayOptions{ + Tray: &menu.Tray{ Icon: "light", Menu: createApplicationTray(), },