aboutsummaryrefslogtreecommitdiff
path: root/src/app.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/app.go')
-rw-r--r--src/app.go24
1 files changed, 21 insertions, 3 deletions
diff --git a/src/app.go b/src/app.go
index c18c1f5..58fc0db 100644
--- a/src/app.go
+++ b/src/app.go
@@ -9,12 +9,18 @@ import (
9) 9)
10 10
11type app struct { 11type app struct {
12 // General GUI
12 tv *tview.Application 13 tv *tview.Application
13 pages *tview.Pages 14 pages *tview.Pages
14 header *tview.TextView 15 header *tview.TextView
15 footer *tview.TextView 16 footer *tview.TextView
16 cfg *Config 17 cfg *Config
17 18
19 // Artists panel
20 artistsTree *tview.TreeView
21 songsList *tview.List
22
23 // Subsonic variables
18 sub *subsonic.Client 24 sub *subsonic.Client
19} 25}
20 26
@@ -42,16 +48,28 @@ func Run(cfg *Config) {
42 }) 48 })
43 fmt.Fprintf(a.header, `["artists"]F1: Artists[""] | ["playlists"]F2: Playlists[""] | ["config"]F3: Configuration[""]`) 49 fmt.Fprintf(a.header, `["artists"]F1: Artists[""] | ["playlists"]F2: Playlists[""] | ["config"]F3: Configuration[""]`)
44 50
51 a.pages.SetBorder(true)
45 a.pages.AddPage("config", configPage(a), true, false) 52 a.pages.AddPage("config", configPage(a), true, false)
46 a.pages.AddPage("artists", artistsPage(a), true, false) 53 a.pages.AddPage("artists", artistsPage(a), true, false)
47 54
48 mainLayout := tview.NewFlex(). 55 mainLayout := tview.NewFlex().
49 SetDirection(tview.FlexRow). 56 SetDirection(tview.FlexRow).
50 AddItem(a.header, 0, 1, false). 57 AddItem(a.header, 1, 1, false).
51 AddItem(a.pages, 0, 3, true). 58 AddItem(a.pages, 0, 3, true).
52 AddItem(a.footer, 0, 1, false) 59 AddItem(a.footer, 1, 1, false)
60
61 if testConfig(a.cfg) != nil {
62 switchToPage(a, "config")
63 } else {
64 a.sub, _ = buildSubsonicClient(a.cfg)
65 err := refreshArtists(a)
66 if err != nil {
67 alert(a, "Could not refresh artists: %v", err)
68 } else {
69 switchToPage(a, "artists")
70 }
71 }
53 72
54 switchToPage(a, "config")
55 if err := a.tv.SetRoot(mainLayout, true).EnableMouse(true).SetFocus(mainLayout).Run(); err != nil { 73 if err := a.tv.SetRoot(mainLayout, true).EnableMouse(true).SetFocus(mainLayout).Run(); err != nil {
56 fmt.Printf("Error running termsonic: %v", err) 74 fmt.Printf("Error running termsonic: %v", err)
57 os.Exit(1) 75 os.Exit(1)