mirror of
https://github.com/wailsapp/wails.git
synced 2025-05-19 02:19:31 +08:00
Remove a ton of unused code
This commit is contained in:
parent
a86fbbb440
commit
de06fc7dcc
@ -114,11 +114,7 @@ func (a *App) Run() error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Start the runtime
|
runtimesubsystem, err := subsystem.NewRuntime(a.servicebus, a.logger)
|
||||||
applicationMenu := options.GetApplicationMenu(a.options)
|
|
||||||
contextMenus := options.GetContextMenus(a.options)
|
|
||||||
|
|
||||||
runtimesubsystem, err := subsystem.NewRuntime(a.servicebus, a.logger, contextMenus)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -176,17 +172,15 @@ func (a *App) Run() error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Optionally start the menu subsystem
|
// Start the menu subsystem
|
||||||
if applicationMenu != nil {
|
menusubsystem, err := subsystem.NewMenu(a.servicebus, a.logger, a.menuManager)
|
||||||
menusubsystem, err := subsystem.NewMenu(a.servicebus, a.logger, a.menuManager)
|
if err != nil {
|
||||||
if err != nil {
|
return err
|
||||||
return err
|
}
|
||||||
}
|
a.menu = menusubsystem
|
||||||
a.menu = menusubsystem
|
err = a.menu.Start()
|
||||||
err = a.menu.Start()
|
if err != nil {
|
||||||
if err != nil {
|
return err
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Start the call subsystem
|
// Start the call subsystem
|
||||||
|
@ -185,22 +185,14 @@ func (c *Client) DarkModeEnabled(callbackID string) {
|
|||||||
C.DarkModeEnabled(c.app.app, c.app.string2CString(callbackID))
|
C.DarkModeEnabled(c.app.app, c.app.string2CString(callbackID))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Client) UpdateMenu(menuJSON string) {
|
func (c *Client) SetApplicationMenu(applicationMenuJSON string) {
|
||||||
C.SetApplicationMenu(c.app.app, c.app.string2CString(menuJSON))
|
C.SetApplicationMenu(c.app.app, c.app.string2CString(applicationMenuJSON))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Client) UpdateTrayMenu(trayMenuJSON string) {
|
func (c *Client) UpdateTrayMenu(trayMenuJSON string) {
|
||||||
C.UpdateTrayMenu(c.app.app, c.app.string2CString(trayMenuJSON))
|
C.UpdateTrayMenu(c.app.app, c.app.string2CString(trayMenuJSON))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Client) UpdateTrayLabel(label string) {
|
|
||||||
C.UpdateTrayLabel(c.app.app, c.app.string2CString(label))
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *Client) UpdateTrayIcon(name string) {
|
|
||||||
C.UpdateTrayIcon(c.app.app, c.app.string2CString(name))
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *Client) UpdateContextMenus(contextMenus *menu.ContextMenus) {
|
func (c *Client) UpdateContextMenus(contextMenus *menu.ContextMenus) {
|
||||||
//
|
//
|
||||||
// // Guard against nil contextMenus
|
// // Guard against nil contextMenus
|
||||||
|
@ -32,9 +32,7 @@ type Client interface {
|
|||||||
WindowUnFullscreen()
|
WindowUnFullscreen()
|
||||||
WindowSetColour(colour int)
|
WindowSetColour(colour int)
|
||||||
DarkModeEnabled(callbackID string)
|
DarkModeEnabled(callbackID string)
|
||||||
UpdateMenu(menuJSON string)
|
SetApplicationMenu(menuJSON string)
|
||||||
UpdateTrayLabel(label string)
|
|
||||||
UpdateTrayIcon(name string)
|
|
||||||
UpdateTrayMenu(menuJSON string)
|
UpdateTrayMenu(menuJSON string)
|
||||||
UpdateContextMenus(contextMenus *menu.ContextMenus)
|
UpdateContextMenus(contextMenus *menu.ContextMenus)
|
||||||
}
|
}
|
||||||
|
@ -452,7 +452,7 @@ func (d *Dispatcher) processMenuMessage(result *servicebus.Message) {
|
|||||||
// TODO: Work out what we mean in a multi window environment...
|
// TODO: Work out what we mean in a multi window environment...
|
||||||
// For now we will just pick the first one
|
// For now we will just pick the first one
|
||||||
for _, client := range d.clients {
|
for _, client := range d.clients {
|
||||||
client.frontend.UpdateMenu(updatedMenu)
|
client.frontend.SetApplicationMenu(updatedMenu)
|
||||||
}
|
}
|
||||||
|
|
||||||
case "updatetraymenu":
|
case "updatetraymenu":
|
||||||
|
@ -2,35 +2,32 @@ package runtime
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/wailsapp/wails/v2/internal/servicebus"
|
"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
|
// Runtime is a means for the user to interact with the application at runtime
|
||||||
type Runtime struct {
|
type Runtime struct {
|
||||||
Browser Browser
|
Browser Browser
|
||||||
Events Events
|
Events Events
|
||||||
Window Window
|
Window Window
|
||||||
Dialog Dialog
|
Dialog Dialog
|
||||||
System System
|
System System
|
||||||
Menu Menu
|
Menu Menu
|
||||||
ContextMenu ContextMenus
|
Store *StoreProvider
|
||||||
Store *StoreProvider
|
Log Log
|
||||||
Log Log
|
bus *servicebus.ServiceBus
|
||||||
bus *servicebus.ServiceBus
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// New creates a new runtime
|
// New creates a new runtime
|
||||||
func New(serviceBus *servicebus.ServiceBus, contextMenus *menu.ContextMenus) *Runtime {
|
func New(serviceBus *servicebus.ServiceBus) *Runtime {
|
||||||
result := &Runtime{
|
result := &Runtime{
|
||||||
Browser: newBrowser(),
|
Browser: newBrowser(),
|
||||||
Events: newEvents(serviceBus),
|
Events: newEvents(serviceBus),
|
||||||
Window: newWindow(serviceBus),
|
Window: newWindow(serviceBus),
|
||||||
Dialog: newDialog(serviceBus),
|
Dialog: newDialog(serviceBus),
|
||||||
System: newSystem(serviceBus),
|
System: newSystem(serviceBus),
|
||||||
Menu: newMenu(serviceBus),
|
Menu: newMenu(serviceBus),
|
||||||
ContextMenu: newContextMenus(serviceBus, contextMenus),
|
Log: newLog(serviceBus),
|
||||||
Log: newLog(serviceBus),
|
bus: serviceBus,
|
||||||
bus: serviceBus,
|
|
||||||
}
|
}
|
||||||
result.Store = newStore(result)
|
result.Store = newStore(result)
|
||||||
return result
|
return result
|
||||||
|
@ -2,7 +2,6 @@ package subsystem
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/wailsapp/wails/v2/pkg/menu"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/wailsapp/wails/v2/internal/logger"
|
"github.com/wailsapp/wails/v2/internal/logger"
|
||||||
@ -24,7 +23,7 @@ type Runtime struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NewRuntime creates a new runtime subsystem
|
// NewRuntime creates a new runtime subsystem
|
||||||
func NewRuntime(bus *servicebus.ServiceBus, logger *logger.Logger, contextMenus *menu.ContextMenus) (*Runtime, error) {
|
func NewRuntime(bus *servicebus.ServiceBus, logger *logger.Logger) (*Runtime, error) {
|
||||||
|
|
||||||
// Register quit channel
|
// Register quit channel
|
||||||
quitChannel, err := bus.Subscribe("quit")
|
quitChannel, err := bus.Subscribe("quit")
|
||||||
@ -42,7 +41,7 @@ func NewRuntime(bus *servicebus.ServiceBus, logger *logger.Logger, contextMenus
|
|||||||
quitChannel: quitChannel,
|
quitChannel: quitChannel,
|
||||||
runtimeChannel: runtimeChannel,
|
runtimeChannel: runtimeChannel,
|
||||||
logger: logger.CustomLogger("Runtime Subsystem"),
|
logger: logger.CustomLogger("Runtime Subsystem"),
|
||||||
runtime: runtime.New(bus, contextMenus),
|
runtime: runtime.New(bus),
|
||||||
}
|
}
|
||||||
|
|
||||||
return result, nil
|
return result, nil
|
||||||
|
Loading…
Reference in New Issue
Block a user