summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/rhlibrary/selector_widget.go65
1 files changed, 37 insertions, 28 deletions
diff --git a/src/rhlibrary/selector_widget.go b/src/rhlibrary/selector_widget.go
index 16bb762..f5b732e 100644
--- a/src/rhlibrary/selector_widget.go
+++ b/src/rhlibrary/selector_widget.go
@@ -30,7 +30,7 @@ import (
"github.com/gotk3/gotk3/gtk"
)
-func getManualSelector(db *rddb.DBChan, p *player.PlayerChan) (gtk.IWidget, error) {
+func getManualSelectorWidget(db *rddb.DBChan, p *player.PlayerChan) (gtk.IWidget, error) {
var grid *gtk.Grid
grid, err := gtk.GridNew()
if err != nil {
@@ -88,38 +88,47 @@ func getManualSelector(db *rddb.DBChan, p *player.PlayerChan) (gtk.IWidget, erro
return grid, nil
}
-func getShowsSelector(db *rddb.DBChan, p *player.PlayerChan) (gtk.IWidget, error) {
- page, err := gtk.BoxNew(gtk.ORIENTATION_VERTICAL, 0)
+func appendShowListEntry(grid *gtk.Grid, show rddb.ShowListEntry, db *rddb.DBChan, p *player.PlayerChan) error {
+ rhdl.Printf("Show: %d, %s\n", show.ID, show.Title)
+
+ carts, err := db.GetShowCartList(show)
if err != nil {
- return nil, err
+ return err
}
- var btn *gtk.Button
- if btn, err = gtk.ButtonNew(); err != nil {
+ for _, cart := range carts {
+ rhdl.Printf(" [%d]: %s\n", cart.Number, cart.Title)
+ for _, cut := range cart.Cuts {
+ rhdl.Printf(" %+v", cut)
+ }
+ }
+ return nil
+}
+
+func getShowsSelectorWidget(db *rddb.DBChan, p *player.PlayerChan) (gtk.IWidget, error) {
+ grid, err := gtk.GridNew()
+ if err != nil {
return nil, err
}
- btn.SetLabel("fetch show list")
+ grid.SetHExpand(true)
+ grid.SetVExpand(true)
- btn.Connect("clicked", func(_ *gtk.Button) {
- shows, err := db.GetShowList("equinox")
- if err != nil {
- rhdl.Println(err) // TODO: feedback at GUI?
- return
- }
- for _, show := range shows {
- rhdl.Printf("Show: %d, %s\n", show.ID, show.Title)
- for _, cart := range show.Carts {
- rhdl.Printf(" [%d]: %s (%s)\n", cart.Number, cart.Title, cart.Duration.String())
- }
- }
- })
+ shows, err := db.GetShowList("equinox") // TODO: get username from system
+ if err != nil {
+ rhdl.Println(err) // TODO: feedback at GUI?
+ return grid, nil
+ }
- page.PackStart(btn, false, false, 42)
+ for _, show := range shows {
+ if err = appendShowListEntry(grid, show, db, p); err != nil {
+ return nil, err
+ }
+ }
- return page, nil
+ return grid, nil
}
-func getJinglesSelector(db *rddb.DBChan, p *player.PlayerChan) (gtk.IWidget, error) {
+func getJinglesSelectorWidget(db *rddb.DBChan, p *player.PlayerChan) (gtk.IWidget, error) {
page, err := gtk.LabelNew("JINGLES")
if err != nil {
return nil, err
@@ -128,7 +137,7 @@ func getJinglesSelector(db *rddb.DBChan, p *player.PlayerChan) (gtk.IWidget, err
return page, nil
}
-func getPoolsSelector(db *rddb.DBChan, p *player.PlayerChan) (gtk.IWidget, error) {
+func getPoolsSelectorWidget(db *rddb.DBChan, p *player.PlayerChan) (gtk.IWidget, error) {
page, err := gtk.LabelNew("MUSIC POOLS")
if err != nil {
return nil, err
@@ -154,28 +163,28 @@ func getSelectorWidget(db *rddb.DBChan, p *player.PlayerChan) (gtk.IWidget, erro
}
var page gtk.IWidget
- if page, err = getShowsSelector(db, p); err != nil {
+ if page, err = getShowsSelectorWidget(db, p); err != nil {
return nil, err
}
if err = addSelectorPage(nb, page, "Sendungen"); err != nil {
return nil, err
}
- if page, err = getJinglesSelector(db, p); err != nil {
+ if page, err = getJinglesSelectorWidget(db, p); err != nil {
return nil, err
}
if err = addSelectorPage(nb, page, "Jingles"); err != nil {
return nil, err
}
- if page, err = getPoolsSelector(db, p); err != nil {
+ if page, err = getPoolsSelectorWidget(db, p); err != nil {
return nil, err
}
if err = addSelectorPage(nb, page, "Musikpools"); err != nil {
return nil, err
}
- if page, err = getManualSelector(db, p); err != nil {
+ if page, err = getManualSelectorWidget(db, p); err != nil {
return nil, err
}
if err = addSelectorPage(nb, page, "manual"); err != nil {