a few more goroutines
This commit is contained in:
@@ -77,7 +77,7 @@ func main() {
|
|||||||
mainWindow := ui.NewMainWindow(fyneApp, res.AppName, res.DisplayName, res.AppVersion, myApp)
|
mainWindow := ui.NewMainWindow(fyneApp, res.AppName, res.DisplayName, res.AppVersion, myApp)
|
||||||
mainWindow.Window.SetMaster()
|
mainWindow.Window.SetMaster()
|
||||||
myApp.OnReactivate = mainWindow.Show
|
myApp.OnReactivate = mainWindow.Show
|
||||||
myApp.OnExit = mainWindow.Quit
|
myApp.OnExit = func() { fyne.Do(mainWindow.Quit) }
|
||||||
|
|
||||||
fyneApp.Lifecycle().SetOnEnteredForeground(sync.OnceFunc(func() {
|
fyneApp.Lifecycle().SetOnEnteredForeground(sync.OnceFunc(func() {
|
||||||
defaultServer := myApp.ServerManager.GetDefaultServer()
|
defaultServer := myApp.ServerManager.GetDefaultServer()
|
||||||
|
|||||||
@@ -64,6 +64,7 @@ func (a *GenresPage) load(searchOnLoad bool, scrollPos float32) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("error loading genres: %v", err.Error())
|
log.Printf("error loading genres: %v", err.Error())
|
||||||
}
|
}
|
||||||
|
fyne.Do(func() {
|
||||||
a.genres = genres
|
a.genres = genres
|
||||||
if searchOnLoad {
|
if searchOnLoad {
|
||||||
a.onSearched(a.searcher.Entry.Text)
|
a.onSearched(a.searcher.Entry.Text)
|
||||||
@@ -78,6 +79,7 @@ func (a *GenresPage) load(searchOnLoad bool, scrollPos float32) {
|
|||||||
}
|
}
|
||||||
a.list.Refresh()
|
a.list.Refresh()
|
||||||
}
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *GenresPage) onSearched(query string) {
|
func (a *GenresPage) onSearched(query string) {
|
||||||
|
|||||||
@@ -297,7 +297,8 @@ func (a *NowPlayingPage) onImageLoaded(img image.Image, err error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("error loading cover art: %v\n", err)
|
log.Printf("error loading cover art: %v\n", err)
|
||||||
}
|
}
|
||||||
a.card.SetCoverImage(img)
|
|
||||||
|
fyne.Do(func() { a.card.SetCoverImage(img) })
|
||||||
if img == nil {
|
if img == nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -307,18 +308,15 @@ func (a *NowPlayingPage) onImageLoaded(img image.Image, err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
evenFrame := true
|
// Fyne animation starting is currently thread-safe,
|
||||||
|
// despite not being marked as such
|
||||||
|
// TODO: if this changes, use fyne.Do
|
||||||
anim := canvas.NewColorRGBAAnimation(
|
anim := canvas.NewColorRGBAAnimation(
|
||||||
a.background.StartColor, c, 75*time.Millisecond, func(c color.Color) {
|
a.background.StartColor, c, 75*time.Millisecond, func(c color.Color) {
|
||||||
// reduce fps to reduce mem allocations
|
|
||||||
if evenFrame {
|
|
||||||
a.background.StartColor = c
|
a.background.StartColor = c
|
||||||
a.background.Refresh()
|
a.background.Refresh()
|
||||||
}
|
|
||||||
evenFrame = !evenFrame
|
|
||||||
})
|
})
|
||||||
anim.Start()
|
anim.Start()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *NowPlayingPage) updateLyrics() {
|
func (a *NowPlayingPage) updateLyrics() {
|
||||||
|
|||||||
@@ -349,6 +349,7 @@ func (a *PlaylistPageHeader) Update(playlist *mediaprovider.PlaylistWithTracks)
|
|||||||
a.Refresh()
|
a.Refresh()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// should be called asynchronously
|
||||||
func (a *PlaylistPageHeader) showPopUpCover() {
|
func (a *PlaylistPageHeader) showPopUpCover() {
|
||||||
if a.fullSizeCoverFetching || a.playlistInfo == nil {
|
if a.fullSizeCoverFetching || a.playlistInfo == nil {
|
||||||
return
|
return
|
||||||
@@ -361,7 +362,7 @@ func (a *PlaylistPageHeader) showPopUpCover() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
if a.page != nil {
|
if a.page != nil {
|
||||||
a.page.contr.ShowPopUpImage(cover)
|
fyne.Do(func() { a.page.contr.ShowPopUpImage(cover) })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -133,22 +133,6 @@ func NewMainWindow(fyneApp fyne.App, appName, displayAppName, appVersion string,
|
|||||||
|
|
||||||
m.Window.SetCloseIntercept(func() {
|
m.Window.SetCloseIntercept(func() {
|
||||||
m.SaveWindowSize()
|
m.SaveWindowSize()
|
||||||
// save settings in case we crash during shutdown
|
|
||||||
// TODO: when all shutdowns exit cleanly, remove these lines
|
|
||||||
// as they are already executed in app.Shutdown()
|
|
||||||
app.Config.LocalPlayback.Volume = app.LocalPlayer.GetVolume()
|
|
||||||
repeatMode := "None"
|
|
||||||
switch app.PlaybackManager.GetLoopMode() {
|
|
||||||
case backend.LoopOne:
|
|
||||||
repeatMode = "One"
|
|
||||||
case backend.LoopAll:
|
|
||||||
repeatMode = "All"
|
|
||||||
}
|
|
||||||
app.Config.Playback.RepeatMode = repeatMode
|
|
||||||
app.Config.Playback.Autoplay = app.PlaybackManager.IsAutoplay()
|
|
||||||
app.SavePlayQueueIfEnabled()
|
|
||||||
app.SaveConfigFile()
|
|
||||||
|
|
||||||
if app.Config.Application.CloseToSystemTray && m.HaveSystemTray() {
|
if app.Config.Application.CloseToSystemTray && m.HaveSystemTray() {
|
||||||
m.Window.Hide()
|
m.Window.Hide()
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
+3
-1
@@ -199,7 +199,9 @@ func NewDebouncer(dur time.Duration, callOnDone func()) func() {
|
|||||||
if timer != nil {
|
if timer != nil {
|
||||||
timer.Stop()
|
timer.Stop()
|
||||||
}
|
}
|
||||||
timer = time.AfterFunc(dur, callOnDone)
|
timer = time.AfterFunc(dur, func() {
|
||||||
|
fyne.Do(callOnDone)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user