add Mac about menu override, minor MainWindow refactor
This commit is contained in:
@@ -73,17 +73,7 @@ func main() {
|
|||||||
|
|
||||||
}()
|
}()
|
||||||
|
|
||||||
mainWindow.Show()
|
mainWindow.ShowAndRun()
|
||||||
mainWindow.Window.SetCloseIntercept(func() {
|
|
||||||
mainWindow.SaveWindowSize()
|
|
||||||
if myApp.Config.Application.CloseToSystemTray &&
|
|
||||||
mainWindow.HaveSystemTray() {
|
|
||||||
mainWindow.Window.Hide()
|
|
||||||
} else {
|
|
||||||
fyneApp.Quit()
|
|
||||||
}
|
|
||||||
})
|
|
||||||
fyneApp.Run()
|
|
||||||
|
|
||||||
log.Println("Running shutdown tasks...")
|
log.Println("Running shutdown tasks...")
|
||||||
myApp.Shutdown()
|
myApp.Shutdown()
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"math"
|
"math"
|
||||||
|
"runtime"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@@ -87,6 +88,18 @@ func NewMainWindow(fyneApp fyne.App, appName, displayAppName, appVersion string,
|
|||||||
m.Controller.CurPageFunc = m.BrowsingPane.CurrentPage
|
m.Controller.CurPageFunc = m.BrowsingPane.CurrentPage
|
||||||
m.Controller.RefreshPageFunc = m.BrowsingPane.RefreshPage
|
m.Controller.RefreshPageFunc = m.BrowsingPane.RefreshPage
|
||||||
|
|
||||||
|
if runtime.GOOS == "darwin" {
|
||||||
|
// Fyne will extract out an "About" menu item and
|
||||||
|
// assign its action to the native Mac "About Supersonic" menu item
|
||||||
|
m.Window.SetMainMenu(fyne.NewMainMenu(
|
||||||
|
fyne.NewMenu("File", /*name doesn't matter*/
|
||||||
|
fyne.NewMenuItem("About", func() {
|
||||||
|
m.Window.Show()
|
||||||
|
m.Controller.ShowAboutDialog()
|
||||||
|
})),
|
||||||
|
))
|
||||||
|
}
|
||||||
|
|
||||||
m.BottomPanel = NewBottomPanel(app.PlaybackManager, app.ImageManager, m.Controller)
|
m.BottomPanel = NewBottomPanel(app.PlaybackManager, app.ImageManager, m.Controller)
|
||||||
m.container = container.NewBorder(nil, m.BottomPanel, nil, nil, m.BrowsingPane)
|
m.container = container.NewBorder(nil, m.BottomPanel, nil, nil, m.BrowsingPane)
|
||||||
m.Window.SetContent(m.container)
|
m.Window.SetContent(m.container)
|
||||||
@@ -139,6 +152,16 @@ func NewMainWindow(fyneApp fyne.App, appName, displayAppName, appVersion string,
|
|||||||
m.addNavigationButtons()
|
m.addNavigationButtons()
|
||||||
m.BrowsingPane.DisableNavigationButtons()
|
m.BrowsingPane.DisableNavigationButtons()
|
||||||
m.addShortcuts()
|
m.addShortcuts()
|
||||||
|
|
||||||
|
m.Window.SetCloseIntercept(func() {
|
||||||
|
m.SaveWindowSize()
|
||||||
|
if app.Config.Application.CloseToSystemTray && m.HaveSystemTray() {
|
||||||
|
m.Window.Hide()
|
||||||
|
} else {
|
||||||
|
fyneApp.Quit()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
return m
|
return m
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -384,6 +407,10 @@ func (m *MainWindow) Show() {
|
|||||||
m.Window.Show()
|
m.Window.Show()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (m *MainWindow) ShowAndRun() {
|
||||||
|
m.Window.ShowAndRun()
|
||||||
|
}
|
||||||
|
|
||||||
func (m *MainWindow) Canvas() fyne.Canvas {
|
func (m *MainWindow) Canvas() fyne.Canvas {
|
||||||
return m.Window.Canvas()
|
return m.Window.Canvas()
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user