summaryrefslogtreecommitdiff
path: root/src/rhlibrary
diff options
context:
space:
mode:
authorChristian Pointner <equinox@helsinki.at>2016-01-15 01:41:01 (GMT)
committerChristian Pointner <equinox@helsinki.at>2016-01-15 01:41:01 (GMT)
commitebdce0f75cc8a6c5aa38d8f0e3727b0e99a2b618 (patch)
tree111b7b8ff21be90377ffb58ed4b9068d962974f3 /src/rhlibrary
parent28a85e445066a379cd6ec82b936e727f0508be70 (diff)
moved selector widget to seperate file as well
Diffstat (limited to 'src/rhlibrary')
-rw-r--r--src/rhlibrary/app_window.go47
-rw-r--r--src/rhlibrary/player_widget.go1
-rw-r--r--src/rhlibrary/selector_widget.go77
3 files changed, 81 insertions, 44 deletions
diff --git a/src/rhlibrary/app_window.go b/src/rhlibrary/app_window.go
index d6131df..1062c5f 100644
--- a/src/rhlibrary/app_window.go
+++ b/src/rhlibrary/app_window.go
@@ -44,50 +44,11 @@ func (aw *AppWindow) ShowAndRun() {
}
func (aw *AppWindow) drawSelector(grid *gtk.Grid) (err error) {
- var selectorgrid *gtk.Grid
- if selectorgrid, err = gtk.GridNew(); err != nil {
- return
- }
- selectorgrid.SetColumnSpacing(3)
-
- var cartl, cutl *gtk.Label
- var cart, cut *gtk.SpinButton
-
- if cartl, err = gtk.LabelNew("Cart:"); err != nil {
- return
- }
- if cart, err = gtk.SpinButtonNewWithRange(1, 999999, 1); err != nil {
- return
- }
-
- if cutl, err = gtk.LabelNew("Cut:"); err != nil {
- return
- }
- if cut, err = gtk.SpinButtonNewWithRange(1, 999, 1); err != nil {
- return
- }
-
- var loadBtn *gtk.Button
- if loadBtn, err = gtk.ButtonNewWithLabel("LOAD"); err != nil {
- return
+ widget, err := getSelectorWidget(aw.player)
+ if err == nil {
+ grid.Add(widget)
}
- loadBtn.Connect("clicked", func(_ *gtk.Button) {
- if err := aw.player.Load((uint)(cart.GetValueAsInt()), (uint)(cut.GetValueAsInt())); err != nil {
- rhdl.Println(err)
- }
- })
-
- selectorgrid.Attach(cartl, 1, 1, 1, 1)
- selectorgrid.Attach(cart, 2, 1, 1, 1)
- selectorgrid.Attach(cutl, 1, 2, 1, 1)
- selectorgrid.Attach(cut, 2, 2, 1, 1)
- selectorgrid.Attach(loadBtn, 1, 3, 2, 1)
-
- selectorgrid.SetHExpand(true)
- selectorgrid.SetVExpand(true)
-
- grid.Add(selectorgrid)
- return
+ return err
}
func (aw *AppWindow) drawPlayer(grid *gtk.Grid) error {
diff --git a/src/rhlibrary/player_widget.go b/src/rhlibrary/player_widget.go
index 8e2d7e3..33fa88d 100644
--- a/src/rhlibrary/player_widget.go
+++ b/src/rhlibrary/player_widget.go
@@ -72,7 +72,6 @@ func addStopButton(grid *gtk.Grid, p *player.PlayerChan) (err error) {
}
func getPlayerWidget(p *player.PlayerChan) (gtk.IWidget, error) {
-
var grid *gtk.Grid
grid, err := gtk.GridNew()
if err != nil {
diff --git a/src/rhlibrary/selector_widget.go b/src/rhlibrary/selector_widget.go
new file mode 100644
index 0000000..939551a
--- /dev/null
+++ b/src/rhlibrary/selector_widget.go
@@ -0,0 +1,77 @@
+//
+// rhlibrary
+//
+// The Radio Helsinki Rivendell Library
+//
+//
+// Copyright (C) 2016 Christian Pointner <equinox@helsinki.at>
+//
+// This file is part of rhlibrary.
+//
+// rhlibrary is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// any later version.
+//
+// rhlibrary is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with rhlibrary. If not, see <http://www.gnu.org/licenses/>.
+//
+
+package main
+
+import (
+ "code.helsinki.at/rhrd-go/player"
+ "github.com/gotk3/gotk3/gtk"
+)
+
+func getSelectorWidget(p *player.PlayerChan) (gtk.IWidget, error) {
+ var grid *gtk.Grid
+ grid, err := gtk.GridNew()
+ if err != nil {
+ return nil, err
+ }
+ grid.SetColumnSpacing(3)
+
+ var cartl, cutl *gtk.Label
+ var cart, cut *gtk.SpinButton
+
+ if cartl, err = gtk.LabelNew("Cart:"); err != nil {
+ return nil, err
+ }
+ if cart, err = gtk.SpinButtonNewWithRange(1, 999999, 1); err != nil {
+ return nil, err
+ }
+
+ if cutl, err = gtk.LabelNew("Cut:"); err != nil {
+ return nil, err
+ }
+ if cut, err = gtk.SpinButtonNewWithRange(1, 999, 1); err != nil {
+ return nil, err
+ }
+
+ var loadBtn *gtk.Button
+ if loadBtn, err = gtk.ButtonNewWithLabel("LOAD"); err != nil {
+ return nil, err
+ }
+ loadBtn.Connect("clicked", func(_ *gtk.Button) {
+ if err := p.Load((uint)(cart.GetValueAsInt()), (uint)(cut.GetValueAsInt())); err != nil {
+ rhdl.Println(err) // TODO: feedback at GUI?
+ }
+ })
+
+ grid.Attach(cartl, 1, 1, 1, 1)
+ grid.Attach(cart, 2, 1, 1, 1)
+ grid.Attach(cutl, 1, 2, 1, 1)
+ grid.Attach(cut, 2, 2, 1, 1)
+ grid.Attach(loadBtn, 1, 3, 2, 1)
+
+ grid.SetHExpand(true)
+ grid.SetVExpand(true)
+
+ return grid, nil
+}