diff options
author | Christian Pointner <equinox@helsinki.at> | 2016-02-26 18:54:40 (GMT) |
---|---|---|
committer | Christian Pointner <equinox@helsinki.at> | 2016-02-26 18:54:40 (GMT) |
commit | 035bce81f5b8ef689ca664a2b1c0d76117f92c2e (patch) | |
tree | 23891489b20d78885c8ade00cd48351a8826bf5a /src | |
parent | 0a5d62208b7e8e58010d8e8ada95927579cc1ff1 (diff) |
add missing colums to pool cart list
Diffstat (limited to 'src')
-rw-r--r-- | src/rhlibrary/pool_selector_widget.go | 41 |
1 files changed, 37 insertions, 4 deletions
diff --git a/src/rhlibrary/pool_selector_widget.go b/src/rhlibrary/pool_selector_widget.go index 850a685..f4187f6 100644 --- a/src/rhlibrary/pool_selector_widget.go +++ b/src/rhlibrary/pool_selector_widget.go @@ -27,7 +27,9 @@ package main import ( "fmt" "sort" + "strconv" "sync" + "time" "code.helsinki.at/rhrd-go/player" "code.helsinki.at/rhrd-go/rddb" @@ -40,6 +42,10 @@ const ( POOLS_COL_ARTIST POOLS_COL_TITLE POOLS_COL_ALBUM + POOLS_COL_DURATION + POOLS_COL_IMPORTED + POOLS_COL_NUM_PLAYED + POOLS_COL_LAST_PLAYED ) var ( @@ -144,9 +150,22 @@ func updatePoolCartListRows(pool rddb.PoolListEntry, db *rddb.DBChan, p *player. PoolsCartListStore.Clear() for num, cart := range carts { iter := PoolsCartListStore.Append() + + duration := time.Unix(0, 0).UTC().Add(cart.Cuts[0].Duration).Format("15:04:05.0") + imported := "-" + if cart.Cuts[0].Imported.Valid { + imported = cart.Cuts[0].Imported.Time.Format("Mon 02.01.2006 15:04:05") + } + + numplayed := strconv.FormatUint(uint64(cart.Cuts[0].NumPlayed), 10) + lastplayed := "-" + if cart.Cuts[0].LastPlayed.Valid { + lastplayed = cart.Cuts[0].LastPlayed.Time.Format("Mon 02.01.2006 15:04:05") + } + err = PoolsCartListStore.Set(iter, - []int{POOLS_COL_CART, POOLS_COL_ARTIST, POOLS_COL_TITLE, POOLS_COL_ALBUM}, - []interface{}{fmt.Sprintf("%d", num), cart.Artist, cart.Title, cart.Album}) + []int{POOLS_COL_CART, POOLS_COL_ARTIST, POOLS_COL_TITLE, POOLS_COL_ALBUM, POOLS_COL_DURATION, POOLS_COL_IMPORTED, POOLS_COL_NUM_PLAYED, POOLS_COL_LAST_PLAYED}, + []interface{}{fmt.Sprintf("%d", num), cart.Artist, cart.Title, cart.Album, duration, imported, numplayed, lastplayed}) if err != nil { return } @@ -165,6 +184,7 @@ func appendPoolCartListColumn(tree *gtk.TreeView, title string, id int) (err err if col, err = gtk.TreeViewColumnNewWithAttribute(title, cell, "text", id); err != nil { return } + col.SetSortColumnID(id) tree.AppendColumn(col) return } @@ -179,13 +199,26 @@ func addPoolCartList(grid *gtk.Grid, db *rddb.DBChan, p *player.PlayerChan) (err appendPoolCartListColumn(tree, "Interpret", POOLS_COL_ARTIST) appendPoolCartListColumn(tree, "Titel", POOLS_COL_TITLE) appendPoolCartListColumn(tree, "Album", POOLS_COL_ALBUM) + appendPoolCartListColumn(tree, "Länge", POOLS_COL_DURATION) + appendPoolCartListColumn(tree, "importiert", POOLS_COL_IMPORTED) + appendPoolCartListColumn(tree, "# gespielt", POOLS_COL_NUM_PLAYED) + appendPoolCartListColumn(tree, "zuletzt gespielt", POOLS_COL_LAST_PLAYED) - if PoolsCartListStore, err = gtk.ListStoreNew(glib.TYPE_STRING, glib.TYPE_STRING, glib.TYPE_STRING, glib.TYPE_STRING); err != nil { + if PoolsCartListStore, err = gtk.ListStoreNew(glib.TYPE_STRING, glib.TYPE_STRING, glib.TYPE_STRING, glib.TYPE_STRING, + glib.TYPE_STRING, glib.TYPE_STRING, glib.TYPE_STRING, glib.TYPE_STRING); err != nil { return } tree.SetModel(PoolsCartListStore) - grid.Attach(tree, 1, 2, 1, 1) + var sw *gtk.ScrolledWindow + if sw, err = gtk.ScrolledWindowNew(nil, nil); err != nil { + return + } + sw.SetHExpand(true) + sw.SetVExpand(true) + sw.Add(tree) + + grid.Attach(sw, 1, 2, 1, 1) return } |