summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Pointner <equinox@helsinki.at>2016-02-11 14:26:29 (GMT)
committerChristian Pointner <equinox@helsinki.at>2016-02-11 14:26:29 (GMT)
commit54ef8a99328c6103d50b3925f706056c530b8279 (patch)
treedd4851affd933c964f1f2a92826efe5fe40170be /src
parenta21503b001d5f6ee0616b143b417a9c8e22340a8 (diff)
added scuffolding for jingle view
Diffstat (limited to 'src')
-rw-r--r--src/rhlibrary/jingle_selector_widget.go123
1 files changed, 121 insertions, 2 deletions
diff --git a/src/rhlibrary/jingle_selector_widget.go b/src/rhlibrary/jingle_selector_widget.go
index c29d21e..4d0015d 100644
--- a/src/rhlibrary/jingle_selector_widget.go
+++ b/src/rhlibrary/jingle_selector_widget.go
@@ -25,16 +25,135 @@
package main
import (
+ "sync"
+
"code.helsinki.at/rhrd-go/player"
"code.helsinki.at/rhrd-go/rddb"
"github.com/gotk3/gotk3/gtk"
)
+var (
+ jinglesMutex sync.Mutex
+ jingles map[string]string // TODO: how should this look like?
+ jinglesComboBox *gtk.ComboBoxText
+ jinglesCurrentGroup string
+ jinglesCutListBin *gtk.Bin
+ jinglesCutList *gtk.Grid
+)
+
+// func fetchJingles(db *rddb.DBChan) (err error) {
+// jinglesMutex.Lock()
+// defer jinglesMutex.Unlock()
+
+// if jingles, err = db.GetJingleList(rhuser.Username); err != nil {
+// return err
+// }
+// return
+// }
+
+// func updateJingles(db *rddb.DBChan) (err error) {
+// if err = fetchJingles(db); err != nil {
+// return
+// }
+
+// jinglesComboBox.RemoveAll()
+// for group, jingle := range jingles {
+// jinglesComboBox.Append(group, jingle.Description)
+// }
+
+// if !jinglesComboBox.SetActiveID(jinglesCurrentGroup) {
+// jinglesComboBox.SetActive(0)
+// }
+// return
+// }
+
+func addJingleComboBox(grid *gtk.Grid, db *rddb.DBChan, p *player.PlayerChan) (err error) {
+ var box *gtk.Box
+ if box, err = gtk.BoxNew(gtk.ORIENTATION_HORIZONTAL, 10); err != nil {
+ return
+ }
+
+ var label *gtk.Label
+ if label, err = gtk.LabelNew("Jingle Gruppe auswählen"); err != nil {
+ return
+ }
+ box.PackStart(label, false, false, 0)
+
+ if jinglesComboBox, err = gtk.ComboBoxTextNew(); err != nil {
+ return
+ }
+ // if err = updateJingles(db); err != nil {
+ // return err
+ // }
+ jinglesComboBox.Connect("changed", func(_ *gtk.ComboBoxText) {
+ // jingle := selectJingle()
+ // if jingle.ID == 0 {
+ // return
+ // }
+
+ // glib.IdleAdd(func() {
+ // if err = updateJingleCutListRows(jingle, db, p); err != nil {
+ // rhdl.Printf("error loading jingle cuts for %d", jingle.ID)
+ // return
+ // }
+ // })
+ // rhdl.Printf("jingle %d is now selected: %s", jingle.ID, jingle.Title)
+ })
+
+ box.PackStart(jinglesComboBox, true, true, 0)
+ box.SetHExpand(true)
+
+ grid.Attach(box, 1, 1, 1, 1)
+ return
+}
+
+func addJingleCutList(grid *gtk.Grid, db *rddb.DBChan, p *player.PlayerChan) (err error) {
+ var frame *gtk.Frame
+ if frame, err = gtk.FrameNew(""); err != nil {
+ return
+ }
+ jinglesCutListBin = &frame.Bin
+ if err = setCssStyle(&frame.Widget, ".frame { border: 0; }"); err != nil {
+ return
+ }
+
+ var sw *gtk.ScrolledWindow
+ if sw, err = gtk.ScrolledWindowNew(nil, nil); err != nil {
+ return
+ }
+ sw.SetHExpand(true)
+ sw.SetVExpand(true)
+ sw.Add(frame)
+
+ grid.Attach(sw, 1, 2, 1, 1)
+ return
+}
+
func getJinglesSelectorWidget(db *rddb.DBChan, p *player.PlayerChan) (gtk.IWidget, error) {
- page, err := gtk.LabelNew("JINGLES")
+ grid, err := gtk.GridNew()
if err != nil {
return nil, err
}
+ grid.SetRowSpacing(25)
+ grid.SetHExpand(true)
+ grid.SetVExpand(true)
+
+ if err = addJingleComboBox(grid, db, p); err != nil {
+ return nil, err
+ }
+ if err = addJingleCutList(grid, db, p); err != nil {
+ return nil, err
+ }
+
+ var frame *gtk.Frame
+ if frame, err = gtk.FrameNew(""); err != nil {
+ return nil, err
+ }
+ if err = setCssStyle(&frame.Widget, ".frame { border: 0; padding: 25px 42px; }"); err != nil {
+ return nil, err
+ }
+
+ frame.Add(grid)
- return page, nil
+ return frame, nil
}