Added menu cloning.

Introduced the ability to clone a menu, along with its submenus, in Linux-based web applications to create a full deep copy. This fixes reusing the application menu for window menus.
This commit is contained in:
Lea Anthony 2024-02-06 21:14:51 +11:00 committed by Travis McLane
commit a048233f4c
2 changed files with 3 additions and 26 deletions

View file

@ -54,8 +54,8 @@ func (l *linuxApp) show() {
}
func (l *linuxApp) on(eventID uint) {
// TODO: What do we need to do here?
log.Println("linuxApp.on()", eventID)
// TODO: Test register/unregister events
//C.registerApplicationEvent(l.application, C.uint(eventID))
}
func (l *linuxApp) setIcon(icon []byte) {
@ -78,21 +78,6 @@ func (r rnr) run() {
r.f()
}
func (l *linuxApp) getApplicationMenu() pointer {
if l.applicationMenu != nilPointer {
return l.applicationMenu
}
menu := globalApplication.ApplicationMenu
if menu != nil {
InvokeSync(func() {
menu.Update()
})
l.applicationMenu = (menu.impl).(*linuxMenu).native
}
return l.applicationMenu
}
func (l *linuxApp) setApplicationMenu(menu *Menu) {
// FIXME: How do we avoid putting a menu?
if menu == nil {

View file

@ -37,14 +37,6 @@ type linuxWebviewWindow struct {
gtkmenu pointer
}
func (w *linuxWebviewWindow) setMinimiseButtonEnabled(enabled bool) {
// Not available in Linux
}
func (w *linuxWebviewWindow) setMaximiseButtonEnabled(enabled bool) {
// Not available in Linux
}
var (
registered bool = false // avoid 'already registered message' about 'wails://'
)
@ -276,7 +268,7 @@ func (w *linuxWebviewWindow) run() {
w.gtkmenu = (menu.impl).(*linuxMenu).native
}
w.window, w.webview, w.vbox = windowNew(app.application, menu, w.parent.id, w.parent.options.Linux.WebviewGpuPolicy)
w.window, w.webview, w.vbox = windowNew(app.application, w.gtkmenu, w.parent.id, w.parent.options.Linux.WebviewGpuPolicy)
app.registerWindow(w.window, w.parent.id) // record our mapping
w.connectSignals()
if w.parent.options.EnableDragAndDrop {