Sonically/shared_objects.go

244 lines
7.9 KiB
Go

package main
import (
"io"
"net/http"
"os"
"sync"
"github.com/TheCreeper/go-notify"
"github.com/delucks/go-subsonic"
"github.com/diamondburned/gotk4/pkg/gtk/v4"
// "github.com/diamondburned/gotk4/pkg/gdk/v4"
// "github.com/diamondburned/gotk4/pkg/core/glib"
"github.com/djherbis/fscache"
// "github.com/emirpasic/gods/lists/arraylist"
"github.com/gordonklaus/portaudio"
"github.com/hraban/opus"
)
func GetRunDir() string {
rundirGet, _ := os.UserHomeDir()
return rundirGet
}
// Dirs
const MainDir string = "/.Sonically"
const DataDir string = "/data"
const SettingsDir string = "/Settings"
const InfDir string = "/inf"
var CurrentClient subsonic.Client
var CurrentStream *portaudio.Stream
var MainQueue []string
var NowPlayingIndex int = 0
var UserList [10]User
var UserDeserialized User
var MainSettings Settings
var DownloadSyncGroup sync.WaitGroup
var TotalTime int = 0
var DrawnTime float64 = float64(0.0)
var Out []int16 = make([]int16, 1920)
// var ReadBuffer []byte
// var MasterStramSlice map[string]SonicallyStream
var CachingMap map[string]bool = make(map[string]bool)
var TimeInPrecent float64 = 0.0
var CurrentCache fscache.Cache
var AudioControlChan chan bool
var OpusStr *opus.Stream
var ReadMaster fscache.ReadAtCloser
var WriteMaster io.WriteCloser
var ArtistsCached []string
var PlaylistCached []string
var TempArtist string = ""
var EnterArtist bool
// UI widgets declaration
var MainWindow *gtk.ApplicationWindow
var LyricsNotebook *gtk.Notebook
var LyricsScrolledWindow *gtk.ScrolledWindow
var MainFlowbox *gtk.FlowBox
var MainFlowBoxChild1 *gtk.FlowBoxChild
var MainFlowBoxChild2 *gtk.FlowBoxChild
var MainFlowBoxChild3 *gtk.FlowBoxChild
var MainFlowBoxChild4 *gtk.FlowBoxChild
var MainGridFlowBoxChild2 *gtk.Grid
var MainGridFlowBoxChild4 *gtk.Grid
var MainGridFlowBoxChild2Grid *gtk.Grid
var MainLeftSeparator *gtk.Separator
var MainRightSeparator *gtk.Separator
var MainScale *gtk.Scale
var MainScaleGrid *gtk.Grid
var QueueMasterBox *gtk.Box
var QueueSearchControlBox *gtk.Grid
var QueueFlowBox *gtk.FlowBox
var QueueScrolledWindow *gtk.ScrolledWindow
var QueueSaveButton *gtk.Button
var QueueClearButton *gtk.Button
var QueueShuffleButton *gtk.Button
var QueueFlowBoxChild1 *gtk.FlowBoxChild
var SearchFlowBox *gtk.FlowBox
var SearchFlowBoxChild1 *gtk.FlowBoxChild
var SearchMasterBox *gtk.Box
var SearchControlBox *gtk.Grid
var SearchScrolledWindow *gtk.ScrolledWindow
var LibraryFlowBox1 *gtk.FlowBox
var LibraryFlowBox2 *gtk.FlowBox
var LibraryFlowBox3 *gtk.FlowBox
var LibraryFlowBox4 *gtk.FlowBox
var LibraryPlaylistMainBox *gtk.Box
var LibraryStarredMainBox *gtk.Box
var LibraryLibraryMainBox *gtk.Box
var LibraryPodcastMainBox *gtk.Box
var LibraryFlowBox1Child1 *gtk.FlowBoxChild
var LibraryFlowBox2Child1 *gtk.FlowBoxChild
var LibraryFlowBox3Child1 *gtk.FlowBoxChild
var LibraryFlowBox4Child1 *gtk.FlowBoxChild
var LibraryPlaylistMainControlGrid *gtk.Grid
var LibraryStarredMainControlGrid *gtk.Grid
var LibraryLibraryMainControlGrid *gtk.Grid
var LibraryPodcastMainControlGrid *gtk.Grid
var LibraryPlaylistBackButton *gtk.Button
var LibraryPlaylistRefreshButton *gtk.Button
var LibraryStarredBackButton *gtk.Button
var LibraryStarredRefreshButton *gtk.Button
var LibraryLibraryBackButton *gtk.Button
var LibraryLibraryRefreshButton *gtk.Button
var LibraryPodcastBackButton *gtk.Button
var LibraryPodcastRefreshButton *gtk.Button
var LibraryStarredListBox *gtk.ListBox
var LibraryPodcastListBox *gtk.ListBox
var LibraryPlaylistMainScrolledWindow *gtk.ScrolledWindow
var LibraryPodcastListBoxScrolledWindow *gtk.ScrolledWindow
var LibraryStarredListBoxScrolledWindow *gtk.ScrolledWindow
var QueueListBoxLibraryScrolledWindow *gtk.ScrolledWindow
var SettingsFlowBox *gtk.FlowBox
var SettingsTabUserUsernameEntry *gtk.Entry
var SettingsTabUserServerEntry *gtk.Entry
var SettingsTabUserDeviceNameEntry *gtk.Entry
var SettingsTabUserPasswordEntry *gtk.Entry
var SettingsTabUserStatusLabel *gtk.Label
var SearchTabSearchEntry *gtk.SearchEntry
var SearchTabSongCheckButton *gtk.CheckButton
var SearchTabAlbumCheckButton *gtk.CheckButton
var SearchTabArtistCheckButton *gtk.CheckButton
var SearchListBoxResult *gtk.ListBox
var PlayListListBox *gtk.ListBox
var MainSongTitleLabel *gtk.Label
var MainArtistLabel *gtk.Label
var MainAlbumLabel *gtk.Label
var MainTimeDrawnLabel *gtk.Label
var MainTimeLeft *gtk.Label
var MainAdjustment *gtk.Adjustment
var SettingsTabAppDeleteSwitch *gtk.Switch
var SettingsTabAppCodecComboBoxTest *gtk.ComboBoxText
// var SettingsTabAppRetrievingComboBoxText *gtk.ComboBoxText
var SettingsTabAppCacheEntry *gtk.Entry
var QueueListBox *gtk.ListBox
var MainAlbumCover *gtk.Image
var MainPlayPauseButton *gtk.Button
var MainPreviousButton *gtk.Button
var MainNextButton *gtk.Button
var MainRepeatButton *gtk.Button
var MainStarredButton *gtk.Button
var MainSubtitlesTextView *gtk.TextView
var MainTotalTimeLabel *gtk.Label
var LibraryNotebook *gtk.Notebook
var MainNotebook *gtk.Notebook
var QueueListBoxLibrary *gtk.ListBox
var SettingsTabAppCoverSizeEntry *gtk.Entry
var SettingsTabAppBlurRadiusEntry *gtk.Entry
var SettingsTabAppBitrateEntry *gtk.Entry
var SettingsTabAppBufferSizeEntry *gtk.Entry
var SettingsTabAppStreamingProxySwitch *gtk.Switch
var SettingsTabAppStreamingProxyEntry *gtk.Entry
var SettingsTabAppAuthStreamingProxySwitch *gtk.Switch
var SettingsTabAppStreamingProxyUsernameEntry *gtk.Entry
var SettingsTabAppStreamingProxyPassEntry *gtk.Entry
var SettingsTabAppMetadataProxySwitch *gtk.Switch
var SettingsTabAppMetadataProxyEntry *gtk.Entry
var SettingsTabAppAuthMetadataProxySwitch *gtk.Switch
var SettingsTabAppMetadataProxyUsernameEntry *gtk.Entry
var SettingsTabAppMetadataProxyPassEntry *gtk.Entry
var SettingsAccountsFlowBox *gtk.FlowBox
var SettingsAccountFlowboxChild1 *gtk.FlowBoxChild
var SettingsAccountFlowboxChild2 *gtk.FlowBoxChild
var SettingsNotebook *gtk.Notebook
var SettingsAccountBox *gtk.Box
var SettingsAccountLoginGrid *gtk.Grid
var SettingsAccountButtonsGrid *gtk.Grid
var SettingsAccountUserListbox *gtk.ListBox
var SettingsAppFlowBox *gtk.FlowBox
var SettingsCreditsFlowBox *gtk.FlowBox
var SettingsAccountUsernameLabel *gtk.Label
var SettingsAccountPasswordLabel *gtk.Label
var SettingsAccountPLayerNameLabel *gtk.Label
var SettingsAccountServerLabel *gtk.Label
var SettingsAccountTestButton *gtk.Button
var SettingsAccountSaveButton *gtk.Button
var SettingsAccountLoadButton *gtk.Button
// var SettingsAppScrolledWindow *gtk.ScrolledWindow
var SettingsAppFlowBoxChild1 *gtk.FlowBoxChild
var SettingsAppFlowBoxChild2 *gtk.FlowBoxChild
var SettingsAppFlowBoxChild3 *gtk.FlowBoxChild
var SettingsAppFlowBoxChild4 *gtk.FlowBoxChild
var SettingsAppGrid1 *gtk.Grid
var SettingsAppGrid2 *gtk.Grid
var SettingsAppGrid3 *gtk.Grid
var SettingsAppGrid4 *gtk.Grid
var SettingsAppLabelGrid4 *gtk.Label
var SettingsAppLabelGrid4Metadata *gtk.Label
var SettingsTabAppMetadataComboBoxTest *gtk.ComboBoxText
var SettingsAppLabelGrid1 *gtk.Label
var SettingsAppLabelGrid2 *gtk.Label
var SettingsAppLabelGrid3 *gtk.Label
var SettingsAppLabelGrid1DeleteOnClose *gtk.Label
var SettingsAppLabelGrid1CoverSideSize *gtk.Label
var SettingsAppLabelGrid1BackgroundBlurRadius *gtk.Label
var SettingsAppLabelGrid2Codec *gtk.Label
var SettingsAppLabelGrid2Bitrate *gtk.Label
var SettingsAppLabelGrid2DownloadBufferSize *gtk.Label
var SettingsTabAppHideHeaderBarSwitch *gtk.Switch
var SettingsAppLabelHideHeaderBar *gtk.Label
var SettingsAccountScrolledWindow *gtk.ScrolledWindow
var SettingsAppScrolledWindow *gtk.ScrolledWindow
var SettingsCreditsScrolledWindow *gtk.ScrolledWindow
var SettingsAppLabelGrid3UseProxyForStreaming *gtk.Label
var SettingsAppLabelGrid3AuthenticateStreamingProxy *gtk.Label
var SettingsAppLabelGrid3UseProxyForMetadata *gtk.Label
var SettingsAppLabelGrid3AuthenticateMetadataProxy *gtk.Label
var SettingsCreditsFlowBoxChild1 *gtk.FlowBoxChild
var SettingsCreditsLabel1 *gtk.Label
var MetadataClient *http.Client
var HttpSettings *http.Client
// var one gtk.EventBox
// LIBNOTIFY
var MainNotification notify.Notification