diff options
author | Christian Pointner <equinox@helsinki.at> | 2016-12-17 02:36:06 (GMT) |
---|---|---|
committer | Christian Pointner <equinox@helsinki.at> | 2016-12-17 02:36:06 (GMT) |
commit | 120f3dd271e5fb8028690b32d435e344896742e1 (patch) | |
tree | b607e6eb54049c7473f97a980c574f9ef2a26557 /src | |
parent | 30d026532b1b19534fff94b6dfd1ab5be76d6047 (diff) |
improved show, pool and jingle listings
Diffstat (limited to 'src')
-rw-r--r-- | src/rhlibrary/jingle_selector_widget.go | 21 | ||||
-rw-r--r-- | src/rhlibrary/pool_selector_widget.go | 21 | ||||
-rw-r--r-- | src/rhlibrary/show_selector_widget.go | 20 |
3 files changed, 33 insertions, 29 deletions
diff --git a/src/rhlibrary/jingle_selector_widget.go b/src/rhlibrary/jingle_selector_widget.go index 60f8cbd..fa8bdbf 100644 --- a/src/rhlibrary/jingle_selector_widget.go +++ b/src/rhlibrary/jingle_selector_widget.go @@ -52,6 +52,7 @@ func fetchJingles(db *rddb.DB) (err error) { if jingles, err = db.GetJingleList(rhuser.Username); err != nil { return err } + sort.Sort(jingles) return } @@ -60,15 +61,10 @@ func updateJingles(db *rddb.DB) (err error) { return } - var keys []string - for k, _ := range jingles { - keys = append(keys, k) - } - sort.Strings(keys) - jinglesComboBox.RemoveAll() - for _, group := range keys { - jinglesComboBox.Append(group, jingles[group].Description) + for _, jingle := range jingles { + name := fmt.Sprintf(" %s", jingle.Title) + jinglesComboBox.Append(jingle.Group, name) } if !jinglesComboBox.SetActiveID(jinglesCurrentGroup) { @@ -87,7 +83,12 @@ func selectJingle() rddb.JingleListEntry { jinglesMutex.Lock() defer jinglesMutex.Unlock() - return jingles[jinglesCurrentGroup] + for _, jingle := range jingles { + if jingle.Group == jinglesCurrentGroup { + return jingle + } + } + return rddb.JingleListEntry{} } func addJingleComboBox(grid *gtk.Grid, db *rddb.DB, p *player.Player) (err error) { @@ -120,7 +121,7 @@ func addJingleComboBox(grid *gtk.Grid, db *rddb.DB, p *player.Player) (err error return } }) - rhdl.Printf("jingle group %s is now selected: %s", jingle.Group, jingle.Description) + rhdl.Printf("jingle group %s is now selected: %s", jingle.Group, jingle.Title) }) box.PackStart(jinglesComboBox, true, true, 0) diff --git a/src/rhlibrary/pool_selector_widget.go b/src/rhlibrary/pool_selector_widget.go index d9475fe..9568d50 100644 --- a/src/rhlibrary/pool_selector_widget.go +++ b/src/rhlibrary/pool_selector_widget.go @@ -63,6 +63,7 @@ func fetchPools(db *rddb.DB) (err error) { if pools, err = db.GetPoolList(rhuser.Username); err != nil { return err } + sort.Sort(pools) return } @@ -71,15 +72,10 @@ func updatePools(db *rddb.DB) (err error) { return } - var keys []string - for k, _ := range pools { - keys = append(keys, k) - } - sort.Strings(keys) - poolsComboBox.RemoveAll() - for _, group := range keys { - poolsComboBox.Append(group, pools[group].Description) + for _, pool := range pools { + name := fmt.Sprintf(" %s | %s", pool.ShortName, pool.Title) + poolsComboBox.Append(pool.Group, name) } if !poolsComboBox.SetActiveID(poolsCurrentGroup) { @@ -98,7 +94,12 @@ func selectPool() rddb.PoolListEntry { poolsMutex.Lock() defer poolsMutex.Unlock() - return pools[poolsCurrentGroup] + for _, pool := range pools { + if pool.Group == poolsCurrentGroup { + return pool + } + } + return rddb.PoolListEntry{} } func addPoolComboBox(grid *gtk.Grid, db *rddb.DB, p *player.Player) (err error) { @@ -131,7 +132,7 @@ func addPoolComboBox(grid *gtk.Grid, db *rddb.DB, p *player.Player) (err error) return } }) - rhdl.Printf("pool %s is now selected: %s", pool.Group, pool.Description) + rhdl.Printf("pool %s is now selected: %s", pool.Group, pool.Title) }) box.PackStart(poolsComboBox, true, true, 0) diff --git a/src/rhlibrary/show_selector_widget.go b/src/rhlibrary/show_selector_widget.go index 55c255b..943413a 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" @@ -52,6 +53,7 @@ func fetchShows(db *rddb.DB) (err error) { if shows, err = db.GetShowList(rhuser.Username); err != nil { return err } + sort.Sort(shows) return } @@ -60,15 +62,10 @@ func updateShows(db *rddb.DB) (err error) { return } - var keys []int - for k, _ := range shows { - keys = append(keys, int(k)) - } - sort.Ints(keys) - showsComboBox.RemoveAll() - for _, showid := range keys { - showsComboBox.Append(strconv.FormatUint(uint64(showid), 10), shows[uint(showid)].Title) + for _, show := range shows { + name := fmt.Sprintf(" %d | %s (%s, %v, %s, %d Min.)", show.ID, show.TitleFull, show.Rhythm, show.Dow, show.StartTime, show.Length) + showsComboBox.Append(strconv.FormatUint(uint64(show.ID), 10), name) } if !showsComboBox.SetActiveID(strconv.FormatUint(uint64(showsCurrentID), 10)) { @@ -92,7 +89,12 @@ func selectShow() rddb.ShowListEntry { showsMutex.Lock() defer showsMutex.Unlock() - return shows[showsCurrentID] + for _, show := range shows { + if show.ID == showsCurrentID { + return show + } + } + return rddb.ShowListEntry{} } func addShowComboBox(grid *gtk.Grid, db *rddb.DB, p *player.Player) (err error) { |