Skip to content

Commit

Permalink
Merge pull request #552 from dweymouth/fyne-2.6-migrate
Browse files Browse the repository at this point in the history
Fyne 2.6 migrate
  • Loading branch information
dweymouth authored Feb 11, 2025
2 parents 12dcbf0 + f064e4c commit 4c0f936
Show file tree
Hide file tree
Showing 43 changed files with 715 additions and 1,140 deletions.
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ build:
# so the last 3 cmds move it over manually. This is a bit fragile though
# since it assumes a specific location and version of the dependency
package_macos:
CGO_CFLAGS="-I/usr/local/include -I/opt/homebrew/include" CGO_LDFLAGS="-L/usr/local/lib -L/opt/homebrew/lib" fyne package -os darwin
CGO_CFLAGS="-I/usr/local/include -I/opt/homebrew/include" CGO_LDFLAGS="-L/usr/local/lib -L/opt/homebrew/lib" fyne package -os darwin -tags migrated_fynedo

bundledeps_macos_homebrew:
dylibbundler -od -b -x ./Supersonic.app/Contents/MacOS/supersonic -d ./Supersonic.app/Contents/Frameworks/ -p @executable_path/../Frameworks/
Expand All @@ -25,7 +25,7 @@ zip_macos:
zip --symlinks -r Supersonic.zip Supersonic.app/

package_windows:
fyne package -os windows
fyne package -os windows -tags migrated_fynedo

