summaryrefslogtreecommitdiff
path: root/src/rhlibrary
diff options
context:
space:
mode:
Diffstat (limited to 'src/rhlibrary')
-rw-r--r--src/rhlibrary/pool_selector_widget.go35
1 files changed, 34 insertions, 1 deletions
diff --git a/src/rhlibrary/pool_selector_widget.go b/src/rhlibrary/pool_selector_widget.go
index f4187f6..4c90ea5 100644
--- a/src/rhlibrary/pool_selector_widget.go
+++ b/src/rhlibrary/pool_selector_widget.go
@@ -185,6 +185,7 @@ func appendPoolCartListColumn(tree *gtk.TreeView, title string, id int) (err err
return
}
col.SetSortColumnID(id)
+ col.SetExpand(true)
tree.AppendColumn(col)
return
}
@@ -195,7 +196,7 @@ func addPoolCartList(grid *gtk.Grid, db *rddb.DBChan, p *player.PlayerChan) (err
return
}
- appendPoolCartListColumn(tree, "#Cart", POOLS_COL_CART)
+ appendPoolCartListColumn(tree, "Cart #", POOLS_COL_CART)
appendPoolCartListColumn(tree, "Interpret", POOLS_COL_ARTIST)
appendPoolCartListColumn(tree, "Titel", POOLS_COL_TITLE)
appendPoolCartListColumn(tree, "Album", POOLS_COL_ALBUM)
@@ -209,6 +210,38 @@ func addPoolCartList(grid *gtk.Grid, db *rddb.DBChan, p *player.PlayerChan) (err
return
}
tree.SetModel(PoolsCartListStore)
+ tree.Connect("row-activated", func(_ *gtk.TreeView, path *gtk.TreePath, _ *gtk.TreeViewColumn) {
+ iter, err := PoolsCartListStore.GetIter(path)
+ if err != nil {
+ rhdl.Printf("unable to get iter for path %v: %v", path, err)
+ }
+ val, err := PoolsCartListStore.GetValue(iter, 0)
+
+ cart, err := val.GoValue()
+ if err != nil {
+ rhdl.Printf("unable to get go value for cart column: %v", err)
+ return
+ }
+
+ cartStr, ok := cart.(string)
+ if !ok {
+ rhdl.Printf("list-store cart is not a string")
+ return
+ }
+
+ cart64, err := strconv.ParseUint(cartStr, 10, 32)
+ if err != nil {
+ rhdl.Printf("invalid cart in tree view: %v", err)
+ return
+ }
+ if err := p.Load(uint(cart64), 1); err != nil {
+ rhdl.Println(err) // TODO: feedback at GUI?
+ return
+ }
+ if err := p.Play(); err != nil {
+ rhdl.Println(err) // TODO: feedback at GUI?
+ }
+ })
var sw *gtk.ScrolledWindow
if sw, err = gtk.ScrolledWindowNew(nil, nil); err != nil {