mirror of
https://github.com/taigrr/wails.git
synced 2026-04-17 12:15:02 -07:00
[WIP] Support tray in menu manager
This commit is contained in:
@@ -2,7 +2,6 @@ package runtime
|
||||
|
||||
import (
|
||||
"github.com/wailsapp/wails/v2/internal/servicebus"
|
||||
"github.com/wailsapp/wails/v2/pkg/menu"
|
||||
)
|
||||
|
||||
// Menu defines all Menu related operations
|
||||
@@ -11,15 +10,13 @@ type Menu interface {
|
||||
}
|
||||
|
||||
type menuRuntime struct {
|
||||
bus *servicebus.ServiceBus
|
||||
menu *menu.Menu
|
||||
bus *servicebus.ServiceBus
|
||||
}
|
||||
|
||||
// newMenu creates a new Menu struct
|
||||
func newMenu(bus *servicebus.ServiceBus, menu *menu.Menu) Menu {
|
||||
func newMenu(bus *servicebus.ServiceBus) Menu {
|
||||
return &menuRuntime{
|
||||
bus: bus,
|
||||
menu: menu,
|
||||
bus: bus,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -14,22 +14,20 @@ type Runtime struct {
|
||||
System System
|
||||
Menu Menu
|
||||
ContextMenu ContextMenus
|
||||
Tray Tray
|
||||
Store *StoreProvider
|
||||
Log Log
|
||||
bus *servicebus.ServiceBus
|
||||
}
|
||||
|
||||
// New creates a new runtime
|
||||
func New(serviceBus *servicebus.ServiceBus, menu *menu.Menu, trayMenu *menu.Tray, contextMenus *menu.ContextMenus) *Runtime {
|
||||
func New(serviceBus *servicebus.ServiceBus, contextMenus *menu.ContextMenus) *Runtime {
|
||||
result := &Runtime{
|
||||
Browser: newBrowser(),
|
||||
Events: newEvents(serviceBus),
|
||||
Window: newWindow(serviceBus),
|
||||
Dialog: newDialog(serviceBus),
|
||||
System: newSystem(serviceBus),
|
||||
Menu: newMenu(serviceBus, menu),
|
||||
Tray: newTray(serviceBus, trayMenu),
|
||||
Menu: newMenu(serviceBus),
|
||||
ContextMenu: newContextMenus(serviceBus, contextMenus),
|
||||
Log: newLog(serviceBus),
|
||||
bus: serviceBus,
|
||||
|
||||
@@ -8,9 +8,8 @@ import (
|
||||
|
||||
// Tray defines all Tray related operations
|
||||
type Tray interface {
|
||||
NewTray(id string) *menu.Tray
|
||||
On(menuID string, callback func(*menu.MenuItem))
|
||||
Update(tray ...*menu.Tray)
|
||||
Update(tray ...*menu.TrayMenu)
|
||||
GetByID(menuID string) *menu.MenuItem
|
||||
RemoveByID(id string) bool
|
||||
SetLabel(label string)
|
||||
@@ -19,11 +18,11 @@ type Tray interface {
|
||||
|
||||
type trayRuntime struct {
|
||||
bus *servicebus.ServiceBus
|
||||
trayMenu *menu.Tray
|
||||
trayMenu *menu.TrayMenu
|
||||
}
|
||||
|
||||
// newTray creates a new Menu struct
|
||||
func newTray(bus *servicebus.ServiceBus, menu *menu.Tray) Tray {
|
||||
func newTray(bus *servicebus.ServiceBus, menu *menu.TrayMenu) Tray {
|
||||
return &trayRuntime{
|
||||
bus: bus,
|
||||
trayMenu: menu,
|
||||
@@ -38,14 +37,7 @@ func (t *trayRuntime) On(menuID string, callback func(*menu.MenuItem)) {
|
||||
})
|
||||
}
|
||||
|
||||
// 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) {
|
||||
func (t *trayRuntime) Update(tray ...*menu.TrayMenu) {
|
||||
|
||||
//trayToUpdate := t.trayMenu
|
||||
t.bus.Publish("tray:update", t.trayMenu)
|
||||
|
||||
Reference in New Issue
Block a user