diff options
author | Christian Pointner <equinox@helsinki.at> | 2016-02-26 19:46:26 (GMT) |
---|---|---|
committer | Christian Pointner <equinox@helsinki.at> | 2016-02-26 19:46:26 (GMT) |
commit | 644bba7bb779bcf789478847669dca450ea84ca6 (patch) | |
tree | 5e603a761d70be8f3b88eb0238072723192624b0 /src | |
parent | 035bce81f5b8ef689ca664a2b1c0d76117f92c2e (diff) |
selection for pool cart works now
Diffstat (limited to 'src')
-rw-r--r-- | src/rhlibrary/pool_selector_widget.go | 35 |
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 { |