diff --git a/v2/internal/bridge/client.go b/v2/internal/bridge/client.go index 3975062e6..f65cffc20 100644 --- a/v2/internal/bridge/client.go +++ b/v2/internal/bridge/client.go @@ -118,8 +118,8 @@ func (b BridgeClient) DarkModeEnabled(callbackID string) { b.session.log.Info("DarkModeEnabled unsupported in Bridge mode") } -func (b BridgeClient) SetApplicationMenu(menuJSON string) { - b.session.log.Info("SetApplicationMenu unsupported in Bridge mode") +func (b BridgeClient) MenuSetApplicationMenu(menuJSON string) { + b.session.log.Info("MenuSetApplicationMenu unsupported in Bridge mode") } func (b BridgeClient) SetTrayMenu(trayMenuJSON string) { diff --git a/v2/internal/frontend/desktop/windows/menu.go b/v2/internal/frontend/desktop/windows/menu.go index 05ebfc4b7..f407d574a 100644 --- a/v2/internal/frontend/desktop/windows/menu.go +++ b/v2/internal/frontend/desktop/windows/menu.go @@ -120,10 +120,10 @@ func processMenuItem(parent *winc.MenuItem, menuItem *menu.MenuItem) { } } -func (f *Frontend) SetApplicationMenu(menu *menu.Menu) { +func (f *Frontend) MenuSetApplicationMenu(menu *menu.Menu) { f.mainWindow.SetApplicationMenu(menu) } -func (f *Frontend) UpdateApplicationMenu() { +func (f *Frontend) MenuUpdateApplicationMenu() { processMenu(f.mainWindow, f.mainWindow.applicationMenu) } diff --git a/v2/internal/frontend/devserver/devserver.go b/v2/internal/frontend/devserver/devserver.go index e4ddc1014..099343864 100644 --- a/v2/internal/frontend/devserver/devserver.go +++ b/v2/internal/frontend/devserver/devserver.go @@ -230,12 +230,12 @@ func (d *DevWebServer) WindowSetRGBA(col *options.RGBA) { d.desktopFrontend.WindowSetRGBA(col) } -func (d *DevWebServer) SetApplicationMenu(menu *menu.Menu) { - d.desktopFrontend.SetApplicationMenu(menu) +func (d *DevWebServer) MenuSetApplicationMenu(menu *menu.Menu) { + d.desktopFrontend.MenuSetApplicationMenu(menu) } -func (d *DevWebServer) UpdateApplicationMenu() { - d.desktopFrontend.UpdateApplicationMenu() +func (d *DevWebServer) MenuUpdateApplicationMenu() { + d.desktopFrontend.MenuUpdateApplicationMenu() } func (d *DevWebServer) Notify(name string, data ...interface{}) { diff --git a/v2/internal/frontend/frontend.go b/v2/internal/frontend/frontend.go index 7f11bcae0..68f7609ae 100644 --- a/v2/internal/frontend/frontend.go +++ b/v2/internal/frontend/frontend.go @@ -89,8 +89,8 @@ type Frontend interface { WindowReload() // Menus - SetApplicationMenu(menu *menu.Menu) - UpdateApplicationMenu() + MenuSetApplicationMenu(menu *menu.Menu) + MenuUpdateApplicationMenu() //SetTrayMenu(menu *menu.TrayMenu) //UpdateTrayMenuLabel(menu *menu.TrayMenu) //UpdateContextMenu(contextMenu *menu.ContextMenu) diff --git a/v2/internal/frontend/runtime/runtime_dev_desktop.js b/v2/internal/frontend/runtime/runtime_dev_desktop.js index 74b9395d5..eccf61795 100644 --- a/v2/internal/frontend/runtime/runtime_dev_desktop.js +++ b/v2/internal/frontend/runtime/runtime_dev_desktop.js @@ -1,11 +1,11 @@ (() => { var __defProp = Object.defineProperty; - var __markAsModule = (target) => __defProp(target, "__esModule", {value: true}); - var __export = (target, all) => { - __markAsModule(target); - for (var name in all) - __defProp(target, name, {get: all[name], enumerable: true}); - }; + var __markAsModule = (target) => __defProp(target, "__esModule", {value: true}); + var __export = (target, all) => { + __markAsModule(target); + for (var name in all) + __defProp(target, name, {get: all[name], enumerable: true}); + }; // desktop/log.js var log_exports = {}; @@ -138,17 +138,17 @@ if (timeout == null) { timeout = 0; } - return new Promise(function (resolve, reject) { - var callbackID; - do { - callbackID = name + "-" + randomFunc(); - } while (callbacks[callbackID]); - var timeoutHandle; - if (timeout > 0) { - timeoutHandle = setTimeout(function () { - reject(Error("Call to " + name + " timed out. Request ID: " + callbackID)); - }, timeout); - } + return new Promise(function (resolve, reject) { + var callbackID; + do { + callbackID = name + "-" + randomFunc(); + } while (callbacks[callbackID]); + var timeoutHandle; + if (timeout > 0) { + timeoutHandle = setTimeout(function () { + reject(Error("Call to " + name + " timed out. Request ID: " + callbackID)); + }, timeout); + } callbacks[callbackID] = { timeoutHandle, reject, @@ -205,20 +205,20 @@ Object.keys(bindingsMap[packageName]).forEach((structName) => { window.go[packageName][structName] = window.go[packageName][structName] || {}; Object.keys(bindingsMap[packageName][structName]).forEach((methodName) => { - window.go[packageName][structName][methodName] = function () { - let timeout = 0; + window.go[packageName][structName][methodName] = function () { + let timeout = 0; - function dynamic() { - const args = [].slice.call(arguments); - return Call([packageName, structName, methodName].join("."), args, timeout); - } + function dynamic() { + const args = [].slice.call(arguments); + return Call([packageName, structName, methodName].join("."), args, timeout); + } - dynamic.setTimeout = function (newTimeout) { - timeout = newTimeout; - }; - dynamic.getTimeout = function () { - return timeout; - }; + dynamic.setTimeout = function (newTimeout) { + timeout = newTimeout; + }; + dynamic.getTimeout = function () { + return timeout; + }; return dynamic; }(); }); @@ -231,23 +231,23 @@ __export(window_exports, { WindowCenter: () => WindowCenter, WindowClose: () => WindowClose, - WindowFullscreen: () => WindowFullscreen, - WindowGetPosition: () => WindowGetPosition, - WindowGetSize: () => WindowGetSize, - WindowHide: () => WindowHide, - WindowMaximise: () => WindowMaximise, - WindowMinimise: () => WindowMinimise, - WindowReload: () => WindowReload, - WindowSetMaxSize: () => WindowSetMaxSize, - WindowSetMinSize: () => WindowSetMinSize, - WindowSetPosition: () => WindowSetPosition, - WindowSetRGBA: () => WindowSetRGBA, - WindowSetSize: () => WindowSetSize, - WindowSetTitle: () => WindowSetTitle, - WindowShow: () => WindowShow, - WindowUnFullscreen: () => WindowUnFullscreen, - WindowUnmaximise: () => WindowUnmaximise, - WindowUnminimise: () => WindowUnminimise + WindowFullscreen: () => WindowFullscreen, + WindowGetPosition: () => WindowGetPosition, + WindowGetSize: () => WindowGetSize, + WindowHide: () => WindowHide, + WindowMaximise: () => WindowMaximise, + WindowMinimise: () => WindowMinimise, + WindowReload: () => WindowReload, + WindowSetMaxSize: () => WindowSetMaxSize, + WindowSetMinSize: () => WindowSetMinSize, + WindowSetPosition: () => WindowSetPosition, + WindowSetRGBA: () => WindowSetRGBA, + WindowSetSize: () => WindowSetSize, + WindowSetTitle: () => WindowSetTitle, + WindowShow: () => WindowShow, + WindowUnFullscreen: () => WindowUnFullscreen, + WindowUnmaximise: () => WindowUnmaximise, + WindowUnminimise: () => WindowUnminimise }); function WindowReload() { window.location.reload(); @@ -282,43 +282,46 @@ function WindowGetPosition() { return Call(":wails:WindowGetPos"); } + function WindowHide() { window.WailsInvoke("WH"); } + function WindowShow() { window.WailsInvoke("WS"); } + function WindowMaximise() { window.WailsInvoke("WM"); } - function WindowUnmaximise() { - window.WailsInvoke("WU"); - } + function WindowUnmaximise() { + window.WailsInvoke("WU"); + } - function WindowMinimise() { - window.WailsInvoke("Wm"); - } + function WindowMinimise() { + window.WailsInvoke("Wm"); + } - function WindowUnminimise() { - window.WailsInvoke("Wu"); - } + function WindowUnminimise() { + window.WailsInvoke("Wu"); + } - function WindowSetRGBA(RGBA) { - let rgba = JSON.stringify(RGBA); - window.WailsInvoke("Wr:" + rgba); - } + function WindowSetRGBA(RGBA) { + let rgba = JSON.stringify(RGBA); + window.WailsInvoke("Wr:" + rgba); + } - function WindowClose() { - window.WailsInvoke("WC"); - } + function WindowClose() { + window.WailsInvoke("WC"); + } - // desktop/main.js - window.runtime = { - ...log_exports, - ...window_exports, - EventsOn, - EventsOnce, + // desktop/main.js + window.runtime = { + ...log_exports, + ...window_exports, + EventsOn, + EventsOnce, EventsOnMultiple, EventsEmit, EventsOff diff --git a/v2/pkg/runtime/menu.go b/v2/pkg/runtime/menu.go index b81641941..176c9bb1d 100644 --- a/v2/pkg/runtime/menu.go +++ b/v2/pkg/runtime/menu.go @@ -2,31 +2,15 @@ package runtime import ( "context" + "github.com/wailsapp/wails/v2/pkg/menu" ) -func UpdateApplicationMenu(ctx context.Context) { +func MenuSetApplicationMenu(ctx context.Context, menu *menu.Menu) { frontend := getFrontend(ctx) - frontend.UpdateApplicationMenu() + frontend.MenuSetApplicationMenu(menu) } -/* -func UpdateContextMenu(ctx context.Context, contextMenu *menu.ContextMenu) { +func MenuUpdateApplicationMenu(ctx context.Context) { frontend := getFrontend(ctx) - bus.Publish("menu:updatecontextmenu", contextMenu) + frontend.MenuUpdateApplicationMenu() } - -func SetTrayMenu(ctx context.Context, trayMenu *menu.TrayMenu) { - frontend := getFrontend(ctx) - bus.Publish("menu:settraymenu", trayMenu) -} - -func UpdateTrayMenuLabel(ctx context.Context, trayMenu *menu.TrayMenu) { - frontend := getFrontend(ctx) - bus.Publish("menu:updatetraymenulabel", trayMenu) -} - -func DeleteTrayMenu(ctx context.Context, trayMenu *menu.TrayMenu) { - frontend := getFrontend(ctx) - bus.Publish("menu:deletetraymenu", trayMenu) -} -*/