summaryrefslogtreecommitdiff
path: root/src/rhlibrary
diff options
context:
space:
mode:
authorChristian Pointner <equinox@helsinki.at>2016-02-06 01:13:03 (GMT)
committerChristian Pointner <equinox@helsinki.at>2016-02-06 01:13:03 (GMT)
commitfbaf462b3d974c3ca4046d4df84fd512b2409259 (patch)
tree86ae70efd9001a3ee7e3cb8be9d70ce8bbb16914 /src/rhlibrary
parent5fdd4110cc0bbeefc1b5fcb334a271c2c801f195 (diff)
added GtkListBox for show carts
Diffstat (limited to 'src/rhlibrary')
-rw-r--r--src/rhlibrary/show_selector_widget.go107
1 files changed, 76 insertions, 31 deletions
diff --git a/src/rhlibrary/show_selector_widget.go b/src/rhlibrary/show_selector_widget.go
index 5b3bcab..b32ac6a 100644
--- a/src/rhlibrary/show_selector_widget.go
+++ b/src/rhlibrary/show_selector_widget.go
@@ -25,6 +25,7 @@
package main
import (
+ "fmt"
"sort"
"strconv"
"sync"
@@ -41,24 +42,6 @@ var (
showsCurrentID uint
)
-// 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 fetchShows(db *rddb.DBChan) (err error) {
showsMutex.Lock()
defer showsMutex.Unlock()
@@ -132,27 +115,65 @@ func addShowComboBox(grid *gtk.Grid, db *rddb.DBChan) (err error) {
box.PackStart(showsComboBox, true, true, 0)
box.SetHExpand(true)
- var frame *gtk.Frame
- if frame, err = gtk.FrameNew(""); err != nil {
- return
+ grid.Attach(box, 1, 1, 1, 1)
+ return
+}
+
+// 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 addShowListRows(box *gtk.ListBox, db *rddb.DBChan, p *player.PlayerChan) (err error) {
+ for i := 0; i < 25; i++ {
+ var row *gtk.ListBoxRow
+ if row, err = gtk.ListBoxRowNew(); err != nil {
+ return
+ }
+
+ var label *gtk.Label
+ if label, err = gtk.LabelNew(fmt.Sprintf("Row %d", i)); err != nil {
+ return
+ }
+ row.Add(label)
+ box.Add(row)
}
+ return
+}
- var cp *gtk.CssProvider
- if cp, err = gtk.CssProviderNew(); err != nil {
+func addShowListBox(grid *gtk.Grid, db *rddb.DBChan, p *player.PlayerChan) (err error) {
+ var box *gtk.ListBox
+ if box, err = gtk.ListBoxNew(); err != nil {
return
}
- if err = cp.LoadFromData(".frame { border: 0; padding: 25px 42px; }"); err != nil {
+ box.SetSelectionMode(gtk.SELECTION_NONE)
+
+ if err = addShowListRows(box, db, p); err != nil {
return
}
- var sc *gtk.StyleContext
- if sc, err = frame.GetStyleContext(); err != nil {
+
+ var sw *gtk.ScrolledWindow
+ if sw, err = gtk.ScrolledWindowNew(nil, nil); err != nil {
return
}
- sc.AddProvider(cp, 600) // TOOD: hardcoded value
+ sw.SetHExpand(true)
+ sw.SetVExpand(true)
+ sw.Add(box)
- frame.Add(box)
-
- grid.Attach(frame, 1, 1, 1, 1)
+ grid.Attach(sw, 1, 2, 1, 1)
return
}
@@ -161,12 +182,36 @@ func getShowsSelectorWidget(db *rddb.DBChan, p *player.PlayerChan) (gtk.IWidget,
if err != nil {
return nil, err
}
+ grid.SetRowSpacing(25)
grid.SetHExpand(true)
grid.SetVExpand(true)
if err = addShowComboBox(grid, db); err != nil {
return nil, err
}
+ if err = addShowListBox(grid, db, p); err != nil {
+ return nil, err
+ }
+
+ var frame *gtk.Frame
+ if frame, err = gtk.FrameNew(""); err != nil {
+ return nil, err
+ }
+
+ var cp *gtk.CssProvider
+ if cp, err = gtk.CssProviderNew(); err != nil {
+ return nil, err
+ }
+ if err = cp.LoadFromData(".frame { border: 0; padding: 25px 42px; }"); err != nil {
+ return nil, err
+ }
+ var sc *gtk.StyleContext
+ if sc, err = frame.GetStyleContext(); err != nil {
+ return nil, err
+ }
+ sc.AddProvider(cp, 600) // TOOD: hardcoded value
+
+ frame.Add(grid)
- return grid, nil
+ return frame, nil
}