5
0
mirror of https://github.com/wailsapp/wails.git synced 2025-05-03 17:41:24 +08:00
wails/v2/internal/runtime/runtime.go
Lea Anthony b837b1e131
Tray menu support
Bugfix move after tray use
Refactored options to handle default tray/menu
2020-12-10 07:16:10 +11:00

43 lines
990 B
Go

package runtime
import (
"github.com/wailsapp/wails/v2/internal/servicebus"
"github.com/wailsapp/wails/v2/pkg/menu"
)
// Runtime is a means for the user to interact with the application at runtime
type Runtime struct {
Browser Browser
Events Events
Window Window
Dialog Dialog
System System
Menu Menu
Tray Tray
Store *StoreProvider
Log Log
bus *servicebus.ServiceBus
}
// New creates a new runtime
func New(serviceBus *servicebus.ServiceBus, menu *menu.Menu, trayMenu *menu.Menu) *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),
Log: newLog(serviceBus),
bus: serviceBus,
}
result.Store = newStore(result)
return result
}
// Quit the application
func (r *Runtime) Quit() {
r.bus.Publish("quit", "runtime.Quit()")
}