package_linux:
fyne package -os linux
fyne package -os linux -tags migrated_fynedo
1 change: 1 addition & 0 deletions backend/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ type AppConfig struct {
SkipSSLVerify bool
EnqueueBatchSize int
Language string
DisableDPIDetection bool

// Experimental - may be removed in future
FontNormalTTF string
Expand Down
36 changes: 18 additions & 18 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ module github.com/dweymouth/supersonic
go 1.21

require (
fyne.io/fyne/v2 v2.5.3
fyne.io/fyne/v2 v2.6.0-alpha1
github.com/20after4/configdir v0.1.1
github.com/Microsoft/go-winio v0.6.2
github.com/cenkalti/dominantcolor v1.0.3
github.com/deluan/sanitize v0.0.0-20230310221930-6e18967d9fc1
github.com/dweymouth/fyne-advanced-list v0.0.0-20240806013530-392de9d6a2a1
github.com/dweymouth/fyne-advanced-list v0.0.0-20250211191927-58ea85eec72c
github.com/dweymouth/fyne-lyrics v0.0.0-20240528234907-15eee7ce5e64
github.com/dweymouth/fyne-tooltip v0.2.0
github.com/dweymouth/fyne-tooltip v0.3.0
github.com/dweymouth/go-jellyfin v0.0.0-20240517151952-5ceca61cb645
github.com/godbus/dbus/v5 v5.1.0
github.com/google/uuid v1.3.0
Expand All @@ -20,8 +20,8 @@ require (
github.com/supersonic-app/go-subsonic v0.0.0-20241224013245-9b2841f3711d
github.com/zalando/go-keyring v0.2.6
golang.org/x/net v0.25.0
golang.org/x/sys v0.26.0
golang.org/x/text v0.16.0
golang.org/x/sys v0.30.0
golang.org/x/text v0.22.0
)

require (
Expand All @@ -32,26 +32,26 @@ require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/fredbi/uri v1.1.0 // indirect
github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/fyne-io/gl-js v0.0.0-20220119005834-d2da28d9ccfe // indirect
github.com/fyne-io/glfw-js v0.0.0-20241126112943-313d8a0fe1d0 // indirect
github.com/fyne-io/image v0.0.0-20220602074514-4956b0afb3d2 // indirect
github.com/go-gl/gl v0.0.0-20211210172815-726fda9656d6 // indirect
github.com/fyne-io/gl-js v0.1.0 // indirect
github.com/fyne-io/glfw-js v0.1.0 // indirect
github.com/fyne-io/image v0.1.0 // indirect
github.com/go-gl/gl v0.0.0-20231021071112-07e5d0ea2e71 // indirect
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20240506104042-037f3cc74f2a // indirect
github.com/go-text/render v0.2.0 // indirect
github.com/go-text/typesetting v0.2.0 // indirect
github.com/gopherjs/gopherjs v1.17.2 // indirect
github.com/jeandeaual/go-locale v0.0.0-20240223122105-ce5225dcaa49 // indirect
github.com/jsummers/gobmp v0.0.0-20151104160322-e2ba15ffa76e // indirect
github.com/nicksnyder/go-i18n/v2 v2.4.0 // indirect
github.com/go-text/typesetting v0.2.1 // indirect
github.com/jeandeaual/go-locale v0.0.0-20241217141322-fcc2cadd6f08 // indirect
github.com/jsummers/gobmp v0.0.0-20230614200233-a9de23ed2e25 // indirect
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646 // indirect
github.com/nicksnyder/go-i18n/v2 v2.5.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/rymdport/portal v0.3.0 // indirect
github.com/srwiley/oksvg v0.0.0-20221011165216-be6e8873101c // indirect
github.com/srwiley/rasterx v0.0.0-20220730225603-2ab79fcdd4ef // indirect
github.com/stretchr/testify v1.9.0 // indirect
github.com/yuin/goldmark v1.7.1 // indirect
golang.org/x/image v0.18.0 // indirect
github.com/stretchr/testify v1.10.0 // indirect
github.com/yuin/goldmark v1.7.8 // indirect
golang.org/x/image v0.24.0 // indirect
golang.org/x/mobile v0.0.0-20231127183840-76ac6878050a // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)

replace fyne.io/fyne/v2 v2.5.3 => github.com/dweymouth/fyne/v2 v2.3.0-rc1.0.20241221194247-e7d4715906d9
replace fyne.io/fyne/v2 v2.6.0-alpha1 => github.com/dweymouth/fyne/v2 v2.3.0-rc1.0.20250208153246-b82c2bea222d
640 changes: 38 additions & 602 deletions go.sum

Large diffs are not rendered by default.

21 changes: 11 additions & 10 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ func main() {
os.Setenv("FYNE_SCALE", "1.1")
}

if myApp.Config.Application.DisableDPIDetection {
os.Setenv("FYNE_DISABLE_DPI_DETECTION", "true")
}

// load configured app language, or all otherwise
lIdx := slices.IndexFunc(res.TranslationsInfo, func(t res.TranslationInfo) bool {
return t.Name == myApp.Config.Application.Language
Expand Down Expand Up @@ -75,19 +79,18 @@ func main() {
fyneApp.SetIcon(res.ResAppicon256Png)

mainWindow := ui.NewMainWindow(fyneApp, res.AppName, res.DisplayName, res.AppVersion, myApp)
mainWindow.Window.SetMaster()
myApp.OnReactivate = mainWindow.Show
myApp.OnExit = mainWindow.Quit
myApp.OnExit = func() { fyne.Do(mainWindow.Quit) }

go func() {
windowStartupTasks := sync.OnceFunc(func() {
defaultServer := myApp.ServerManager.GetDefaultServer()
if defaultServer == nil {
mainWindow.Controller.PromptForFirstServer()
} else {
mainWindow.Controller.DoConnectToServerWorkflow(defaultServer)
}
}()

startupOnceTasks := sync.OnceFunc(func() {
mainWindow.Window.(driver.NativeWindow).RunNative(func(ctx any) {
// intialize Windows SMTC
if runtime.GOOS == "windows" {
Expand All @@ -98,19 +101,17 @@ func main() {
// slightly hacky workaround for https://github.com/fyne-io/fyne/issues/4964
_, isWayland := ctx.(*driver.WaylandWindowContext)
if runtime.GOOS == "linux" && !isWayland {
s := mainWindow.DesiredSize()
go func() {
time.Sleep(50 * time.Millisecond)
s := mainWindow.DesiredSize()
mainWindow.Window.Resize(s.Subtract(fyne.NewSize(4, 0)))
fyne.Do(func() { mainWindow.Window.Resize(s.Subtract(fyne.NewSize(4, 0))) })
time.Sleep(50 * time.Millisecond)
mainWindow.Window.Resize(s) // back to desired size
fyne.Do(func() { mainWindow.Window.Resize(s) }) // back to desired size
}()
}
})
})
fyneApp.Lifecycle().SetOnEnteredForeground(func() {
startupOnceTasks()
})
fyneApp.Lifecycle().SetOnEnteredForeground(windowStartupTasks)

mainWindow.ShowAndRun()

Expand Down
2 changes: 1 addition & 1 deletion res/translations/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
"days": "Tage",
"Delete Playlist": "Playlist löschen",
"Demo": "Demo",
"Description": "Beschreibung",
"_Description": "Beschreibung",
"Disable server transcoding": "Server-Transkodierung deaktivieren",
"Disc number": "Disk Nummer",
"Discography": "Diskographie",
Expand Down
3 changes: 2 additions & 1 deletion res/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"All Tracks": "All Tracks",
"Alt. URL": "Alt. URL",
"An error occurred adding tracks to the playlist": "An error occurred adding tracks to the playlist",
"An error occurred updating the playlist": "An error occurred updating the playlist",
"Are you sure you want to delete the server": "Are you sure you want to delete the server",
"Artist": "Artist",
"Artist (A-Z)": "Artist (A-Z)",
Expand Down Expand Up @@ -54,7 +55,7 @@
"days": "days",
"Delete Playlist": "Delete Playlist",
"Demo": "Demo",
"Description": "Description",
"_Description": "Description",
"Disable server transcoding": "Disable server transcoding",
"Disc number": "Disc number",
"Discography": "Discography",
Expand Down
2 changes: 1 addition & 1 deletion res/translations/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
"days": "días",
"Delete Playlist": "Eliminar lista de reproducción",
"Demo": "Demo",
"Description": "Descripción",
"_Description": "Descripción",
"Disable server transcoding": "Desactivar transcodificación del servidor",
"Disc number": "Número de disco",
"Discography": "Discografía",
Expand Down
2 changes: 1 addition & 1 deletion res/translations/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
"days": "jours",
"Delete Playlist": "Supprimer la liste de lecture",
"Demo": "Démo",
"Description": "Description",
"_Description": "Description",
"Disable server transcoding": "Désactiver le transcodage par le serveur",
"Disc number": "Numéro de disque",
"Discography": "Discographie",
Expand Down
2 changes: 1 addition & 1 deletion res/translations/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
"days": "giorni",
"Delete Playlist": "Elimina playlist",
"Demo": "Demo",
"Description": "Descrizione",
"_Description": "Descrizione",
"Disable server transcoding": "Disabilita la transocodifica lato server",
"Disc number": "Numero disco",
"Discography": "Discografia",
Expand Down
2 changes: 1 addition & 1 deletion res/translations/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
"days": "",
"Delete Playlist": "プレイリストの削除",
"Demo": "デモ",
"Description": "説明",
"_Description": "説明",
"Disable server transcoding": "サーバーのトランスコーディングを無効にする",
"Disc number": "ディスク番号",
"Discography": "ディスコグラフィー",
Expand Down
2 changes: 1 addition & 1 deletion res/translations/nl.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
"days": "dagen",
"Delete Playlist": "Wis afspeellijst",
"Demo": "Demo",
"Description": "Beschrijving",
"_Description": "Beschrijving",
"Disable server transcoding": "Schakel server transcodering uit",
"Disc number": "Schijf nummer",
"Discography": "Discografie",
Expand Down
2 changes: 1 addition & 1 deletion res/translations/pl.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
"days": "dni",
"Delete Playlist": "Usuń playlistę",
"Demo": "Demo",
"Description": "Opis",
"_Description": "Opis",
"Disable server transcoding": "Wyłącz transkodowanie serwera",
"Disc number": "Disc number",
"Discography": "Dyskografia",
Expand Down
2 changes: 1 addition & 1 deletion res/translations/pt_BR.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
"days": "dias",
"Delete Playlist": "Remover lista de reprodução",
"Demo": "Demo",
"Description": "Descrição",
"_Description": "Descrição",
"Disable server transcoding": "Desabilitar transcodificação no servidor",
"Disc number": "Número do disco",
"Discography": "Discografia",
Expand Down
2 changes: 1 addition & 1 deletion res/translations/ro.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
"days": "zile",
"Delete Playlist": "Șterge playlist",
"Demo": "Demo",
"Description": "Descriere",
"_Description": "Descriere",
"Disable server transcoding": "Dezactivează transcodare pe server",
"Disc number": "Număr disc",
"Discography": "Discografie",
Expand Down
2 changes: 1 addition & 1 deletion res/translations/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
"days": "",
"Delete Playlist": "删除播放列表",
"Demo": "演示",
"Description": "描述",
"_Description": "描述",
"Disable server transcoding": "禁用服务器转码",
"Disc number": "碟片编号",
"Discography": "唱片集",
Expand Down
2 changes: 1 addition & 1 deletion res/translations/zhHans.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
"days": "",
"Delete Playlist": "删除播放列表",
"Demo": "演示",
"Description": "描述",
"_Description": "描述",
"Disable server transcoding": "禁用服务器转码",
"Disc number": "碟片编号",
"Discography": "唱片集",
Expand Down
2 changes: 1 addition & 1 deletion res/translations/zhHant.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
"days": "",
"Delete Playlist": "刪除播放清單",
"Demo": "示範",
"Description": "描述",
"_Description": "描述",
"Disable server transcoding": "禁用伺服器轉碼",
"Disc number": "碟片編號",
"Discography": "唱片集",
Expand Down
38 changes: 23 additions & 15 deletions ui/bottompanel.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,21 @@ func NewBottomPanel(pm *backend.PlaybackManager, im *backend.ImageManager, contr

pm.OnSongChange(bp.onSongChange)
pm.OnPlayTimeUpdate(func(cur, total float64, _ bool) {
if !pm.IsSeeking() {
bp.Controls.UpdatePlayTime(cur, total)
}
fyne.Do(func() {
if !pm.IsSeeking() {
bp.Controls.UpdatePlayTime(cur, total)
}
})
})

pm.OnPaused(func() {
bp.Controls.SetPlaying(false)
fyne.Do(func() { bp.Controls.SetPlaying(false) })
})
pm.OnPlaying(func() {
bp.Controls.SetPlaying(true)
fyne.Do(func() { bp.Controls.SetPlaying(true) })
})
pm.OnStopped(func() {
bp.Controls.SetPlaying(false)
fyne.Do(func() { bp.Controls.SetPlaying(false) })
})

bp.NowPlaying = widgets.NewNowPlayingCard()
Expand Down Expand Up @@ -103,8 +105,12 @@ func NewBottomPanel(pm *backend.PlaybackManager, im *backend.ImageManager, contr
})

bp.AuxControls = widgets.NewAuxControls(pm.Volume(), pm.GetLoopMode(), pm.IsAutoplay())
pm.OnLoopModeChange(bp.AuxControls.SetLoopMode)
pm.OnVolumeChange(bp.AuxControls.VolumeControl.SetVolume)
pm.OnLoopModeChange(func(lm backend.LoopMode) {
fyne.Do(func() { bp.AuxControls.SetLoopMode(lm) })
})
pm.OnVolumeChange(func(vol int) {
fyne.Do(func() { bp.AuxControls.VolumeControl.SetVolume(vol) })
})
bp.AuxControls.VolumeControl.OnSetVolume = func(v int) {
pm.SetVolume(v)
}
Expand All @@ -124,13 +130,15 @@ func NewBottomPanel(pm *backend.PlaybackManager, im *backend.ImageManager, contr
}

func (bp *BottomPanel) onSongChange(song mediaprovider.MediaItem, _ *mediaprovider.Track) {
if song == nil {
bp.NowPlaying.Update(nil)
bp.imageLoader.Load("")
} else {
bp.NowPlaying.Update(song)
bp.imageLoader.Load(song.Metadata().CoverArtID)
}
fyne.Do(func() {
if song == nil {
bp.NowPlaying.Update(nil)
bp.imageLoader.Load("")
} else {
bp.NowPlaying.Update(song)
bp.imageLoader.Load(song.Metadata().CoverArtID)
}
})
}

func (bp *BottomPanel) CreateRenderer() fyne.WidgetRenderer {
Expand Down
21 changes: 13 additions & 8 deletions ui/browsing/albumpage.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,11 +168,13 @@ func (a *AlbumPage) load() {
if a.disposed {
return
}
a.header.Update(album, a.im)
a.tracklist.Options.ShowDiscNumber = len(album.Tracks) > 0 && album.Tracks[0].DiscNumber != album.Tracks[len(album.Tracks)-1].DiscNumber
a.tracks = album.Tracks
a.tracklist.SetTracks(album.Tracks)
a.tracklist.SetNowPlaying(a.nowPlayingID)
fyne.Do(func() {
a.header.Update(album, a.im)
a.tracklist.Options.ShowDiscNumber = len(album.Tracks) > 0 && album.Tracks[0].DiscNumber != album.Tracks[len(album.Tracks)-1].DiscNumber
a.tracks = album.Tracks
a.tracklist.SetTracks(album.Tracks)
a.tracklist.SetNowPlaying(a.nowPlayingID)
})
}

type AlbumPageHeader struct {
Expand Down Expand Up @@ -316,8 +318,10 @@ func (a *AlbumPageHeader) Update(album *mediaprovider.AlbumWithTracks, im *backe

go func() {
if cover, err := im.GetCoverThumbnail(album.CoverArtID); err == nil {
a.cover.SetImage(cover, true)
a.cover.Refresh()
fyne.Do(func() {
a.cover.SetImage(cover, true)
a.cover.Refresh()
})
} else {
log.Printf("error fetching cover: %v", err)
}
Expand All @@ -342,6 +346,7 @@ func (a *AlbumPageHeader) toggleFavorited() {
a.page.mp.SetFavorite(params, a.toggleFavButton.IsFavorited)
}

// should be called asynchronously
func (a *AlbumPageHeader) showPopUpCover() {
if a.fullSizeCoverFetching {
return
Expand All @@ -354,7 +359,7 @@ func (a *AlbumPageHeader) showPopUpCover() {
return
}
if a.page != nil {
a.page.contr.ShowPopUpImage(cover)
fyne.Do(func() { a.page.contr.ShowPopUpImage(cover) })
}
}

Expand Down
Loading

0 comments on commit 4c0f936

Please sign in to comment.