diff --git a/v2/pkg/runtime/Events/events.go b/v2/pkg/runtime/Events/events.go index d51a61c85..cdc0daaa5 100644 --- a/v2/pkg/runtime/Events/events.go +++ b/v2/pkg/runtime/Events/events.go @@ -1,3 +1,5 @@ +// +build !experimental + package events import ( diff --git a/v2/pkg/runtime/dialog/dialog.go b/v2/pkg/runtime/dialog/dialog.go index 9622502e9..2c2b33432 100644 --- a/v2/pkg/runtime/dialog/dialog.go +++ b/v2/pkg/runtime/dialog/dialog.go @@ -77,10 +77,8 @@ func processTitleAndFilter(params ...string) (string, string) { return title, filter } -type Dialog struct{} - // OpenDirectory prompts the user to select a directory -func (d *Dialog) OpenDirectory(ctx context.Context, dialogOptions OpenDialogOptions) (string, error) { +func OpenDirectory(ctx context.Context, dialogOptions OpenDialogOptions) (string, error) { bus := servicebus.ExtractBus(ctx) @@ -107,7 +105,7 @@ func (d *Dialog) OpenDirectory(ctx context.Context, dialogOptions OpenDialogOpti } // OpenFile prompts the user to select a file -func (d *Dialog) OpenFile(ctx context.Context, dialogOptions OpenDialogOptions) (string, error) { +func OpenFile(ctx context.Context, dialogOptions OpenDialogOptions) (string, error) { bus := servicebus.ExtractBus(ctx) @@ -134,7 +132,7 @@ func (d *Dialog) OpenFile(ctx context.Context, dialogOptions OpenDialogOptions) } // OpenMultipleFiles prompts the user to select a file -func (d *Dialog) OpenMultipleFiles(ctx context.Context, dialogOptions OpenDialogOptions) ([]string, error) { +func OpenMultipleFiles(ctx context.Context, dialogOptions OpenDialogOptions) ([]string, error) { bus := servicebus.ExtractBus(ctx) uniqueCallback := crypto.RandomID() @@ -159,7 +157,7 @@ func (d *Dialog) OpenMultipleFiles(ctx context.Context, dialogOptions OpenDialog } // SaveFile prompts the user to select a file -func (d *Dialog) SaveFile(ctx context.Context, dialogOptions SaveDialogOptions) (string, error) { +func SaveFile(ctx context.Context, dialogOptions SaveDialogOptions) (string, error) { bus := servicebus.ExtractBus(ctx) uniqueCallback := crypto.RandomID() @@ -184,7 +182,7 @@ func (d *Dialog) SaveFile(ctx context.Context, dialogOptions SaveDialogOptions) } // Message show a message to the user -func (d *Dialog) Message(ctx context.Context, dialogOptions MessageDialogOptions) (string, error) { +func Message(ctx context.Context, dialogOptions MessageDialogOptions) (string, error) { bus := servicebus.ExtractBus(ctx) diff --git a/v2/pkg/runtime/log/log.go b/v2/pkg/runtime/log/log.go index 38800d9ff..1c3e40010 100644 --- a/v2/pkg/runtime/log/log.go +++ b/v2/pkg/runtime/log/log.go @@ -8,52 +8,50 @@ import ( "github.com/wailsapp/wails/v2/pkg/logger" ) -type Log struct{} - // Print prints a Print level message -func (l *Log) Print(ctx context.Context, message string) { +func Print(ctx context.Context, message string) { bus := servicebus.ExtractBus(ctx) bus.Publish("log:print", message) } // Trace prints a Trace level message -func (l *Log) Trace(ctx context.Context, message string) { +func Trace(ctx context.Context, message string) { bus := servicebus.ExtractBus(ctx) bus.Publish("log:trace", message) } // Debug prints a Debug level message -func (l *Log) Debug(ctx context.Context, message string) { +func Debug(ctx context.Context, message string) { bus := servicebus.ExtractBus(ctx) bus.Publish("log:debug", message) } // Info prints a Info level message -func (l *Log) Info(ctx context.Context, message string) { +func Info(ctx context.Context, message string) { bus := servicebus.ExtractBus(ctx) bus.Publish("log:info", message) } // Warning prints a Warning level message -func (l *Log) Warning(ctx context.Context, message string) { +func Warning(ctx context.Context, message string) { bus := servicebus.ExtractBus(ctx) bus.Publish("log:warning", message) } // Error prints a Error level message -func (l *Log) Error(ctx context.Context, message string) { +func Error(ctx context.Context, message string) { bus := servicebus.ExtractBus(ctx) bus.Publish("log:error", message) } // Fatal prints a Fatal level message -func (l *Log) Fatal(ctx context.Context, message string) { +func Fatal(ctx context.Context, message string) { bus := servicebus.ExtractBus(ctx) bus.Publish("log:fatal", message) } // SetLogLevel sets the log level -func (l *Log) SetLogLevel(ctx context.Context, level logger.LogLevel) { +func SetLogLevel(ctx context.Context, level logger.LogLevel) { bus := servicebus.ExtractBus(ctx) bus.Publish("log:setlevel", level) } diff --git a/v2/pkg/runtime/menu/menu.go b/v2/pkg/runtime/menu/menu.go index 7f1fe521a..e9876b5b4 100644 --- a/v2/pkg/runtime/menu/menu.go +++ b/v2/pkg/runtime/menu/menu.go @@ -1,3 +1,5 @@ +// +build !experimental\ + package menu import ( diff --git a/v2/pkg/runtime/runtime.go b/v2/pkg/runtime/runtime.go deleted file mode 100644 index 491a280c7..000000000 --- a/v2/pkg/runtime/runtime.go +++ /dev/null @@ -1,17 +0,0 @@ -package runtime - -import ( - "github.com/wailsapp/wails/v2/pkg/runtime/dialog" - "github.com/wailsapp/wails/v2/pkg/runtime/events" - "github.com/wailsapp/wails/v2/pkg/runtime/log" - "github.com/wailsapp/wails/v2/pkg/runtime/menu" - "github.com/wailsapp/wails/v2/pkg/runtime/window" -) - -var ( - Window = window.Window{} - Menu = menu.Menu{} - Log = log.Log{} - Events = events.Events{} - Dialog = dialog.Dialog{} -) diff --git a/v2/pkg/runtime/system/system.go b/v2/pkg/runtime/system/system.go index 9cdb05365..235c4aaf5 100644 --- a/v2/pkg/runtime/system/system.go +++ b/v2/pkg/runtime/system/system.go @@ -7,10 +7,8 @@ import ( "github.com/wailsapp/wails/v2/internal/servicebus" ) -type System struct{} - // Quit the application -func (s *System) Quit(ctx context.Context) { +func Quit(ctx context.Context) { bus := servicebus.ExtractBus(ctx) // Start shutdown of Wails bus.Publish("quit", "runtime.Quit()") diff --git a/v2/pkg/runtime/window/window.go b/v2/pkg/runtime/window/window.go index 6a154cd0e..fd5db3172 100644 --- a/v2/pkg/runtime/window/window.go +++ b/v2/pkg/runtime/window/window.go @@ -9,92 +9,90 @@ import ( "github.com/wailsapp/wails/v2/internal/servicebus" ) -type Window struct{} - // SetTitle sets the title of the window -func (w *Window) SetTitle(ctx context.Context, title string) { +func SetTitle(ctx context.Context, title string) { bus := servicebus.ExtractBus(ctx) bus.Publish("window:settitle", title) } // Fullscreen makes the window fullscreen -func (w *Window) Fullscreen(ctx context.Context) { +func Fullscreen(ctx context.Context) { bus := servicebus.ExtractBus(ctx) bus.Publish("window:fullscreen", "") } // UnFullscreen makes the window UnFullscreen -func (w *Window) UnFullscreen(ctx context.Context) { +func UnFullscreen(ctx context.Context) { bus := servicebus.ExtractBus(ctx) bus.Publish("window:unfullscreen", "") } // Center the window on the current screen -func (w *Window) Center(ctx context.Context) { +func Center(ctx context.Context) { bus := servicebus.ExtractBus(ctx) bus.Publish("window:center", "") } // Show shows the window if hidden -func (w *Window) Show(ctx context.Context) { +func Show(ctx context.Context) { bus := servicebus.ExtractBus(ctx) bus.Publish("window:show", "") } // Hide the window -func (w *Window) Hide(ctx context.Context) { +func Hide(ctx context.Context) { bus := servicebus.ExtractBus(ctx) bus.Publish("window:hide", "") } // SetSize sets the size of the window -func (w *Window) SetSize(ctx context.Context, width int, height int) { +func SetSize(ctx context.Context, width int, height int) { bus := servicebus.ExtractBus(ctx) message := fmt.Sprintf("window:size:%d:%d", width, height) bus.Publish(message, "") } // SetSize sets the size of the window -func (w *Window) SetMinSize(ctx context.Context, width int, height int) { +func SetMinSize(ctx context.Context, width int, height int) { bus := servicebus.ExtractBus(ctx) message := fmt.Sprintf("window:minsize:%d:%d", width, height) bus.Publish(message, "") } // SetSize sets the size of the window -func (w *Window) SetMaxSize(ctx context.Context, width int, height int) { +func SetMaxSize(ctx context.Context, width int, height int) { bus := servicebus.ExtractBus(ctx) message := fmt.Sprintf("window:maxsize:%d:%d", width, height) bus.Publish(message, "") } // SetPosition sets the position of the window -func (w *Window) SetPosition(ctx context.Context, x int, y int) { +func SetPosition(ctx context.Context, x int, y int) { bus := servicebus.ExtractBus(ctx) message := fmt.Sprintf("window:position:%d:%d", x, y) bus.Publish(message, "") } // Maximise the window -func (w *Window) Maximise(ctx context.Context) { +func Maximise(ctx context.Context) { bus := servicebus.ExtractBus(ctx) bus.Publish("window:maximise", "") } // Unmaximise the window -func (w *Window) Unmaximise(ctx context.Context) { +func Unmaximise(ctx context.Context) { bus := servicebus.ExtractBus(ctx) bus.Publish("window:unmaximise", "") } // Minimise the window -func (w *Window) Minimise(ctx context.Context) { +func Minimise(ctx context.Context) { bus := servicebus.ExtractBus(ctx) bus.Publish("window:minimise", "") } // Unminimise the window -func (w *Window) Unminimise(ctx context.Context) { +func Unminimise(ctx context.Context) { bus := servicebus.ExtractBus(ctx) bus.Publish("window:unminimise", "") }