mirror of
https://github.com/aditya-K2/gspt.git
synced 2026-01-08 21:37:58 -05:00
Using Updated Ui values
This commit is contained in:
2
main.go
2
main.go
@@ -11,7 +11,7 @@ func main() {
|
||||
if err := spt.InitClient(); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
if err := ui.NewApplication().App.Run(); err != nil {
|
||||
if err := ui.NewApplication().Run(); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ func getFontWidth() (int, int, error) {
|
||||
if err != nil {
|
||||
return 0, 0, err
|
||||
}
|
||||
_, _, rw, rh := Ui.Root.Root.GetRect()
|
||||
_, _, rw, rh := root.Root.GetRect()
|
||||
if rw == 0 || rh == 0 {
|
||||
return 0, 0, errors.New("Unable to get row width and height")
|
||||
}
|
||||
|
||||
@@ -23,5 +23,5 @@ func OpenDeviceMenu() {
|
||||
RefreshProgress(true)
|
||||
}
|
||||
})
|
||||
Ui.Root.AddCenteredWidget(m)
|
||||
root.AddCenteredWidget(m)
|
||||
}
|
||||
|
||||
@@ -3,8 +3,8 @@ package ui
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"github.com/gdamore/tcell/v2"
|
||||
"github.com/aditya-K2/tview"
|
||||
"github.com/gdamore/tcell/v2"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -162,7 +162,7 @@ func (i *interactiveView) getHandler(s string) func(e *tcell.EventKey) *tcell.Ev
|
||||
},
|
||||
"openCtx": func(e *tcell.EventKey) *tcell.EventKey {
|
||||
if GetCurrentView().ContextOpener() != nil {
|
||||
GetCurrentView().ContextOpener()(Ui.Root, Ui.Main.SelectionHandler)
|
||||
GetCurrentView().ContextOpener()(root, Main.SelectionHandler)
|
||||
return nil
|
||||
}
|
||||
return e
|
||||
|
||||
@@ -56,6 +56,7 @@ func NewPlaylistNav() *PlaylistNav {
|
||||
T := tview.NewTable()
|
||||
T.SetSelectable(true, false).SetBorder(true)
|
||||
T.SetTitle("Playlists").SetTitleAlign(tview.AlignLeft)
|
||||
T.SetBackgroundColor(tcell.ColorDefault)
|
||||
v := &PlaylistNav{&defView{}, T, nil, make(chan bool), func(err error) {
|
||||
if err != nil {
|
||||
SendNotification(err.Error())
|
||||
|
||||
16
ui/notify.go
16
ui/notify.go
@@ -6,8 +6,8 @@ import (
|
||||
|
||||
"github.com/aditya-K2/utils"
|
||||
|
||||
"github.com/gdamore/tcell/v2"
|
||||
"github.com/aditya-K2/tview"
|
||||
"github.com/gdamore/tcell/v2"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -138,18 +138,18 @@ func notify(n *notification) {
|
||||
npos = posArr.GetNextPosition()
|
||||
}
|
||||
n.position = npos
|
||||
Ui.Root.Root.AddPage(currentTime, n, false, true)
|
||||
Ui.App.Draw()
|
||||
Ui.App.SetFocus(Ui.Main.Table)
|
||||
root.Root.AddPage(currentTime, n, false, true)
|
||||
App.Draw()
|
||||
App.SetFocus(Main.Table)
|
||||
if n.msg != nil {
|
||||
n.text = <-n.msg
|
||||
Ui.App.Draw()
|
||||
App.Draw()
|
||||
}
|
||||
time.Sleep(n.timer)
|
||||
Ui.Root.Root.RemovePage(currentTime)
|
||||
root.Root.RemovePage(currentTime)
|
||||
posArr.Free(npos)
|
||||
Ui.App.SetFocus(Ui.Main.Table)
|
||||
Ui.App.Draw()
|
||||
App.SetFocus(Main.Table)
|
||||
App.Draw()
|
||||
}()
|
||||
}
|
||||
|
||||
|
||||
@@ -11,8 +11,8 @@ import (
|
||||
|
||||
"github.com/aditya-K2/gspt/config"
|
||||
"github.com/aditya-K2/gspt/spt"
|
||||
"github.com/aditya-K2/utils"
|
||||
"github.com/aditya-K2/tview"
|
||||
"github.com/aditya-K2/utils"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -89,7 +89,7 @@ func RefreshProgress(force bool) {
|
||||
stateLock.Lock()
|
||||
state = s
|
||||
stateLock.Unlock()
|
||||
if Ui != nil && Ui.CoverArt != nil {
|
||||
if coverArt != nil {
|
||||
// If No Item is playing
|
||||
if (state.Item == nil) ||
|
||||
// An Item is Playing but doesn't match the cached Track ID
|
||||
@@ -100,7 +100,7 @@ func RefreshProgress(force bool) {
|
||||
ctrackId = state.Item.ID
|
||||
}
|
||||
if !config.Config.HideImage {
|
||||
Ui.CoverArt.RefreshState()
|
||||
coverArt.RefreshState()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,14 +22,14 @@ func NewSearchBar() *tview.InputField {
|
||||
switch k {
|
||||
case tcell.KeyEscape:
|
||||
{
|
||||
Ui.App.SetFocus(Ui.Main.Table)
|
||||
App.SetFocus(Main.Table)
|
||||
T.SetText("")
|
||||
}
|
||||
case tcell.KeyEnter:
|
||||
{
|
||||
searchView.SetSearch(T.GetText())
|
||||
SetCurrentView(searchView)
|
||||
Ui.App.SetFocus(Ui.Main.Table)
|
||||
App.SetFocus(Main.Table)
|
||||
T.SetText("")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -88,7 +88,7 @@ func (a *AlbumView) ContextHandler() func(start, end, sel int) {
|
||||
}
|
||||
|
||||
func (a *AlbumView) PlaySelectEntry() {
|
||||
r, _ := Ui.Main.Table.GetSelection()
|
||||
r, _ := Main.Table.GetSelection()
|
||||
if err := spt.PlaySongWithContext(&a.currentFullAlbum.URI, r); err != nil {
|
||||
SendNotification(err.Error())
|
||||
}
|
||||
|
||||
@@ -48,13 +48,13 @@ func (a *AlbumsView) Content() func() [][]Content {
|
||||
}
|
||||
|
||||
func (a *AlbumsView) OpenAlbum() {
|
||||
r, _ := Ui.Main.Table.GetSelection()
|
||||
r, _ := Main.Table.GetSelection()
|
||||
albumView.SetAlbum((*a.savedAlbums)[r].Name, &(*a.savedAlbums)[r].ID)
|
||||
SetCurrentView(albumView)
|
||||
}
|
||||
|
||||
func (a *AlbumsView) PlaySelectEntry() {
|
||||
r, _ := Ui.Main.Table.GetSelection()
|
||||
r, _ := Main.Table.GetSelection()
|
||||
if err := spt.PlayContext(&(*a.savedAlbums)[r].URI); err != nil {
|
||||
SendNotification(err.Error())
|
||||
}
|
||||
|
||||
@@ -67,7 +67,7 @@ func (a *ArtistView) Content() func() [][]Content {
|
||||
}
|
||||
|
||||
func (a *ArtistView) PlayEntry() {
|
||||
r, _ := Ui.Main.Table.GetSelection()
|
||||
r, _ := Main.Table.GetSelection()
|
||||
if r > 0 {
|
||||
if r < (len(a.albums) + 1) {
|
||||
if err := spt.PlayContext(&a.albums[r-1].URI); err != nil {
|
||||
@@ -78,7 +78,7 @@ func (a *ArtistView) PlayEntry() {
|
||||
}
|
||||
|
||||
func (a *ArtistView) OpenEntry() {
|
||||
r, _ := Ui.Main.Table.GetSelection()
|
||||
r, _ := Main.Table.GetSelection()
|
||||
if r > 0 {
|
||||
if r < (len(a.albums) + 1) {
|
||||
albumView.SetAlbum(a.albums[r-1].Name, &a.albums[r-1].ID)
|
||||
|
||||
@@ -47,7 +47,7 @@ func (a *ArtistsView) Content() func() [][]Content {
|
||||
}
|
||||
|
||||
func (a *ArtistsView) OpenArtist() {
|
||||
r, _ := Ui.Main.Table.GetSelection()
|
||||
r, _ := Main.Table.GetSelection()
|
||||
artistView.SetArtist(&(*a.followedArtists)[r].ID)
|
||||
artistView.RefreshState()
|
||||
SetCurrentView(artistView)
|
||||
|
||||
@@ -75,7 +75,7 @@ func (l *LikedSongsView) ContextHandler() func(start, end, sel int) {
|
||||
}
|
||||
|
||||
func (l *LikedSongsView) OpenEntry() {
|
||||
r, _ := Ui.Main.Table.GetSelection()
|
||||
r, _ := Main.Table.GetSelection()
|
||||
if err := spt.PlaySong((*l.likedSongs)[r].URI); err != nil {
|
||||
SendNotification(err.Error())
|
||||
}
|
||||
|
||||
@@ -86,7 +86,7 @@ func (p *PlaylistView) ContextHandler() func(start, end, sel int) {
|
||||
}
|
||||
|
||||
func (p *PlaylistView) PlaySelectEntry() {
|
||||
r, _ := Ui.Main.Table.GetSelection()
|
||||
r, _ := Main.Table.GetSelection()
|
||||
if err := spt.PlaySongWithContext(&p.currentPlaylist.URI, r); err != nil {
|
||||
SendNotification(err.Error())
|
||||
}
|
||||
|
||||
@@ -84,7 +84,7 @@ func (r *RecentlyPlayedView) RefreshState() {
|
||||
}
|
||||
|
||||
func (re *RecentlyPlayedView) SelectEntry(e *tcell.EventKey) *tcell.EventKey {
|
||||
r, _ := Ui.Main.Table.GetSelection()
|
||||
r, _ := Main.Table.GetSelection()
|
||||
contextUri := re.recentlyPlayed[r].PlaybackContext.URI
|
||||
if string(contextUri) != "" {
|
||||
if err := spt.PlaySongWithContextURI(&re.recentlyPlayed[r].PlaybackContext.URI, &re.recentlyPlayed[r].Track.URI); err != nil {
|
||||
|
||||
@@ -102,7 +102,7 @@ func (a *SearchView) Content() func() [][]Content {
|
||||
}
|
||||
|
||||
func (a *SearchView) SelectEntry() {
|
||||
r, _ := Ui.Main.Table.GetSelection()
|
||||
r, _ := Main.Table.GetSelection()
|
||||
switch a.searchContent[r].Type {
|
||||
case "track":
|
||||
{
|
||||
|
||||
@@ -70,7 +70,7 @@ func (a *TopTracksView) Content() func() [][]Content {
|
||||
}
|
||||
|
||||
func (a *TopTracksView) PlaySelectedEntry() {
|
||||
r, _ := Ui.Main.Table.GetSelection()
|
||||
r, _ := Main.Table.GetSelection()
|
||||
if r > 0 {
|
||||
if r < (len(a.topArtists) + 1) {
|
||||
if err := spt.PlayContext(&a.topArtists[r-1].URI); err != nil {
|
||||
@@ -82,7 +82,7 @@ func (a *TopTracksView) PlaySelectedEntry() {
|
||||
}
|
||||
|
||||
func (a *TopTracksView) OpenSelectEntry() {
|
||||
r, _ := Ui.Main.Table.GetSelection()
|
||||
r, _ := Main.Table.GetSelection()
|
||||
if r > 0 {
|
||||
if r < (len(a.topArtists) + 1) {
|
||||
artistView.SetArtist(&(a.topArtists)[r-1].ID)
|
||||
|
||||
Reference in New Issue
Block a user