summaryrefslogtreecommitdiff
path: root/src/rhlibrary
diff options
context:
space:
mode:
Diffstat (limited to 'src/rhlibrary')
-rw-r--r--src/rhlibrary/show_selector_widget.go70
1 files changed, 51 insertions, 19 deletions
diff --git a/src/rhlibrary/show_selector_widget.go b/src/rhlibrary/show_selector_widget.go
index 3b9d464..da121bd 100644
--- a/src/rhlibrary/show_selector_widget.go
+++ b/src/rhlibrary/show_selector_widget.go
@@ -25,26 +25,66 @@
package main
import (
+ "strconv"
+
"code.helsinki.at/rhrd-go/player"
"code.helsinki.at/rhrd-go/rddb"
"github.com/gotk3/gotk3/gtk"
)
-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 err
+// }
+
+// for _, cart := range carts {
+// rhdl.Printf(" [%d]: %s\n", cart.Number, cart.Title)
+// for _, cut := range cart.Cuts {
+// rhdl.Printf(" %+v", cut)
+// }
+// }
+
+// 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)
+
+// return nil
+// }
+
+func addShowComboBox(grid *gtk.Grid, db *rddb.DBChan) (err error) {
+ var label *gtk.Label
+ if label, err = gtk.LabelNew("Sendung auswählen"); err != nil {
+ return
+ }
+ grid.Attach(label, 1, 1, 1, 1)
+
+ var box *gtk.ComboBoxText
+ if box, err = gtk.ComboBoxTextNew(); err != nil {
+ return
+ }
- carts, err := db.GetShowCartList(show)
+ shows, err := db.GetShowList(rhuser.Username)
if err != nil {
+ rhdl.Println(err) // TODO: feedback at GUI?
return err
}
- for _, cart := range carts {
- rhdl.Printf(" [%d]: %s\n", cart.Number, cart.Title)
- for _, cut := range cart.Cuts {
- rhdl.Printf(" %+v", cut)
- }
+ for _, show := range shows {
+ box.Append(strconv.FormatUint(uint64(show.ID), 10), show.Title)
}
- return nil
+ box.SetActive(0)
+
+ box.Connect("changed", func(_ *gtk.ComboBoxText) {
+ idx, err := strconv.ParseUint(box.GetActiveID(), 10, 32)
+ if err != nil {
+ rhdl.Printf("invalid show-id in combo box: %v", err)
+ return
+ }
+
+ rhdl.Printf("show %d is now selected", idx)
+ })
+
+ grid.Attach(box, 2, 1, 1, 1)
+ return
}
func getShowsSelectorWidget(db *rddb.DBChan, p *player.PlayerChan) (gtk.IWidget, error) {
@@ -55,16 +95,8 @@ func getShowsSelectorWidget(db *rddb.DBChan, p *player.PlayerChan) (gtk.IWidget,
grid.SetHExpand(true)
grid.SetVExpand(true)
- shows, err := db.GetShowList(rhuser.Username)
- if err != nil {
- rhdl.Println(err) // TODO: feedback at GUI?
- return grid, nil
- }
-
- for _, show := range shows {
- if err = appendShowListEntry(grid, show, db, p); err != nil {
- return nil, err
- }
+ if err = addShowComboBox(grid, db); err != nil {
+ return nil, err
}
return grid, nil