Sonically/gui.go

1453 lines
52 KiB
Go

package main
import (
"fmt"
"github.com/TheCreeper/go-notify"
"github.com/delucks/go-subsonic"
"github.com/diamondburned/gotk4/pkg/gtk/v4"
"github.com/zalando/go-keyring"
// "github.com/diamondburned/gotk4/pkg/gdk/v4"
"github.com/diamondburned/gotk4/pkg/core/glib"
)
func SetUpGui() {
SettingsTabUserUsernameEntry = gtk.NewEntry()
SettingsTabUserServerEntry = gtk.NewEntry()
SettingsTabUserDeviceNameEntry = gtk.NewEntry()
SettingsTabUserPasswordEntry = gtk.NewEntry()
SettingsTabUserStatusLabel = gtk.NewLabel("- ")
SearchTabSearchEntry = gtk.NewSearchEntry()
SearchTabSongCheckButton = gtk.NewCheckButton()
SearchTabAlbumCheckButton = gtk.NewCheckButton()
SearchTabArtistCheckButton = gtk.NewCheckButton()
SearchListBoxResult = gtk.NewListBox()
MainSongTitleLabel = gtk.NewLabel(":")
MainArtistLabel = gtk.NewLabel(":")
MainAlbumLabel = gtk.NewLabel(":")
MainTimeDrawnLabel = gtk.NewLabel(":")
MainTimeLeft = gtk.NewLabel(":")
MainTotalTimeLabel = gtk.NewLabel(":")
SettingsTabAppDeleteSwitch = gtk.NewSwitch()
MainAdjustment = gtk.NewAdjustment(float64(0), float64(0), float64(1), float64(1), float64(10), float64(0))
SettingsTabAppCodecComboBoxTest = gtk.NewComboBoxText()
QueueListBox = gtk.NewListBox()
PlayListListBox = gtk.NewListBox()
MainAlbumCover = gtk.NewImage()
MainPlayPauseButton = gtk.NewButton() // gtk.NewLabel("▶")
MainSubtitlesTextView = gtk.NewTextView()
MainNotebook = gtk.NewNotebook()
LibraryNotebook = gtk.NewNotebook()
QueueListBoxLibrary = gtk.NewListBox()
SettingsTabAppCoverSizeEntry = gtk.NewEntry()
SettingsTabAppCoverSizeEntry = gtk.NewEntry()
SettingsTabAppBlurRadiusEntry = gtk.NewEntry()
SettingsTabAppBufferSizeEntry = gtk.NewEntry()
SettingsTabAppStreamingProxySwitch = gtk.NewSwitch()
SettingsTabAppStreamingProxyEntry = gtk.NewEntry()
SettingsTabAppAuthStreamingProxySwitch = gtk.NewSwitch()
SettingsTabAppStreamingProxyUsernameEntry = gtk.NewEntry()
SettingsTabAppStreamingProxyPassEntry = gtk.NewEntry()
SettingsTabAppMetadataProxySwitch = gtk.NewSwitch()
SettingsTabAppMetadataProxyEntry = gtk.NewEntry()
SettingsTabAppAuthMetadataProxySwitch = gtk.NewSwitch()
SettingsTabAppMetadataProxyUsernameEntry = gtk.NewEntry()
SettingsTabAppMetadataProxyPassEntry = gtk.NewEntry()
MainNotebook = gtk.NewNotebook()
LyricsNotebook = gtk.NewNotebook()
MainFlowbox = gtk.NewFlowBox()
LyricsScrolledWindow := gtk.NewScrolledWindow()
MainFlowBoxChild1 = gtk.NewFlowBoxChild()
MainFlowBoxChild2 = gtk.NewFlowBoxChild()
MainGridFlowBoxChild2 = gtk.NewGrid()
MainGridFlowBoxChild2Grid = gtk.NewGrid()
MainLeftSeparator = gtk.NewSeparator(gtk.OrientationHorizontal)
MainRightSeparator = gtk.NewSeparator(gtk.OrientationHorizontal)
MainFlowBoxChild3 = gtk.NewFlowBoxChild()
MainAdjustment.SetUpper(100)
MainAdjustment.SetStepIncrement(1)
MainAdjustment.SetPageIncrement(10)
MainScale = gtk.NewScale(gtk.OrientationHorizontal, MainAdjustment)
MainScaleGrid := gtk.NewGrid()
MainFlowBoxChild4 = gtk.NewFlowBoxChild()
MainGridFlowBoxChild4 = gtk.NewGrid()
MainPreviousButton = gtk.NewButton()
MainNextButton = gtk.NewButton()
MainRepeatButton = gtk.NewButton()
MainStarredButton = gtk.NewButton()
QueueMasterBox = gtk.NewBox(gtk.OrientationVertical, 2)
QueueSearchControlBox = gtk.NewGrid()
QueueScrolledWindow = gtk.NewScrolledWindow()
QueueSaveButton = gtk.NewButton() //
QueueClearButton = gtk.NewButton() //
QueueShuffleButton = gtk.NewButton() //
SearchControlBox = gtk.NewGrid()
QueueFlowBox := gtk.NewFlowBox()
QueueFlowBoxChild1 = gtk.NewFlowBoxChild()
LibraryFlowBox1 = gtk.NewFlowBox()
LibraryFlowBox2 = gtk.NewFlowBox()
LibraryFlowBox3 = gtk.NewFlowBox()
LibraryFlowBox4 = gtk.NewFlowBox()
LibraryPlaylistMainBox = gtk.NewBox(gtk.OrientationVertical, 0)
LibraryStarredMainBox = gtk.NewBox(gtk.OrientationVertical, 0)
LibraryLibraryMainBox = gtk.NewBox(gtk.OrientationVertical, 0)
LibraryPodcastMainBox = gtk.NewBox(gtk.OrientationVertical, 0)
LibraryFlowBox1Child1 = gtk.NewFlowBoxChild()
LibraryFlowBox2Child1 = gtk.NewFlowBoxChild()
LibraryFlowBox3Child1 = gtk.NewFlowBoxChild()
LibraryFlowBox4Child1 = gtk.NewFlowBoxChild()
LibraryPlaylistMainControlGrid = gtk.NewGrid()
LibraryStarredMainControlGrid = gtk.NewGrid()
LibraryLibraryMainControlGrid = gtk.NewGrid()
LibraryPodcastMainControlGrid = gtk.NewGrid()
LibraryPlaylistBackButton = gtk.NewButton()
LibraryPlaylistRefreshButton = gtk.NewButton()
LibraryStarredBackButton = gtk.NewButton()
LibraryStarredRefreshButton = gtk.NewButton()
LibraryLibraryBackButton = gtk.NewButton()
LibraryLibraryRefreshButton = gtk.NewButton()
LibraryPodcastBackButton = gtk.NewButton()
LibraryPodcastRefreshButton = gtk.NewButton()
LibraryStarredListBox = gtk.NewListBox()
LibraryPodcastListBox = gtk.NewListBox()
LibraryPlaylistMainScrolledWindow = gtk.NewScrolledWindow()
LibraryPodcastListBoxScrolledWindow = gtk.NewScrolledWindow()
LibraryStarredListBoxScrolledWindow = gtk.NewScrolledWindow()
QueueListBoxLibraryScrolledWindow = gtk.NewScrolledWindow()
SettingsAccountScrolledWindow = gtk.NewScrolledWindow()
SettingsAppScrolledWindow = gtk.NewScrolledWindow()
SettingsCreditsScrolledWindow = gtk.NewScrolledWindow()
SettingsAccountsFlowBox = gtk.NewFlowBox()
SettingsAppFlowBox = gtk.NewFlowBox()
SettingsCreditsFlowBox = gtk.NewFlowBox()
SettingsAccountFlowboxChild1 = gtk.NewFlowBoxChild()
SettingsAccountFlowboxChild2 = gtk.NewFlowBoxChild()
SettingsNotebook = gtk.NewNotebook()
SettingsAccountBox = gtk.NewBox(gtk.OrientationVertical, 3)
SettingsAccountLoginGrid = gtk.NewGrid()
SettingsAccountButtonsGrid = gtk.NewGrid()
SettingsAccountUserListbox = gtk.NewListBox()
SettingsAccountUsernameLabel = gtk.NewLabel("Username: ")
SettingsAccountPasswordLabel = gtk.NewLabel("Password: ")
SettingsAccountPLayerNameLabel = gtk.NewLabel("Player Name: ")
SettingsAccountServerLabel = gtk.NewLabel("Server: ")
SettingsAccountTestButton = gtk.NewButton()
SettingsAccountSaveButton = gtk.NewButton()
SettingsAccountLoadButton = gtk.NewButton()
SettingsAppScrolledWindow = gtk.NewScrolledWindow()
SettingsAppFlowBoxChild1 = gtk.NewFlowBoxChild()
SettingsAppFlowBoxChild2 = gtk.NewFlowBoxChild()
SettingsAppFlowBoxChild3 = gtk.NewFlowBoxChild()
SettingsAppFlowBoxChild4 = gtk.NewFlowBoxChild()
SettingsAppGrid1 = gtk.NewGrid()
SettingsAppGrid2 = gtk.NewGrid()
SettingsAppGrid3 = gtk.NewGrid()
SettingsAppGrid4 = gtk.NewGrid()
SettingsTabAppBitrateEntry = gtk.NewEntry()
SettingsAppLabelGrid1 = gtk.NewLabel("Local")
SettingsAppLabelGrid2 = gtk.NewLabel("Transcoding")
SettingsAppLabelGrid3 = gtk.NewLabel("Net")
SettingsAppLabelGrid1DeleteOnClose = gtk.NewLabel("Clear cache on close")
SettingsAppLabelGrid1CoverSideSize = gtk.NewLabel("Cover Side Size (px)")
SettingsAppLabelGrid1BackgroundBlurRadius = gtk.NewLabel("Cover blur radius")
SettingsTabAppHideHeaderBarSwitch = gtk.NewSwitch()
SettingsAppLabelHideHeaderBar = gtk.NewLabel("Hide Headerbar")
SettingsAppLabelGrid2Codec = gtk.NewLabel("Codec")
SettingsAppLabelGrid2Bitrate = gtk.NewLabel("Bitrate")
SettingsAppLabelGrid2DownloadBufferSize = gtk.NewLabel("Download Buffer Size")
SettingsAppLabelGrid3UseProxyForStreaming = gtk.NewLabel("Use proxy for streaming")
SettingsAppLabelGrid3AuthenticateStreamingProxy = gtk.NewLabel("Authenticate")
SettingsAppLabelGrid3UseProxyForMetadata = gtk.NewLabel("User proxy for Metadata")
SettingsAppLabelGrid3AuthenticateMetadataProxy = gtk.NewLabel("Authenticate")
SettingsAppLabelGrid4 = gtk.NewLabel("External Services")
SettingsAppLabelGrid4Metadata = gtk.NewLabel("Metadata")
SettingsTabAppMetadataComboBoxTest = gtk.NewComboBoxText()
SearchFlowBox := gtk.NewFlowBox()
SearchMasterBox = gtk.NewBox(gtk.OrientationVertical, 0)
SearchFlowBoxChild1 = gtk.NewFlowBoxChild()
SearchScrolledWindow = gtk.NewScrolledWindow()
// BELOW
// Main Notebook
MainNotebook.SetTabPos(gtk.PosBottom)
MainWindow.SetChild(MainNotebook)
// Home page
MainFlowbox.SetOrientation(gtk.OrientationVertical)
MainNotebook.AppendPage(LyricsNotebook, gtk.NewLabel("⌂"))
LyricsNotebook.AppendPage(MainFlowbox, gtk.NewLabel("⌂"))
LyricsNotebook.AppendPage(LyricsScrolledWindow, gtk.NewLabel("♪"))
MainFlowBoxChild1.SetChild(MainAlbumCover)
MainFlowBoxChild2.SetChild(MainGridFlowBoxChild2)
MainGridFlowBoxChild2.Attach(MainSongTitleLabel, 0, 0, 1, 1)
MainGridFlowBoxChild2.Attach(MainArtistLabel, 0, 1, 1, 1)
MainGridFlowBoxChild2.Attach(MainAlbumLabel, 0, 2, 1, 1)
MainGridFlowBoxChild2.Attach(MainGridFlowBoxChild2Grid, 0, 3, 1, 1)
// MainGridFlowBoxChild2Grid.Attach(MainTimeDrawnLabel, 0, 0, 1, 1)
MainGridFlowBoxChild2Grid.Attach(MainLeftSeparator, 1, 0, 1, 1)
// MainGridFlowBoxChild2Grid.Attach(MainTotalTimeLabel, 2, 0, 1, 1)
MainGridFlowBoxChild2Grid.Attach(MainRightSeparator, 3, 0, 1, 1)
// MainGridFlowBoxChild2Grid.Attach(MainTimeLeft, 4, 0, 1, 1)
MainFlowBoxChild3.SetChild(MainScaleGrid)
MainFlowBoxChild4.SetChild(MainGridFlowBoxChild4)
MainFlowbox.SetMaxChildrenPerLine(2)
MainFlowbox.SetMinChildrenPerLine(0)
MainPreviousButton.SetChild(gtk.NewLabel("◀◀"))
MainNextButton.SetChild(gtk.NewLabel("▶▶"))
MainRepeatButton.SetChild(gtk.NewLabel("⟳"))
MainStarredButton.SetChild(gtk.NewLabel("☆"))
MainGridFlowBoxChild4.Attach(MainPreviousButton, 1, 0, 1, 1)
MainGridFlowBoxChild4.Attach(MainPlayPauseButton, 2, 0, 1, 1)
MainGridFlowBoxChild4.Attach(MainNextButton, 3, 0, 1, 1)
MainGridFlowBoxChild4.Attach(MainRepeatButton, 0, 0, 1, 1)
MainGridFlowBoxChild4.Attach(MainStarredButton, 4, 0, 1, 1)
MainFlowbox.SetOrientation(gtk.OrientationHorizontal)
MainFlowbox.Insert(MainFlowBoxChild1, 0)
MainFlowbox.Insert(MainFlowBoxChild2, 1)
MainFlowbox.Insert(MainFlowBoxChild3, 2)
MainFlowbox.Insert(MainFlowBoxChild4, 3)
MainFlowbox.SetVAlign(gtk.AlignFill)
MainFlowbox.SetHAlign(gtk.AlignFill)
MainScale.SetHExpand(true)
MainScale.SetShowFillLevel(true)
MainScale.SetDrawValue(false)
MainScale.SetSizeRequest(294, 1)
// MainAdjustment.SetUpper(100)
// MainAdjustment.SetStepIncrement(float64(1.0))
// MainAdjustment.SetPageIncrement(float64(10.0))
MainAlbumCover.SetSizeRequest(300, 300)
MainAlbumCover.SetHAlign(gtk.AlignFill)
MainAlbumCover.SetVAlign(gtk.AlignFill)
MainGridFlowBoxChild2.SetHAlign(gtk.AlignCenter)
MainGridFlowBoxChild2.SetVAlign(gtk.AlignCenter)
MainGridFlowBoxChild2Grid.SetHAlign(gtk.AlignCenter)
MainGridFlowBoxChild2Grid.SetVAlign(gtk.AlignCenter)
MainLeftSeparator.SetHExpand(true)
MainRightSeparator.SetVExpand(true)
MainLeftSeparator.SetOpacity(0.0)
MainRightSeparator.SetOpacity(0.0)
MainLeftSeparator.SetSizeRequest(90, 0)
MainRightSeparator.SetSizeRequest(90, 0)
MainGridFlowBoxChild4.SetHAlign(gtk.AlignCenter)
MainGridFlowBoxChild4.SetVAlign(gtk.AlignCenter)
MainScale.SetShowFillLevel(true)
MainScaleGrid.Attach(MainScale, 0, 1, 3, 1)
MainScaleGrid.Attach(MainTimeDrawnLabel, 0, 0, 1, 1)
MainScaleGrid.Attach(MainTotalTimeLabel, 1, 0, 1, 1)
MainScaleGrid.Attach(MainTimeLeft, 2, 0, 1, 1)
MainFlowbox.SetSelectionMode(gtk.SelectionNone)
MainPlayPauseButton.SetLabel("▶")
// MainAdjustment
// Queue page
MainNotebook.AppendPage(QueueFlowBox, gtk.NewLabel("☰"))
QueueFlowBox.SetSelectionMode(gtk.SelectionNone)
QueueMasterBox.Append(QueueSearchControlBox)
QueueMasterBox.Append(QueueScrolledWindow)
QueueScrolledWindow.SetChild(QueueListBox)
QueueSearchControlBox.Attach(QueueSaveButton, 0, 0, 1, 1)
QueueSearchControlBox.Attach(QueueClearButton, 1, 0, 1, 1)
QueueSearchControlBox.Attach(QueueShuffleButton, 2, 0, 1, 1)
QueueSaveButton.SetChild(gtk.NewLabel("↧"))
QueueClearButton.SetChild(gtk.NewLabel("✘"))
QueueShuffleButton.SetChild(gtk.NewLabel("shuffle"))
QueueFlowBox.SetOrientation(gtk.OrientationVertical)
QueueFlowBox.Insert(QueueFlowBoxChild1, 0)
QueueFlowBoxChild1.SetChild(QueueMasterBox)
QueueSearchControlBox.SetHAlign(gtk.AlignEnd)
QueueSearchControlBox.SetVAlign(gtk.AlignFill)
QueueFlowBox.SetMaxChildrenPerLine(1)
QueueFlowBox.SetMinChildrenPerLine(0)
QueueListBox.SetSelectionMode(gtk.SelectionSingle)
QueueFlowBox.SetHAlign(gtk.AlignFill)
QueueFlowBox.SetVAlign(gtk.AlignFill)
QueueFlowBox.SetHExpand(true)
QueueFlowBox.SetVExpand(true)
QueueScrolledWindow.SetHExpand(true)
QueueScrolledWindow.SetVExpand(true)
QueueScrolledWindow.SetVAlign(gtk.AlignFill)
QueueScrolledWindow.SetHAlign(gtk.AlignFill)
// Search page
MainNotebook.AppendPage(SearchFlowBox, gtk.NewLabel("⌕"))
SearchFlowBox.SetSelectionMode(gtk.SelectionNone)
SearchMasterBox.Append(SearchControlBox)
SearchControlBox.Attach(SearchTabAlbumCheckButton, 1, 1, 1, 1)
SearchControlBox.Attach(SearchTabSongCheckButton, 0, 1, 1, 1)
SearchControlBox.Attach(SearchTabArtistCheckButton, 2, 1, 1, 1)
SearchControlBox.Attach(SearchTabSearchEntry, 0, 0, 2, 1)
SearchMasterBox.Append(SearchScrolledWindow)
SearchFlowBoxChild1.SetChild(SearchMasterBox)
SearchScrolledWindow.SetChild(SearchListBoxResult)
SearchFlowBox.Insert(SearchFlowBoxChild1, 0)
SearchFlowBox.SetOrientation(gtk.OrientationVertical)
SearchFlowBoxChild1.SetHAlign(gtk.AlignFill)
SearchFlowBoxChild1.SetVAlign(gtk.AlignFill)
SearchFlowBox.SetHAlign(gtk.AlignFill)
SearchFlowBox.SetVAlign(gtk.AlignFill)
SearchFlowBox.SetMaxChildrenPerLine(1)
SearchFlowBox.SetMinChildrenPerLine(0)
SearchListBoxResult.SetHExpand(true)
SearchListBoxResult.SetVExpand(true)
SearchListBoxResult.SetHAlign(gtk.AlignFill)
SearchListBoxResult.SetVAlign(gtk.AlignFill)
SearchFlowBoxChild1.SetHExpand(true)
SearchFlowBoxChild1.SetVExpand(true)
SearchFlowBox.SetHExpand(true)
SearchFlowBox.SetVExpand(true)
SearchFlowBox.SetVAlign(gtk.AlignFill)
SearchFlowBox.SetHAlign(gtk.AlignFill)
SearchControlBox.SetHAlign(gtk.AlignCenter)
SearchControlBox.SetVAlign(gtk.AlignCenter)
SearchTabSongCheckButton.SetActive(true)
SearchTabSongCheckButton.SetLabel("Songs")
SearchTabArtistCheckButton.SetLabel("Artists")
SearchTabAlbumCheckButton.SetLabel("Albums")
// Library page
MainNotebook.AppendPage(LibraryNotebook, gtk.NewLabel("||\\"))
LibraryNotebook.AppendPage(LibraryFlowBox1, gtk.NewLabel("playlists"))
LibraryNotebook.AppendPage(LibraryFlowBox2, gtk.NewLabel("☆"))
LibraryNotebook.AppendPage(LibraryFlowBox3, gtk.NewLabel("||\\"))
LibraryNotebook.AppendPage(LibraryFlowBox4, gtk.NewLabel("podcasts"))
LibraryFlowBox1.Insert(LibraryFlowBox1Child1, 0)
LibraryFlowBox2.Insert(LibraryFlowBox2Child1, 0)
LibraryFlowBox3.Insert(LibraryFlowBox3Child1, 0)
LibraryFlowBox4.Insert(LibraryFlowBox4Child1, 0)
LibraryFlowBox1.SetSelectionMode(gtk.SelectionNone)
LibraryFlowBox2.SetSelectionMode(gtk.SelectionNone)
LibraryFlowBox3.SetSelectionMode(gtk.SelectionNone)
LibraryFlowBox4.SetSelectionMode(gtk.SelectionNone)
LibraryFlowBox1Child1.SetChild(LibraryPlaylistMainBox)
LibraryFlowBox2Child1.SetChild(LibraryStarredMainBox)
LibraryFlowBox3Child1.SetChild(LibraryLibraryMainBox)
LibraryFlowBox4Child1.SetChild(LibraryPodcastMainBox)
LibraryPlaylistMainBox.Append(LibraryPlaylistMainControlGrid)
LibraryStarredMainBox.Append(LibraryStarredMainControlGrid)
LibraryLibraryMainBox.Append(LibraryLibraryMainControlGrid)
LibraryPodcastMainBox.Append(LibraryPodcastMainControlGrid)
LibraryPlaylistMainControlGrid.Attach(LibraryPlaylistBackButton, 0, 0, 1, 1)
LibraryPlaylistMainControlGrid.Attach(LibraryPlaylistRefreshButton, 1, 0, 1, 1)
LibraryPlaylistBackButton.SetLabel("↵")
LibraryPlaylistRefreshButton.SetLabel("⟳")
LibraryPlaylistMainScrolledWindow.SetHExpand(true)
LibraryPlaylistMainScrolledWindow.SetVExpand(true)
LibraryPlaylistMainScrolledWindow.SetVAlign(gtk.AlignFill)
LibraryPlaylistMainScrolledWindow.SetHAlign(gtk.AlignFill)
LibraryPlaylistMainScrolledWindow.SetChild(PlayListListBox)
LibraryPlaylistMainBox.Append(LibraryPlaylistMainScrolledWindow)
LibraryStarredMainControlGrid.Attach(LibraryStarredBackButton, 0, 0, 1, 1)
LibraryStarredMainControlGrid.Attach(LibraryStarredRefreshButton, 1, 0, 1, 1)
LibraryStarredBackButton.SetLabel("↵")
LibraryStarredRefreshButton.SetLabel("⟳")
LibraryStarredListBoxScrolledWindow.SetHExpand(true)
LibraryStarredListBoxScrolledWindow.SetVExpand(true)
LibraryStarredListBoxScrolledWindow.SetVAlign(gtk.AlignFill)
LibraryStarredListBoxScrolledWindow.SetHAlign(gtk.AlignFill)
LibraryStarredListBoxScrolledWindow.SetChild(LibraryStarredListBox)
LibraryStarredMainBox.Append(LibraryStarredListBoxScrolledWindow)
LibraryLibraryMainControlGrid.Attach(LibraryLibraryBackButton, 0, 0, 1, 1)
LibraryLibraryMainControlGrid.Attach(LibraryLibraryRefreshButton, 1, 0, 1, 1)
LibraryLibraryBackButton.SetLabel("↵")
LibraryLibraryRefreshButton.SetLabel("⟳")
QueueListBoxLibraryScrolledWindow.SetHExpand(true)
QueueListBoxLibraryScrolledWindow.SetVExpand(true)
QueueListBoxLibraryScrolledWindow.SetVAlign(gtk.AlignFill)
QueueListBoxLibraryScrolledWindow.SetHAlign(gtk.AlignFill)
QueueListBoxLibraryScrolledWindow.SetChild(QueueListBoxLibrary)
LibraryLibraryMainBox.Append(QueueListBoxLibraryScrolledWindow)
LibraryPodcastMainControlGrid.Attach(LibraryPodcastBackButton, 0, 0, 1, 1)
LibraryPodcastMainControlGrid.Attach(LibraryPodcastRefreshButton, 1, 0, 1, 1)
LibraryPodcastBackButton.SetLabel("↵")
LibraryPodcastRefreshButton.SetLabel("⟳")
LibraryPodcastListBoxScrolledWindow.SetHExpand(true)
LibraryPodcastListBoxScrolledWindow.SetVExpand(true)
LibraryPodcastListBoxScrolledWindow.SetVAlign(gtk.AlignFill)
LibraryPodcastListBoxScrolledWindow.SetHAlign(gtk.AlignFill)
LibraryPodcastListBoxScrolledWindow.SetChild(LibraryPodcastListBox)
LibraryPodcastMainBox.Append(LibraryPodcastListBoxScrolledWindow)
LibraryFlowBox1.SetHExpand(true)
LibraryFlowBox1.SetVExpand(true)
LibraryFlowBox2.SetHExpand(true)
LibraryFlowBox2.SetVExpand(true)
LibraryFlowBox3.SetHExpand(true)
LibraryFlowBox3.SetVExpand(true)
LibraryFlowBox4.SetHExpand(true)
LibraryFlowBox4.SetVExpand(true)
LibraryFlowBox1Child1.SetHAlign(gtk.AlignFill)
LibraryFlowBox1Child1.SetVAlign(gtk.AlignFill)
LibraryFlowBox2Child1.SetHAlign(gtk.AlignFill)
LibraryFlowBox2Child1.SetVAlign(gtk.AlignFill)
LibraryFlowBox3Child1.SetHAlign(gtk.AlignFill)
LibraryFlowBox3Child1.SetVAlign(gtk.AlignFill)
LibraryFlowBox4Child1.SetHAlign(gtk.AlignFill)
LibraryFlowBox4Child1.SetVAlign(gtk.AlignFill)
LibraryPlaylistMainBox.SetHExpand(true)
LibraryStarredMainBox.SetHExpand(true)
LibraryLibraryMainBox.SetHExpand(true)
LibraryPodcastMainBox.SetHExpand(true)
LibraryPlaylistMainBox.SetVExpand(true)
LibraryStarredMainBox.SetVExpand(true)
LibraryLibraryMainBox.SetVExpand(true)
LibraryPodcastMainBox.SetVExpand(true)
PlayListListBox.SetVAlign(gtk.AlignFill)
LibraryStarredListBox.SetVAlign(gtk.AlignFill)
QueueListBoxLibrary.SetVAlign(gtk.AlignFill)
LibraryPodcastListBox.SetVAlign(gtk.AlignFill)
PlayListListBox.SetHAlign(gtk.AlignFill)
LibraryStarredListBox.SetHAlign(gtk.AlignFill)
QueueListBoxLibrary.SetHAlign(gtk.AlignFill)
LibraryPodcastListBox.SetHAlign(gtk.AlignFill)
LibraryPlaylistMainControlGrid.SetHAlign(gtk.AlignEnd)
LibraryPlaylistMainControlGrid.SetVAlign(gtk.AlignFill)
LibraryStarredMainControlGrid.SetHAlign(gtk.AlignEnd)
LibraryStarredMainControlGrid.SetVAlign(gtk.AlignFill)
LibraryLibraryMainControlGrid.SetHAlign(gtk.AlignEnd)
LibraryLibraryMainControlGrid.SetVAlign(gtk.AlignFill)
LibraryPodcastMainControlGrid.SetHAlign(gtk.AlignEnd)
LibraryPodcastMainControlGrid.SetVAlign(gtk.AlignFill)
LibraryFlowBox1.SetMaxChildrenPerLine(1)
LibraryFlowBox1.SetMinChildrenPerLine(0)
LibraryFlowBox2.SetMaxChildrenPerLine(1)
LibraryFlowBox2.SetMinChildrenPerLine(0)
LibraryFlowBox3.SetMaxChildrenPerLine(1)
LibraryFlowBox3.SetMinChildrenPerLine(0)
LibraryFlowBox4.SetMaxChildrenPerLine(1)
LibraryFlowBox4.SetMinChildrenPerLine(0)
// Settings page
SettingsAccountFlowboxChild1.SetHExpand(true)
SettingsAccountFlowboxChild1.SetVExpand(true)
SettingsAccountFlowboxChild2.SetHExpand(true)
SettingsAccountFlowboxChild2.SetVExpand(true)
SettingsAccountUserListbox.SetHExpand(true)
SettingsAccountUserListbox.SetVExpand(true)
SettingsAccountLoginGrid.SetHExpand(true)
SettingsAccountLoginGrid.SetVExpand(true)
SettingsAccountUserListbox.SetHExpand(true)
SettingsAccountUserListbox.SetVExpand(true)
SettingsAccountScrolledWindow.SetChild(SettingsAccountsFlowBox)
SettingsAppScrolledWindow.SetChild(SettingsAppFlowBox)
SettingsCreditsScrolledWindow.SetChild(SettingsCreditsFlowBox)
MainNotebook.AppendPage(SettingsNotebook, gtk.NewLabel("⚙"))
SettingsNotebook.AppendPage(SettingsAccountScrolledWindow, gtk.NewLabel("Account"))
SettingsNotebook.AppendPage(SettingsAppScrolledWindow, gtk.NewLabel("App"))
SettingsNotebook.AppendPage(SettingsCreditsScrolledWindow, gtk.NewLabel("Credits"))
SettingsAccountsFlowBox.SetSelectionMode(gtk.SelectionNone)
SettingsAppFlowBox.SetSelectionMode(gtk.SelectionNone)
SettingsCreditsFlowBox.SetSelectionMode(gtk.SelectionNone)
SettingsAccountsFlowBox.SetMaxChildrenPerLine(1)
SettingsAccountsFlowBox.SetMinChildrenPerLine(0)
SettingsAccountsFlowBox.SetHAlign(gtk.AlignFill)
SettingsAccountsFlowBox.SetVAlign(gtk.AlignFill)
SettingsAccountFlowboxChild1.SetVAlign(gtk.AlignFill)
SettingsAccountFlowboxChild1.SetHAlign(gtk.AlignCenter)
SettingsAccountFlowboxChild2.SetHExpand(true)
SettingsAccountTestButton.SetLabel("Test")
SettingsAccountSaveButton.SetLabel("Save")
SettingsAccountLoadButton.SetLabel("Load")
SettingsAppFlowBox.SetMaxChildrenPerLine(1)
SettingsAppFlowBox.SetMinChildrenPerLine(0)
SettingsCreditsFlowBox.SetMaxChildrenPerLine(1)
SettingsCreditsFlowBox.SetMinChildrenPerLine(0)
SettingsAccountBox.Append(SettingsAccountLoginGrid)
SettingsAccountBox.Append(SettingsAccountButtonsGrid)
SettingsAccountFlowboxChild1.SetChild(SettingsAccountBox)
SettingsAccountFlowboxChild2.SetChild(SettingsAccountUserListbox)
SettingsAccountsFlowBox.Insert(SettingsAccountFlowboxChild1, 0)
SettingsAccountsFlowBox.Insert(SettingsAccountFlowboxChild2, 1)
SettingsAccountLoginGrid.Attach(SettingsTabUserUsernameEntry, 1, 0, 1, 1)
SettingsAccountLoginGrid.Attach(SettingsTabUserPasswordEntry, 1, 1, 1, 1)
SettingsAccountLoginGrid.Attach(SettingsTabUserDeviceNameEntry, 1, 2, 1, 1)
SettingsAccountLoginGrid.Attach(SettingsTabUserServerEntry, 1, 3, 1, 1)
SettingsAccountLoginGrid.Attach(SettingsAccountUsernameLabel, 0, 0, 1, 1)
SettingsAccountLoginGrid.Attach(SettingsAccountPasswordLabel, 0, 1, 1, 1)
SettingsAccountLoginGrid.Attach(SettingsAccountPLayerNameLabel, 0, 2, 1, 1)
SettingsAccountLoginGrid.Attach(SettingsAccountServerLabel, 0, 3, 1, 1)
SettingsAccountButtonsGrid.Attach(SettingsTabUserStatusLabel, 0, 0, 1, 1)
SettingsAccountButtonsGrid.Attach(SettingsAccountTestButton, 1, 0, 1, 1)
SettingsAccountButtonsGrid.Attach(SettingsAccountSaveButton, 2, 0, 1, 1)
SettingsAccountButtonsGrid.Attach(SettingsAccountLoadButton, 3, 0, 1, 1)
SettingsTabUserPasswordEntry.SetInputPurpose(gtk.InputPurposePassword)
SettingsTabUserPasswordEntry.SetInvisibleChar('●')
SettingsTabUserPasswordEntry.SetVisibility(false)
SettingsTabAppAuthMetadataProxySwitch.SetHAlign(gtk.AlignEnd)
SettingsTabAppAuthStreamingProxySwitch.SetHAlign(gtk.AlignEnd)
SettingsTabAppDeleteSwitch.SetHAlign(gtk.AlignEnd)
SettingsTabAppHideHeaderBarSwitch.SetHAlign(gtk.AlignEnd)
SettingsTabAppMetadataProxySwitch.SetHAlign(gtk.AlignEnd)
SettingsTabAppStreamingProxySwitch.SetHAlign(gtk.AlignEnd)
SettingsTabAppAuthMetadataProxySwitch.SetHExpand(false)
SettingsTabAppAuthStreamingProxySwitch.SetHExpand(false)
SettingsTabAppDeleteSwitch.SetHExpand(false)
SettingsTabAppHideHeaderBarSwitch.SetHExpand(false)
SettingsTabAppMetadataProxySwitch.SetHExpand(false)
SettingsTabAppStreamingProxySwitch.SetHExpand(false)
SettingsAppLabelGrid1DeleteOnClose.SetHAlign(gtk.AlignStart)
SettingsAppLabelGrid1CoverSideSize.SetHAlign(gtk.AlignStart)
SettingsAppLabelGrid1BackgroundBlurRadius.SetHAlign(gtk.AlignStart)
SettingsAppLabelHideHeaderBar.SetHAlign(gtk.AlignStart)
SettingsAppLabelGrid2Codec.SetHAlign(gtk.AlignStart)
SettingsAppLabelGrid2Bitrate.SetHAlign(gtk.AlignStart)
SettingsAppLabelGrid2DownloadBufferSize.SetHAlign(gtk.AlignStart)
SettingsAppLabelGrid3UseProxyForStreaming.SetHAlign(gtk.AlignStart)
SettingsAppLabelGrid3UseProxyForMetadata.SetHAlign(gtk.AlignStart)
SettingsAppLabelGrid3AuthenticateMetadataProxy.SetHAlign(gtk.AlignStart)
SettingsAppLabelGrid3AuthenticateStreamingProxy.SetHAlign(gtk.AlignStart)
SettingsAppLabelGrid4Metadata.SetHAlign(gtk.AlignStart)
SettingsAppLabelGrid1DeleteOnClose.SetHExpand(true)
SettingsAppLabelGrid1CoverSideSize.SetHExpand(true)
SettingsAppLabelGrid1BackgroundBlurRadius.SetHExpand(true)
SettingsAppLabelHideHeaderBar.SetHExpand(true)
SettingsAppLabelGrid2Codec.SetHExpand(true)
SettingsAppLabelGrid2Bitrate.SetHExpand(true)
SettingsAppLabelGrid2DownloadBufferSize.SetHExpand(true)
SettingsAppLabelGrid3UseProxyForStreaming.SetHExpand(true)
SettingsAppLabelGrid3UseProxyForMetadata.SetHExpand(true)
SettingsAppLabelGrid3AuthenticateMetadataProxy.SetHExpand(true)
SettingsAppLabelGrid3AuthenticateStreamingProxy.SetHExpand(true)
SettingsAppLabelGrid4Metadata.SetHExpand(true)
SettingsAppFlowBox.Insert(SettingsAppFlowBoxChild1, 0)
SettingsAppFlowBox.Insert(SettingsAppFlowBoxChild2, 1)
SettingsAppFlowBox.Insert(SettingsAppFlowBoxChild4, 2)
SettingsAppFlowBox.Insert(SettingsAppFlowBoxChild3, 3)
SettingsAppFlowBoxChild1.SetChild(SettingsAppGrid1)
SettingsAppFlowBoxChild2.SetChild(SettingsAppGrid2)
SettingsAppFlowBoxChild3.SetChild(SettingsAppGrid3)
SettingsAppFlowBoxChild4.SetChild(SettingsAppGrid4)
SettingsAppGrid1.Attach(SettingsAppLabelGrid1, 0, 0, 2, 1)
SettingsAppGrid1.Attach(SettingsAppLabelGrid1DeleteOnClose, 0, 1, 1, 1)
SettingsAppGrid1.Attach(SettingsAppLabelGrid1CoverSideSize, 0, 2, 1, 1)
SettingsAppGrid1.Attach(SettingsAppLabelGrid1BackgroundBlurRadius, 0, 3, 1, 1)
SettingsAppGrid1.Attach(SettingsTabAppDeleteSwitch, 1, 1, 1, 1)
SettingsAppGrid1.Attach(SettingsTabAppCoverSizeEntry, 1, 2, 1, 1)
SettingsAppGrid1.Attach(SettingsTabAppBlurRadiusEntry, 1, 3, 1, 1)
SettingsAppGrid1.Attach(SettingsAppLabelHideHeaderBar, 0, 4, 1, 1)
SettingsAppGrid1.Attach(SettingsTabAppHideHeaderBarSwitch, 1, 4, 1, 1)
SettingsAppGrid2.Attach(SettingsAppLabelGrid2, 0, 0, 2, 1)
SettingsAppGrid2.Attach(SettingsAppLabelGrid2Codec, 0, 1, 1, 1)
SettingsAppGrid2.Attach(SettingsAppLabelGrid2Bitrate, 0, 2, 1, 1)
SettingsAppGrid2.Attach(SettingsAppLabelGrid2DownloadBufferSize, 0, 3, 1, 1)
SettingsAppGrid2.Attach(SettingsTabAppCodecComboBoxTest, 1, 1, 1, 1)
SettingsAppGrid2.Attach(SettingsTabAppBitrateEntry, 1, 2, 1, 1)
SettingsAppGrid2.Attach(SettingsTabAppBufferSizeEntry, 1, 3, 1, 1)
SettingsAppGrid3.Attach(SettingsAppLabelGrid3, 0, 0, 2, 1)
SettingsAppGrid3.Attach(SettingsTabAppStreamingProxySwitch, 1, 1, 1, 1)
SettingsAppGrid3.Attach(SettingsAppLabelGrid3UseProxyForStreaming, 0, 1, 1, 1)
SettingsAppGrid3.Attach(SettingsTabAppStreamingProxyEntry, 0, 2, 2, 1)
SettingsAppGrid3.Attach(SettingsAppLabelGrid3AuthenticateStreamingProxy, 0, 3, 1, 1)
SettingsAppGrid3.Attach(SettingsTabAppAuthStreamingProxySwitch, 1, 3, 1, 1)
SettingsAppGrid3.Attach(SettingsTabAppStreamingProxyUsernameEntry, 0, 4, 1, 1)
SettingsAppGrid3.Attach(SettingsTabAppStreamingProxyPassEntry, 1, 4, 1, 1)
SettingsTabAppMetadataComboBoxTest.InsertText(0, "None")
SettingsTabAppMetadataComboBoxTest.InsertText(1, "Server")
SettingsTabAppMetadataComboBoxTest.InsertText(2, "Sonically")
SettingsAppGrid4.Attach(SettingsAppLabelGrid4, 0, 0, 2, 1)
SettingsAppGrid4.Attach(SettingsAppLabelGrid4Metadata, 0, 1, 1, 1)
SettingsAppGrid4.Attach(SettingsTabAppMetadataComboBoxTest, 1, 1, 1, 1)
SettingsAppGrid4.Attach(SettingsAppLabelGrid3UseProxyForMetadata, 0, 2, 1, 1)
SettingsAppGrid4.Attach(SettingsTabAppMetadataProxySwitch, 1, 2, 1, 1)
SettingsAppGrid4.Attach(SettingsTabAppMetadataProxyEntry, 0, 3, 2, 1)
SettingsAppGrid4.Attach(SettingsAppLabelGrid3AuthenticateMetadataProxy, 0, 4, 1, 1)
SettingsAppGrid4.Attach(SettingsTabAppAuthMetadataProxySwitch, 1, 4, 1, 1)
SettingsAppGrid4.Attach(SettingsTabAppMetadataProxyUsernameEntry, 0, 5, 1, 1)
SettingsAppGrid4.Attach(SettingsTabAppMetadataProxyPassEntry, 1, 5, 1, 1)
SettingsCreditsFlowBoxChild1 = gtk.NewFlowBoxChild()
SettingsCreditsLabel1 = gtk.NewLabel("")
// "Website: https://git.itmodulo.eu/LinuxOnMobile/Sonically \nIssue Tracker: https://codeberg.org/LinuxOnMobile/Sonically/issues \nLicense: GPL3.0 \nAuthor: https://itmodulo.eu/"
SettingsCreditsFlowBox.Insert(SettingsCreditsFlowBoxChild1, 0)
SettingsCreditsFlowBoxChild1.SetChild(SettingsCreditsLabel1)
SettingsTabAppCodecComboBoxTest.InsertText(0, "opus")
SettingsTabAppCodecComboBoxTest.InsertText(1, "flac")
SettingsTabAppCodecComboBoxTest.InsertText(2, "ogg")
SettingsTabAppCodecComboBoxTest.InsertText(3, "mp3")
SettingsTabUserUsernameEntry.SetPlaceholderText("Sonic user")
SettingsTabUserServerEntry.SetPlaceholderText("https://my-sonic.server")
SettingsTabUserDeviceNameEntry.SetPlaceholderText("Sonically")
SettingsTabUserPasswordEntry.SetPlaceholderText("●●●●●●●●●●")
SettingsTabAppCoverSizeEntry.SetPlaceholderText("600")
SettingsTabAppBlurRadiusEntry.SetPlaceholderText("12")
SettingsTabAppBitrateEntry.SetPlaceholderText("128")
SettingsTabAppBufferSizeEntry.SetPlaceholderText("4096")
SettingsTabAppStreamingProxyEntry.SetPlaceholderText("https://my-proxy.server")
SettingsTabAppStreamingProxyUsernameEntry.SetPlaceholderText("Proxy username")
SettingsTabAppStreamingProxyPassEntry.SetPlaceholderText("●●●●●●●●●●")
SettingsTabAppMetadataProxyEntry.SetPlaceholderText("socks5://my-proxy.server")
SettingsTabAppMetadataProxyUsernameEntry.SetPlaceholderText("Proxy username")
SettingsTabAppMetadataProxyPassEntry.SetPlaceholderText("●●●●●●●●●●")
SettingsTabAppStreamingProxyPassEntry.SetInputPurpose(gtk.InputPurposePassword)
SettingsTabAppStreamingProxyPassEntry.SetInvisibleChar('●')
SettingsTabAppStreamingProxyPassEntry.SetVisibility(false)
SettingsTabAppMetadataProxyPassEntry.SetInputPurpose(gtk.InputPurposePassword)
SettingsTabAppMetadataProxyPassEntry.SetInvisibleChar('●')
SettingsTabAppMetadataProxyPassEntry.SetVisibility(false)
// SettingsTabAppCodecComboBoxTest.AddAttribute(gtk.CellRendererFocused)
// Signals
MainPlayPauseButton.ConnectClicked(MainPlayPauseButtonClicked)
MainPreviousButton.ConnectClicked(MainPreviousButtonClicked)
MainNextButton.ConnectClicked(MainNextButtonClicked)
QueueClearButton.ConnectClicked(ClearQueue)
QueueSaveButton.ConnectClicked(CacheAllQueue)
SettingsAccountTestButton.ConnectClicked(TestConnButtonClicked)
SettingsAccountSaveButton.ConnectClicked(SettingsTabUserSaveButtonClicked)
SearchTabSearchEntry.ConnectSearchChanged(SearchTabSearchButtonClicked)
LibraryLibraryBackButton.ConnectClicked(LibraryTabBackButtonClicked)
LibraryLibraryRefreshButton.ConnectClicked(LibraryTabRefreshButtonClicked)
LibraryPlaylistBackButton.ConnectClicked(LibraryTabLibraryBackButton)
LibraryPlaylistRefreshButton.ConnectClicked(LibraryTabLibraryRefreshButton)
// MainScale.ConnectValueChanged(ValueChanged)
}
func CreateImagelessSongListBoxRow(lBox *gtk.ListBox, title string, artist string, duration string, postition int, id string) {
MainListboxRow := gtk.NewListBoxRow()
MainGrid := gtk.NewGrid()
Frame := gtk.NewFrame("")
QueueButton := gtk.NewButton()
PLaybutton := gtk.NewButton()
TitleScrolledWindow := gtk.NewScrolledWindow()
ArtistScrolledWindow := gtk.NewScrolledWindow()
TitleLabel := gtk.NewLabel(title)
ArtistLabel := gtk.NewLabel(artist)
DurationLabel := gtk.NewLabel(duration)
PLaybutton.SetLabel("▶")
QueueButton.SetLabel("☰")
MainListboxRow.SetSizeRequest(150, 30)
MainGrid.Attach(DurationLabel, 0, 0, 1, 2)
MainGrid.Attach(TitleScrolledWindow, 1, 0, 1, 1)
MainGrid.Attach(ArtistScrolledWindow, 1, 1, 1, 1)
TitleScrolledWindow.SetChild(TitleLabel)
ArtistScrolledWindow.SetChild(ArtistLabel)
MainGrid.Attach(QueueButton, 2, 0, 1, 2)
MainGrid.Attach(PLaybutton, 3, 0, 1, 2)
QueueButton.SetSizeRequest(15, 30)
PLaybutton.SetSizeRequest(15, 30)
DurationLabel.SetSizeRequest(30, 30)
DurationLabel.SetHAlign(gtk.AlignCenter)
DurationLabel.SetVAlign(gtk.AlignCenter)
TitleLabel.SetHAlign(gtk.AlignStart)
ArtistLabel.SetHAlign(gtk.AlignStart)
TitleLabel.SetSizeRequest(150, 15)
ArtistLabel.SetSizeRequest(150, 15)
TitleScrolledWindow.SetHExpand(true)
ArtistScrolledWindow.SetHExpand(true)
// MainListboxRow.SetSizeRequest(300,50)
MainListboxRow.SetHAlign(gtk.AlignFill)
MainGrid.SetHAlign(gtk.AlignFill)
MainListboxRow.SetHExpand(true)
MainGrid.SetHExpand(true)
TitleScrolledWindow.SetSizeRequest(110, 15)
ArtistScrolledWindow.SetSizeRequest(110, 15)
QueueButton.SetHAlign(gtk.AlignEnd)
PLaybutton.SetHAlign(gtk.AlignEnd)
// TitleScrolledWindow.SetHAlign(gtk.AlignStart)
// ArtistScrolledWindow.SetHAlign(gtk.AlignStart)
// Signals
var PlayButtonClicked = func() {
var upstream = func() {
if !SliceContains(MainQueue, id) {
// fmt.Println(len(MainQueue))
// MainQueue.Add(id)
MainQueue = append(MainQueue, id)
// fmt.Println(MainQueue.Size())
// fmt.Println(MainQueue)
NowPlayingIndex = SliceIndexOf(MainQueue, id)
go StartCaching(id)
CreateImagelessQueueListBoxRow(QueueListBox, title, artist, duration, NowPlayingIndex, id)
// CreateQueueChild(ttl, "album", artst, durat, id)
PlayAudio = false
EndPlayer = true
go PlayPort()
select {
case AudioControlChan <- true:
}
}
}
glib.IdleAdd(upstream)
}
var QueueButtonClicked = func() {
var upstream = func() {
if !SliceContains(MainQueue, id) {
MainQueue = append(MainQueue, id)
// NowPlayingIndex = MainQueue.IndexOf(id)
if SliceIndexOf(MainQueue, id)-1 == NowPlayingIndex || SliceIndexOf(MainQueue, id)-2 == NowPlayingIndex {
fmt.Println("Song is next or 2 next in queue, caching")
go StartCaching(id)
}
CreateImagelessQueueListBoxRow(QueueListBox, title, artist, duration, NowPlayingIndex, id)
}
}
glib.IdleAdd(upstream)
}
PLaybutton.ConnectClicked(PlayButtonClicked)
QueueButton.ConnectClicked(QueueButtonClicked)
MainListboxRow.SetChild(Frame)
Frame.SetChild(MainGrid)
lBox.Append(MainListboxRow)
}
func CreateImagelessQueueListBoxRow(lBox *gtk.ListBox, title string, artist string, duration string, postition int, id string) {
MainListboxRow := gtk.NewListBoxRow()
MainGrid := gtk.NewGrid()
Frame := gtk.NewFrame("")
DelButton := gtk.NewButton()
PLaybutton := gtk.NewButton()
ArrUPButton := gtk.NewButton()
ArrDownButton := gtk.NewButton()
TitleScrolledWindow := gtk.NewScrolledWindow()
ArtistScrolledWindow := gtk.NewScrolledWindow()
TitleLabel := gtk.NewLabel(title)
ArtistLabel := gtk.NewLabel(artist)
DurationLabel := gtk.NewLabel(duration)
DelButton.SetLabel("✗")
PLaybutton.SetLabel("▶")
ArrUPButton.SetLabel("▲")
ArrDownButton.SetLabel("▼")
Frame.SetChild(MainGrid)
MainListboxRow.SetChild(Frame)
MainGrid.Attach(DurationLabel, 0, 0, 1, 2)
MainGrid.Attach(TitleScrolledWindow, 1, 0, 3, 1)
MainGrid.Attach(ArtistScrolledWindow, 1, 1, 1, 1)
MainGrid.Attach(DelButton, 2, 1, 1, 1)
MainGrid.Attach(PLaybutton, 3, 1, 1, 1)
MainGrid.Attach(ArrUPButton, 4, 0, 1, 1)
MainGrid.Attach(ArrDownButton, 4, 1, 1, 1)
TitleScrolledWindow.SetChild(TitleLabel)
ArtistScrolledWindow.SetChild(ArtistLabel)
TitleScrolledWindow.SetHExpand(true)
ArtistScrolledWindow.SetHExpand(true)
// MainListboxRow.SetSizeRequest(300,50)
MainListboxRow.SetHAlign(gtk.AlignFill)
MainGrid.SetHAlign(gtk.AlignFill)
MainListboxRow.SetHExpand(true)
MainGrid.SetHExpand(true)
TitleScrolledWindow.SetSizeRequest(110, 25)
ArtistScrolledWindow.SetSizeRequest(110, 25)
// Frame.SetChild(MainListboxRow)
var PlayButtonClicked = func() {
var upstream = func() {
MainQueue = append(MainQueue, id)
// MasterStramSlice[id]
// go StartCaching(id)
// MainQueue.Add(id)
// NowPlayingIndex = MainQueue.IndexOf(id)
NowPlayingIndex = SliceIndexOf(MainQueue, id)
PlayAudio = false
EndPlayer = true
go PlayPort()
select {
case AudioControlChan <- true:
}
}
glib.IdleAdd(upstream)
}
var UpButtonClicked = func() {
var show = func() {
indx := SliceIndexOf(MainQueue, id)
rowId := MainListboxRow.Index()
if rowId > 0 {
SliceSwapAtIndexes(MainQueue, indx, (indx - 1))
QueueListBox.Remove(MainListboxRow)
QueueListBox.Insert(MainListboxRow, rowId-1)
if indx == NowPlayingIndex {
NowPlayingIndex--
}
}
}
go glib.IdleAdd(show)
}
var DownButtonClicked = func() {
var show = func() {
indx := SliceIndexOf(MainQueue, id)
rowId := MainListboxRow.Index()
if !(indx+1 > len(MainQueue)-1) {
if indx == NowPlayingIndex {
NowPlayingIndex++
}
SliceSwapAtIndexes(MainQueue, indx, (indx + 1))
QueueListBox.Remove(MainListboxRow)
QueueListBox.Insert(MainListboxRow, rowId+1)
}
}
go glib.IdleAdd(show)
}
var RemoveButtonClicked = func() {
var rm = func() {
if SliceIndexOf(MainQueue, id) == NowPlayingIndex {
PlayAudio = false
EndPlayer = true
}
// MainQueue.Remove(MainQueue.IndexOf(id))
SliceRemove(MainQueue, id)
QueueListBox.Remove(MainListboxRow)
}
go glib.IdleAdd(rm)
}
PLaybutton.ConnectClicked(PlayButtonClicked)
ArrUPButton.ConnectClicked(UpButtonClicked)
ArrDownButton.ConnectClicked(DownButtonClicked)
DelButton.ConnectClicked(RemoveButtonClicked)
lBox.Append(MainListboxRow)
}
// func ValueChanged(){
// PlayAudio = false
// if MainScale.Value() > TimeInPrecent {
// // CurrentStream.Stop()
// for (TimeInPrecent < MainScale.Value() && TimeInPrecent < float64(TotalTime)) {
// _, _ = OpusStr.Read(Out)
// DrawnTime += float64(1920 / rate / 2)
// TimeInPrecent = float64(DrawnTime / float64(TotalTime))
// }
// // CurrentStream.Start()
// CurrentStream.Write()
// glib.IdleAdd(UpdatePBar())
// PlayAudio = true
// } else {
// fmt.Println("Not yet implemented")
// MainScale.SetValue(TimeInPrecent)
// PlayAudio = true
// }
// }
func CreatelessListArtistBoxRow(lBox *gtk.ListBox, name string, postition int, albums []*subsonic.AlbumID3, itemid string) {
MainListboxRow := gtk.NewListBoxRow()
MainGrid := gtk.NewGrid()
Frame := gtk.NewFrame("")
InfoButton := gtk.NewButton()
NameScrolledWindow := gtk.NewScrolledWindow()
NameLabel := gtk.NewLabel(name)
MainGrid.Attach(NameScrolledWindow, 0, 0, 1, 1)
MainGrid.Attach(InfoButton, 1, 0, 1, 1)
NameScrolledWindow.SetChild(NameLabel)
Frame.SetChild(MainGrid)
MainListboxRow.SetChild(Frame)
InfoButton.SetLabel("i")
MainListboxRow.SetSizeRequest(150, 30)
InfoButton.SetSizeRequest(15, 30)
NameLabel.SetHAlign(gtk.AlignStart)
NameLabel.SetSizeRequest(150, 15)
NameScrolledWindow.SetHExpand(true)
// MainListboxRow.SetSizeRequest(300,50)
MainListboxRow.SetHAlign(gtk.AlignFill)
MainGrid.SetHAlign(gtk.AlignFill)
MainListboxRow.SetHExpand(true)
MainGrid.SetHExpand(true)
NameScrolledWindow.SetSizeRequest(110, 15)
InfoButton.SetHAlign(gtk.AlignEnd)
var InfoButtonClicked = func() {
TempArtist = ""
var upstream = func() {
for child := lBox.FirstChild(); child != nil; {
lBox.Remove(child)
child = lBox.FirstChild()
}
for i, album := range albums {
alb, _ := CurrentClient.GetAlbum(album.ID)
CreateImagelessAlbumListBoxRow(lBox, alb.Name, alb.Artist, DurationToReadable(alb.Duration), i, alb.Song)
}
}
glib.IdleAdd(upstream)
}
InfoButton.ConnectClicked(InfoButtonClicked)
lBox.Append(MainListboxRow)
}
func CreateImagelessAlbumListBoxRow(lBox *gtk.ListBox, title string, artist string, duration string, postition int, songs []*subsonic.Child) {
MainListboxRow := gtk.NewListBoxRow()
MainGrid := gtk.NewGrid()
Frame := gtk.NewFrame("")
QueueButton := gtk.NewButton()
InfoButton := gtk.NewButton()
PLaybutton := gtk.NewButton()
TitleScrolledWindow := gtk.NewScrolledWindow()
ArtistScrolledWindow := gtk.NewScrolledWindow()
TitleLabel := gtk.NewLabel(title)
ArtistLabel := gtk.NewLabel(artist)
DurationLabel := gtk.NewLabel(duration)
InfoButton.SetLabel("i")
QueueButton.SetLabel("☰")
PLaybutton.SetLabel("▶")
MainGrid.Attach(DurationLabel, 0, 0, 1, 2)
MainGrid.Attach(TitleScrolledWindow, 1, 0, 1, 1)
MainGrid.Attach(ArtistScrolledWindow, 1, 1, 1, 1)
MainGrid.Attach(InfoButton, 2, 0, 1, 2)
MainGrid.Attach(QueueButton, 3, 0, 1, 2)
MainGrid.Attach(PLaybutton, 4, 0, 1, 2)
TitleScrolledWindow.SetChild(TitleLabel)
ArtistScrolledWindow.SetChild(ArtistLabel)
Frame.SetChild(MainGrid)
MainListboxRow.SetChild(Frame)
QueueButton.SetSizeRequest(15, 30)
PLaybutton.SetSizeRequest(15, 30)
DurationLabel.SetSizeRequest(30, 30)
DurationLabel.SetHAlign(gtk.AlignCenter)
DurationLabel.SetVAlign(gtk.AlignCenter)
TitleLabel.SetHAlign(gtk.AlignStart)
ArtistLabel.SetHAlign(gtk.AlignStart)
TitleLabel.SetSizeRequest(150, 15)
ArtistLabel.SetSizeRequest(150, 15)
TitleScrolledWindow.SetHExpand(true)
ArtistScrolledWindow.SetHExpand(true)
// MainListboxRow.SetSizeRequest(300,50)
MainListboxRow.SetHAlign(gtk.AlignFill)
MainGrid.SetHAlign(gtk.AlignFill)
MainListboxRow.SetHExpand(true)
MainGrid.SetHExpand(true)
TitleScrolledWindow.SetSizeRequest(110, 15)
ArtistScrolledWindow.SetSizeRequest(110, 15)
QueueButton.SetHAlign(gtk.AlignEnd)
PLaybutton.SetHAlign(gtk.AlignEnd)
InfoButton.SetSizeRequest(15, 30)
InfoButton.SetHAlign(gtk.AlignEnd)
var InfoButtonClicked = func() {
// TempArtist = itemid
var upstream = func() {
for child := lBox.FirstChild(); child != nil; {
lBox.Remove(child)
child = lBox.FirstChild()
}
for i, song := range songs {
chil, _ := CurrentClient.GetSong(song.ID)
CreateImagelessSongListBoxRow(lBox, chil.Title, chil.Artist, DurationToReadable(chil.Duration), i, chil.ID)
}
}
glib.IdleAdd(upstream)
}
var PlayButtonClicked = func() {
var upstream = func() {
PlayAudio = false
EndPlayer = true
NowPlayingIndex = 0
// MainQueue.Clear() //!
MainQueue = SliceClear(MainQueue)
for child := QueueListBox.FirstChild(); child != nil; {
QueueListBox.Remove(child)
child = QueueListBox.FirstChild()
}
for i, song := range songs {
MainQueue = append(MainQueue, song.ID)
// MainQueue.Add(song.ID)
CreateImagelessQueueListBoxRow(QueueListBox, song.Title, song.Artist, DurationToReadable(song.Duration), i, song.ID)
}
// NowPlayingIndex = MainQueue.IndexOf(songs[0].ID)
NowPlayingIndex = SliceIndexOf(MainQueue, songs[0].ID)
go StartCaching(MainQueue[NowPlayingIndex])
if NowPlayingIndex+1 <= len(MainQueue)-1 {
// fmt.Println(songdata.Title, " +1 needs to be downloaded")
go CachingWaiter(MainQueue[NowPlayingIndex], MainQueue[NowPlayingIndex+1], 5)
}
if NowPlayingIndex+2 <= len(MainQueue)-1 {
// fmt.Println(songdata.Title, " +2 needs to be downloaded")
go CachingWaiter(MainQueue[NowPlayingIndex+1], MainQueue[NowPlayingIndex+2], 5)
}
go PlayPort()
select {
case AudioControlChan <- true:
}
}
glib.IdleAdd(upstream)
}
var QueueButtonClicked = func() {
var upstream = func() {
var j = len(MainQueue)
j--
for _, song := range songs {
// MainQueue.Add(song.ID)
MainQueue = append(MainQueue, song.ID)
CreateImagelessQueueListBoxRow(QueueListBox, song.Title, song.Artist, DurationToReadable(song.Duration), j, song.ID)
}
}
glib.IdleAdd(upstream)
}
InfoButton.ConnectClicked(InfoButtonClicked)
PLaybutton.ConnectClicked(PlayButtonClicked)
QueueButton.ConnectClicked(QueueButtonClicked)
lBox.Append(MainListboxRow)
}
func CreateImagelessPlaylistListBoxRow(lBox *gtk.ListBox, title string, duration string, postition int, songs []*subsonic.Child) {
MainListboxRow := gtk.NewListBoxRow()
MainGrid := gtk.NewGrid()
Frame := gtk.NewFrame("")
InfoButton := gtk.NewButton()
QueueButton := gtk.NewButton()
PLaybutton := gtk.NewButton()
TitleScrolledWindow := gtk.NewScrolledWindow()
TitleLabel := gtk.NewLabel(title)
DurationLabel := gtk.NewLabel(duration)
QueueButton.SetLabel("☰")
PLaybutton.SetLabel("▶")
InfoButton.SetLabel("i")
MainGrid.Attach(DurationLabel, 0, 0, 1, 2)
MainGrid.Attach(TitleScrolledWindow, 1, 0, 1, 2)
MainGrid.Attach(QueueButton, 3, 0, 1, 2)
MainGrid.Attach(PLaybutton, 4, 0, 1, 2)
MainGrid.Attach(InfoButton, 2, 0, 1, 2)
TitleScrolledWindow.SetChild(TitleLabel)
MainListboxRow.SetChild(Frame)
Frame.SetChild(MainGrid)
QueueButton.SetSizeRequest(15, 30)
PLaybutton.SetSizeRequest(15, 30)
DurationLabel.SetSizeRequest(30, 30)
DurationLabel.SetHAlign(gtk.AlignCenter)
DurationLabel.SetVAlign(gtk.AlignCenter)
TitleLabel.SetHAlign(gtk.AlignStart)
TitleLabel.SetSizeRequest(150, 15)
InfoButton.SetSizeRequest(15, 30)
InfoButton.SetHAlign(gtk.AlignEnd)
TitleScrolledWindow.SetHExpand(true)
// MainListboxRow.SetSizeRequest(300,50)
MainListboxRow.SetHAlign(gtk.AlignFill)
MainGrid.SetHAlign(gtk.AlignFill)
MainListboxRow.SetHExpand(true)
MainGrid.SetHExpand(true)
TitleScrolledWindow.SetSizeRequest(110, 15)
QueueButton.SetHAlign(gtk.AlignEnd)
PLaybutton.SetHAlign(gtk.AlignEnd)
var PlayButtonClicked = func() {
var upstream = func() {
PlayAudio = false
EndPlayer = true
NowPlayingIndex = 0
// MainQueue.Clear() //!
MainQueue = SliceClear(MainQueue)
for child := QueueListBox.FirstChild(); child != nil; {
QueueListBox.Remove(child)
child = QueueListBox.FirstChild()
}
for i, song := range songs {
// MainQueue.Add(song.ID)
MainQueue = append(MainQueue, song.ID)
CreateImagelessQueueListBoxRow(QueueListBox, song.Title, song.Artist, DurationToReadable(song.Duration), i, song.ID)
}
// NowPlayingIndex = MainQueue.IndexOf(songs[0].ID)
NowPlayingIndex = SliceIndexOf(MainQueue, songs[0].ID)
go StartCaching(MainQueue[NowPlayingIndex])
if NowPlayingIndex+1 <= len(MainQueue)-1 {
// fmt.Println(songdata.Title, " +1 needs to be downloaded")
go CachingWaiter(MainQueue[NowPlayingIndex], MainQueue[NowPlayingIndex+1], 5)
}
if NowPlayingIndex+2 <= len(MainQueue)-1 {
// fmt.Println(songdata.Title, " +2 needs to be downloaded")
go CachingWaiter(MainQueue[NowPlayingIndex+1], MainQueue[NowPlayingIndex+2], 5)
}
go PlayPort()
select {
case AudioControlChan <- true:
}
}
glib.IdleAdd(upstream)
}
var QueueButtonClicked = func() {
var upstream = func() {
var j = len(MainQueue)
j--
for _, song := range songs {
// MainQueue.Add(song.ID)
MainQueue = append(MainQueue, song.ID)
CreateImagelessQueueListBoxRow(QueueListBox, song.Title, song.Artist, DurationToReadable(song.Duration), j, song.ID)
}
}
glib.IdleAdd(upstream)
}
var InfoButtonClicked = func() {
var upstream = func() {
for child := lBox.FirstChild(); child != nil; {
lBox.Remove(child)
child = lBox.FirstChild()
}
for i, song := range songs {
chil, _ := CurrentClient.GetSong(song.ID)
CreateImagelessSongListBoxRow(lBox, chil.Title, chil.Artist, DurationToReadable(chil.Duration), i, chil.ID)
}
}
glib.IdleAdd(upstream)
}
InfoButton.ConnectClicked(InfoButtonClicked)
PLaybutton.ConnectClicked(PlayButtonClicked)
QueueButton.ConnectClicked(QueueButtonClicked)
lBox.Append(MainListboxRow)
}
// var TestConnButtonClicked = func() {
// // TestConnButtonClicked()
// }
var SettingsTabUserSaveButtonClicked = func() {
CurrentClient = CreateUser(HttpSettings)
usr := SettingsTabUserUsernameEntry.Text()
serv := SettingsTabUserServerEntry.Text()
plr := SettingsTabUserDeviceNameEntry.Text()
coversize := SettingsTabAppCoverSizeEntry.Text()
blur := SettingsTabAppBlurRadiusEntry.Text()
bitr := SettingsTabAppBitrateEntry.Text()
downbuff := SettingsTabAppBufferSizeEntry.Text()
var streamURL, metaURL, streamUser, streamPass, metaUser, metaPass string
if SettingsTabAppStreamingProxySwitch.Active() == true {
streamURL = SettingsTabAppStreamingProxyEntry.Text()
if SettingsTabAppAuthStreamingProxySwitch.Active() == true {
streamUser = SettingsTabAppStreamingProxyUsernameEntry.Text()
streamPass = SettingsTabAppStreamingProxyPassEntry.Text()
keyring.Set(streamURL, streamUser, streamPass)
} else {
streamUser = ""
streamPass = ""
}
} else {
streamURL = ""
streamUser = ""
streamPass = ""
}
if SettingsTabAppMetadataProxySwitch.Active() == true {
metaURL = SettingsTabAppMetadataProxyEntry.Text()
if SettingsTabAppAuthMetadataProxySwitch.Active() == true {
metaUser = SettingsTabAppMetadataProxyUsernameEntry.Text()
metaPass = SettingsTabAppMetadataProxyPassEntry.Text()
keyring.Set(metaURL, metaUser, metaPass)
}
} else {
metaURL = ""
metaUser = ""
metaPass = ""
}
UserDeserialized = User{
User: usr,
Url: serv,
}
UserList[0] = UserDeserialized
var coversizeInt int16
fmt.Sscan(coversize, &coversizeInt)
var blurInt int8
fmt.Sscan(blur, &blurInt)
var bitrInt int16
fmt.Sscan(bitr, &bitrInt)
var downbuffInt int16
fmt.Sscan(downbuff, &downbuffInt)
MainSettings = Settings{
Users: UserList,
PlayerName: plr,
DeleteOnClose: SettingsTabAppDeleteSwitch.Active(),
Coversize: coversizeInt,
BlurRadius: blurInt,
HideHeaderBar: SettingsTabAppHideHeaderBarSwitch.Active(),
Codec: SettingsTabAppCodecComboBoxTest.ActiveText(),
Bitrate: bitrInt,
DownladBufferSize: downbuffInt,
UseStreamingProxy: SettingsTabAppStreamingProxySwitch.Active(),
StreamingProxy: streamURL,
AuthStreamingProxy: SettingsTabAppAuthStreamingProxySwitch.Active(),
StreamingProxyUser: streamUser,
MetadataType: SettingsTabAppMetadataComboBoxTest.ActiveText(),
UseMetadataProxy: SettingsTabAppMetadataProxySwitch.Active(),
MetadataProxy: metaURL,
AuthMetadataProxy: SettingsTabAppAuthMetadataProxySwitch.Active(),
MetadataProxyUser: metaUser,
}
server := SettingsTabUserServerEntry.Text()
username := SettingsTabUserUsernameEntry.Text()
pass := SettingsTabUserPasswordEntry.Text()
err := keyring.Set(server, username, pass)
if err != nil {
}
fmt.Println("")
fmt.Println(UserDeserialized)
fmt.Println(MainSettings)
fmt.Println(settingsPath)
fmt.Println("")
Serialize(MainSettings, settingsPath)
}
var SearchTabSearchButtonClicked = func() {
Search()
// fmt.Println("end searching")
}
var MainSliderUserValueChange = func() {
}
var MainPlayPauseButtonClicked = func() {
// // if NowPlayingIndex == 0 && PlayAudio == false && TotalTime == 0 {
// // go PlayPort()
// // }
PlayAudio = !PlayAudio
if PlayAudio == true {
MainPlayPauseButton.SetLabel("❚❚")
} else {
MainPlayPauseButton.SetLabel("▶")
}
}
var LibraryTabBackButtonClicked = func() {
// if TempArtist != "" {
// var upstream = func() {
// for child := QueueListBoxLibrary.FirstChild(); child != nil; {
// QueueListBoxLibrary.Remove(child)
// child = QueueListBoxLibrary.FirstChild()
// }
// artist, _ := CurrentClient.GetArtist(TempArtist)
// albums := artist.Album
// for i, album := range albums {
// alb, _ := CurrentClient.GetAlbum(album.ID)
// CreateImagelessAlbumListBoxRow(QueueListBoxLibrary, alb.Name, alb.Artist, DurationToReadable(alb.Duration), i, alb.Song)
// }
// }
// glib.IdleAdd(upstream)
// TempArtist = ""
// } else {
// GetLib()
// }
GetLib()
}
var LibraryTabRefreshButtonClicked = func() {
GetLib()
}
var LibraryTabLibraryRefreshButton = func() {
GetPlaylist()
}
var LibraryTabLibraryBackButton = func() {
GetPlaylist()
}
var MainPreviousButtonClicked = func() {
PlayAudio = false
EndPlayer = true
// CurrentStream = nil
if NowPlayingIndex-1 >= 0 {
NowPlayingIndex--
}
notify.CloseNotification(MainNotification.ReplacesID)
UpdatePBar()
go PlayPort()
}
var MainNextButtonClicked = func() {
PlayAudio = false
EndPlayer = true
// CurrentStream = nil
if !(NowPlayingIndex+1 > (len(MainQueue) - 1)) {
NowPlayingIndex++
go StartCaching(MainQueue[NowPlayingIndex])
if NowPlayingIndex+1 <= len(MainQueue)-1 {
// fmt.Println(songdata.Title, " +1 needs to be downloaded")
go CachingWaiter(MainQueue[NowPlayingIndex], MainQueue[NowPlayingIndex+1], 5)
}
if NowPlayingIndex+2 <= len(MainQueue)-1 {
// fmt.Println(songdata.Title, " +2 needs to be downloaded")
go CachingWaiter(MainQueue[NowPlayingIndex+1], MainQueue[NowPlayingIndex+2], 5)
}
}
notify.CloseNotification(MainNotification.ReplacesID)
UpdatePBar()
go PlayPort()
}
// func MoveListBoxChildren(lb *gtk.ListBox, position int){
// // row := lb.RowAtIndex(position +1 )
// // lb.Remove(row)
// // lb.Insert(row, position)
// // position++
// for row := lb.RowAtIndex(position +1 ); position < len(MainQueue); {
// lb.Remove(row)
// lb.Insert(row, position)
// position++
// }
// }
var ClearQueue = func() {
PlayAudio = false
EndPlayer = true
NowPlayingIndex = 0
MainQueue = MainQueue[:0]
SetZeroTime()
for child := QueueListBox.FirstChild(); child != nil; {
QueueListBox.Remove(child)
child = QueueListBox.FirstChild()
}
}
var CacheAllQueue = func() {
StartCaching(MainQueue[0])
for i := 1; i < len(MainQueue); i++ {
go CachingWaiter(MainQueue[i-1], MainQueue[i], 5)
}
}