summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Pointner <equinox@helsinki.at>2016-01-29 18:22:19 (GMT)
committerChristian Pointner <equinox@helsinki.at>2016-01-29 18:22:19 (GMT)
commit2aa88ac7b233cf56a7c5a807152259b9193370af (patch)
treee88c6ef12f43f4828ef50c49a5802575bf1fac82 /src
parent5768d71b0fbba0650d35feeb0eea801644f3efb4 (diff)
added notebook for selector types
Diffstat (limited to 'src')
-rw-r--r--src/rhlibrary/app_window.go8
-rw-r--r--src/rhlibrary/main.go16
-rw-r--r--src/rhlibrary/selector_widget.go85
3 files changed, 95 insertions, 14 deletions
diff --git a/src/rhlibrary/app_window.go b/src/rhlibrary/app_window.go
index cf1a97a..cf8ef18 100644
--- a/src/rhlibrary/app_window.go
+++ b/src/rhlibrary/app_window.go
@@ -26,11 +26,13 @@ package main
import (
"code.helsinki.at/rhrd-go/player"
+ "code.helsinki.at/rhrd-go/rddb"
"github.com/gotk3/gotk3/gtk"
)
type AppWindow struct {
win *gtk.Window
+ db *rddb.DBChan
player *player.PlayerChan
}
@@ -41,7 +43,7 @@ func (aw *AppWindow) dispatchRequests() {
}
func (aw *AppWindow) drawSelector(grid *gtk.Grid) (err error) {
- widget, err := getSelectorWidget(aw.player)
+ widget, err := getSelectorWidget(aw.db, aw.player)
if err == nil {
grid.Add(widget)
}
@@ -64,8 +66,9 @@ func (aw *AppWindow) ShowAndRun() {
aw.win.ShowAll()
}
-func NewAppWindow(player *player.PlayerChan, width, height int) (aw *AppWindow, err error) {
+func NewAppWindow(db *rddb.DBChan, player *player.PlayerChan, width, height int) (aw *AppWindow, err error) {
aw = &AppWindow{}
+ aw.db = db
aw.player = player
if aw.win, err = gtk.WindowNew(gtk.WINDOW_TOPLEVEL); err != nil {
return
@@ -80,6 +83,7 @@ func NewAppWindow(player *player.PlayerChan, width, height int) (aw *AppWindow,
return
}
grid.SetOrientation(gtk.ORIENTATION_VERTICAL)
+ grid.SetRowSpacing(10)
if err = aw.drawPlayer(grid); err != nil {
return
diff --git a/src/rhlibrary/main.go b/src/rhlibrary/main.go
index 1f5fefd..b40ce9a 100644
--- a/src/rhlibrary/main.go
+++ b/src/rhlibrary/main.go
@@ -32,7 +32,7 @@ import (
"os"
"code.helsinki.at/rhrd-go/player"
- // "code.helsinki.at/rhrd-go/rddb"
+ "code.helsinki.at/rhrd-go/rddb"
"github.com/gotk3/gotk3/gtk"
)
@@ -79,12 +79,12 @@ func main() {
gtk.Init(nil)
- // db, err := rddb.NewDB(rdconf.Get().(string))
- // if err != nil {
- // rhl.Println("Error initializing Rivdenll DB:", err)
- // return
- // }
- // defer db.Cleanup()
+ db, err := rddb.NewDB(rdconf.Get().(string))
+ if err != nil {
+ rhl.Println("Error initializing Rivdenll DB:", err)
+ return
+ }
+ defer db.Cleanup()
p, err := player.NewPlayer("/home/equinox/helsinki/rivenhell/contrib/rhlibrary/snd", rhl, rhdl)
if err != nil {
@@ -92,7 +92,7 @@ func main() {
return
}
- mw, err := NewAppWindow(p.GetInterface(), 800, 600)
+ mw, err := NewAppWindow(db.GetInterface(), p.GetInterface(), 800, 600)
if err != nil {
rhl.Println("Error initializing Main Window:", err)
return
diff --git a/src/rhlibrary/selector_widget.go b/src/rhlibrary/selector_widget.go
index becf413..d0aab71 100644
--- a/src/rhlibrary/selector_widget.go
+++ b/src/rhlibrary/selector_widget.go
@@ -26,10 +26,11 @@ package main
import (
"code.helsinki.at/rhrd-go/player"
+ "code.helsinki.at/rhrd-go/rddb"
"github.com/gotk3/gotk3/gtk"
)
-func getSelectorWidget(p *player.PlayerChan) (gtk.IWidget, error) {
+func getManualSelector(p *player.PlayerChan) (gtk.IWidget, error) {
var grid *gtk.Grid
grid, err := gtk.GridNew()
if err != nil {
@@ -81,10 +82,86 @@ func getSelectorWidget(p *player.PlayerChan) (gtk.IWidget, error) {
grid.Attach(loadBtn, 1, 3, 2, 1)
grid.Attach(unloadBtn, 1, 4, 2, 1)
- grid.SetHExpand(true)
- grid.SetVExpand(true)
-
grid.SetHAlign(gtk.ALIGN_CENTER)
grid.SetVAlign(gtk.ALIGN_CENTER)
+
return grid, nil
}
+
+func getShowsSelector(p *player.PlayerChan) (gtk.IWidget, error) {
+ page, err := gtk.LabelNew("SHOWS")
+ if err != nil {
+ return nil, err
+ }
+
+ return page, nil
+}
+
+func getJinglesSelector(p *player.PlayerChan) (gtk.IWidget, error) {
+ page, err := gtk.LabelNew("JINGLES")
+ if err != nil {
+ return nil, err
+ }
+
+ return page, nil
+}
+
+func getPoolsSelector(p *player.PlayerChan) (gtk.IWidget, error) {
+ page, err := gtk.LabelNew("MUSIC POOLS")
+ if err != nil {
+ return nil, err
+ }
+
+ return page, nil
+}
+
+func addSelectorPage(nb *gtk.Notebook, page gtk.IWidget, title string) (err error) {
+ var label *gtk.Label
+ if label, err = gtk.LabelNew(title); err != nil {
+ return
+ }
+ label.SetSizeRequest(150, 15)
+ nb.AppendPage(page, label)
+ return
+}
+
+func getSelectorWidget(db *rddb.DBChan, p *player.PlayerChan) (gtk.IWidget, error) {
+ nb, err := gtk.NotebookNew()
+ if err != nil {
+ return nil, err
+ }
+
+ var page gtk.IWidget
+ if page, err = getShowsSelector(p); err != nil {
+ return nil, err
+ }
+ if err = addSelectorPage(nb, page, "Sendungen"); err != nil {
+ return nil, err
+ }
+
+ if page, err = getJinglesSelector(p); err != nil {
+ return nil, err
+ }
+ if err = addSelectorPage(nb, page, "Jingles"); err != nil {
+ return nil, err
+ }
+
+ if page, err = getPoolsSelector(p); err != nil {
+ return nil, err
+ }
+ if err = addSelectorPage(nb, page, "Musicpools"); err != nil {
+ return nil, err
+ }
+
+ if page, err = getManualSelector(p); err != nil {
+ return nil, err
+ }
+ if err = addSelectorPage(nb, page, "manual"); err != nil {
+ return nil, err
+ }
+
+ nb.SetHExpand(true)
+ nb.SetVExpand(true)
+
+ return nb, nil
+}