diff options
author | Christian Pointner <equinox@helsinki.at> | 2016-02-03 16:08:29 (GMT) |
---|---|---|
committer | Christian Pointner <equinox@helsinki.at> | 2016-02-03 16:08:29 (GMT) |
commit | 784a184c3f292f9c84138dba180e4b30bca341a3 (patch) | |
tree | da4b8c6707a5e5b024b3e88a53f3ccd9394f541e /src/rhlibrary | |
parent | 283a0cd6d86fa4a8b9d3fd4c2098de8249360493 (diff) |
small refactoring
Diffstat (limited to 'src/rhlibrary')
-rw-r--r-- | src/rhlibrary/selector_widget.go | 30 |
1 files changed, 12 insertions, 18 deletions
diff --git a/src/rhlibrary/selector_widget.go b/src/rhlibrary/selector_widget.go index f4dc278..405171c 100644 --- a/src/rhlibrary/selector_widget.go +++ b/src/rhlibrary/selector_widget.go @@ -88,7 +88,14 @@ func getManualSelectorWidget(db *rddb.DBChan, p *player.PlayerChan) (gtk.IWidget return grid, nil } -func addSelectorPage(nb *gtk.Notebook, page gtk.IWidget, title string) (err error) { +type getSelectorFunc func(*rddb.DBChan, *player.PlayerChan) (gtk.IWidget, error) + +func addSelectorPage(nb *gtk.Notebook, title string, getWidget getSelectorFunc, db *rddb.DBChan, p *player.PlayerChan) (err error) { + var page gtk.IWidget + if page, err = getWidget(db, p); err != nil { + return + } + var label *gtk.Label if label, err = gtk.LabelNew(title); err != nil { return @@ -104,32 +111,19 @@ func getSelectorWidget(db *rddb.DBChan, p *player.PlayerChan) (gtk.IWidget, erro return nil, err } - var page gtk.IWidget - if page, err = getShowsSelectorWidget(db, p); err != nil { - return nil, err - } - if err = addSelectorPage(nb, page, "Sendungen"); err != nil { + if err = addSelectorPage(nb, "Sendungen", getShowsSelectorWidget, db, p); err != nil { return nil, err } - if page, err = getJinglesSelectorWidget(db, p); err != nil { - return nil, err - } - if err = addSelectorPage(nb, page, "Jingles"); err != nil { + if err = addSelectorPage(nb, "Jingles", getJinglesSelectorWidget, db, p); err != nil { return nil, err } - if page, err = getPoolsSelectorWidget(db, p); err != nil { - return nil, err - } - if err = addSelectorPage(nb, page, "Musikpools"); err != nil { + if err = addSelectorPage(nb, "Musikpools", getPoolsSelectorWidget, db, p); err != nil { return nil, err } - if page, err = getManualSelectorWidget(db, p); err != nil { - return nil, err - } - if err = addSelectorPage(nb, page, "manual"); err != nil { + if err = addSelectorPage(nb, "Manuell", getManualSelectorWidget, db, p); err != nil { return nil, err } |