From d66e4da59cd8227f1ff0cba7232ba355237a4d9b Mon Sep 17 00:00:00 2001 From: Travis McLane Date: Mon, 25 Jul 2022 14:51:05 -0500 Subject: [PATCH] implement null.Frontend null.Frontend does nothing and is merely needed to pass to the devserver so it has a frontend.Frontend to drive --- v2/internal/frontend/desktop/null/browser.go | 5 + v2/internal/frontend/desktop/null/dialog.go | 28 +++ v2/internal/frontend/desktop/null/frontend.go | 202 ++++++++++++++++++ v2/internal/frontend/desktop/null/menu.go | 11 + 4 files changed, 246 insertions(+) create mode 100644 v2/internal/frontend/desktop/null/browser.go create mode 100644 v2/internal/frontend/desktop/null/dialog.go create mode 100644 v2/internal/frontend/desktop/null/frontend.go create mode 100644 v2/internal/frontend/desktop/null/menu.go diff --git a/v2/internal/frontend/desktop/null/browser.go b/v2/internal/frontend/desktop/null/browser.go new file mode 100644 index 00000000..8c7c6ec4 --- /dev/null +++ b/v2/internal/frontend/desktop/null/browser.go @@ -0,0 +1,5 @@ +package null + +// BrowserOpenURL does nothing +func (f *Frontend) BrowserOpenURL(url string) { +} diff --git a/v2/internal/frontend/desktop/null/dialog.go b/v2/internal/frontend/desktop/null/dialog.go new file mode 100644 index 00000000..823afe64 --- /dev/null +++ b/v2/internal/frontend/desktop/null/dialog.go @@ -0,0 +1,28 @@ +package null + +import "github.com/wailsapp/wails/v2/internal/frontend" + +// OpenFileDialog does nothing +func (f *Frontend) OpenFileDialog(dialogOptions frontend.OpenDialogOptions) (result string, err error) { + return "", nil +} + +// OpenMultipleFilesDialog does nothing +func (f *Frontend) OpenMultipleFilesDialog(dialogOptions frontend.OpenDialogOptions) ([]string, error) { + return []string{}, nil +} + +// OpenDirectoryDialog does nothing +func (f *Frontend) OpenDirectoryDialog(dialogOptions frontend.OpenDialogOptions) (string, error) { + return "", nil +} + +// SaveFileDialog does nothing +func (f *Frontend) SaveFileDialog(dialogOptions frontend.SaveDialogOptions) (string, error) { + return "", nil +} + +// MessageDialog does nothing +func (f *Frontend) MessageDialog(dialogOptions frontend.MessageDialogOptions) (string, error) { + return "", nil +} diff --git a/v2/internal/frontend/desktop/null/frontend.go b/v2/internal/frontend/desktop/null/frontend.go new file mode 100644 index 00000000..fe19907a --- /dev/null +++ b/v2/internal/frontend/desktop/null/frontend.go @@ -0,0 +1,202 @@ +package null + +import ( + "context" + "time" + + "github.com/wailsapp/wails/v2/internal/frontend" + "github.com/wailsapp/wails/v2/pkg/options" +) + +// Frontend implements an empty Frontend that simply waits until the context is done. +type Frontend struct { + // Context + ctx context.Context + done bool +} + +// NewFrontend returns an initialized Frontend +func NewFrontend(ctx context.Context) *Frontend { + return &Frontend{ + ctx: ctx, + } +} + +// Show does nothing +func (f *Frontend) Show() { + +} + +// Hide does nothing +func (f *Frontend) Hide() { + +} + +// ScreenGetAll returns an empty slice +func (f *Frontend) ScreenGetAll() ([]frontend.Screen, error) { + return []frontend.Screen{}, nil +} + +// WindowSetBackgroundColour does nothing +func (f *Frontend) WindowSetBackgroundColour(col *options.RGBA) { + +} + +// WindowReload does nothing +func (f *Frontend) WindowReload() { + +} + +// WindowReloadApp does nothing +func (f *Frontend) WindowReloadApp() { + +} + +// WindowSetAlwaysOnTop does nothing +func (f *Frontend) WindowSetAlwaysOnTop(b bool) { + +} + +// WindowSetSystemDefaultTheme does nothing +func (f *Frontend) WindowSetSystemDefaultTheme() { + +} + +// WindowSetLightTheme does nothing +func (f *Frontend) WindowSetLightTheme() { + +} + +// WindowSetDarkTheme does nothing +func (f *Frontend) WindowSetDarkTheme() { + +} + +// Run waits until the context is done and then exits +func (f *Frontend) Run(ctx context.Context) error { + for { + select { + case <-ctx.Done(): + break + default: + time.Sleep(1 * time.Millisecond) + } + if f.done { + break + } + } + return nil +} + +// WindowCenter does nothing +func (f *Frontend) WindowCenter() { + +} + +// WindowSetPosition does nothing +func (f *Frontend) WindowSetPosition(x, y int) { + +} + +// WindowGetPosition does nothing +func (f *Frontend) WindowGetPosition() (int, int) { + return 0, 0 +} + +// WindowSetSize does nothing +func (f *Frontend) WindowSetSize(width, height int) { + +} + +// WindowGetSize does nothing +func (f *Frontend) WindowGetSize() (int, int) { + return 0, 0 +} + +// WindowSetTitle does nothing +func (f *Frontend) WindowSetTitle(title string) { + +} + +// WindowFullscreen does nothing +func (f *Frontend) WindowFullscreen() { + +} + +// WindowUnfullscreen does nothing +func (f *Frontend) WindowUnfullscreen() { + +} + +// WindowShow does nothing +func (f *Frontend) WindowShow() { + +} + +// WindowHide does nothing +func (f *Frontend) WindowHide() { + +} + +// WindowMaximize does nothing +func (f *Frontend) WindowMaximise() { + +} + +// WindowToggleMaximise does nothing +func (f *Frontend) WindowToggleMaximise() { + +} + +// WindowUnmaximise does nothing +func (f *Frontend) WindowUnmaximise() { +} + +// WindowMinimise does nothing +func (f *Frontend) WindowMinimise() { + +} + +// WindowUnminimise does nothing +func (f *Frontend) WindowUnminimise() { + +} + +// WindowSetMinSize does nothing +func (f *Frontend) WindowSetMinSize(width int, height int) { + +} + +// WindowSetMaxSize does nothing +func (f *Frontend) WindowSetMaxSize(width int, height int) { + +} + +// WindowSetRGBA does nothing +func (f *Frontend) WindowSetRGBA(col *options.RGBA) { +} + +// Quit does nothing +func (f *Frontend) Quit() { + f.done = true +} + +// Notify does nothing +func (f *Frontend) Notify(name string, data ...interface{}) { + +} + +// Callback does nothing +func (f *Frontend) Callback(message string) { + +} + +// startDrag does nothing +func (f *Frontend) startDrag() { + +} + +// ExecJS does nothing +func (f *Frontend) ExecJS(js string) { + +} diff --git a/v2/internal/frontend/desktop/null/menu.go b/v2/internal/frontend/desktop/null/menu.go new file mode 100644 index 00000000..97c9c400 --- /dev/null +++ b/v2/internal/frontend/desktop/null/menu.go @@ -0,0 +1,11 @@ +package null + +import "github.com/wailsapp/wails/v2/pkg/menu" + +//MenuSetApplicationMenu does nothing +func (f *Frontend) MenuSetApplicationMenu(menu *menu.Menu) { +} + +// MenuUpdateApplicationMenu does nothing +func (f *Frontend) MenuUpdateApplicationMenu() { +}