summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Pointner <equinox@helsinki.at>2016-01-13 14:16:21 (GMT)
committerChristian Pointner <equinox@helsinki.at>2016-01-13 14:16:21 (GMT)
commitaacbbfa74a912a6ac11eb0400f358f5f1de23356 (patch)
treee32c4e2d6b7ace85ea43d707dae05fe82e86a6b1
parentb2398fd830443fa2930de0605d153b8a1264be95 (diff)
added simple main window
-rw-r--r--Makefile3
-rw-r--r--src/rhlibrary/main.go9
-rw-r--r--src/rhlibrary/mainwindow.go64
-rw-r--r--src/rhlibrary/player.go2
4 files changed, 74 insertions, 4 deletions
diff --git a/Makefile b/Makefile
index 8e4d72e..c784954 100644
--- a/Makefile
+++ b/Makefile
@@ -28,7 +28,8 @@ GOCMD := GOPATH=$(curdir) go
EXECUTEABLE := rhlibrary
LIBS := "code.helsinki.at/rhrd-go/rddb" \
- "github.com/ziutek/glib" \
+ "github.com/gotk3/gotk3/glib" \
+ "github.com/gotk3/gotk3/gtk" \
"github.com/revmischa/gst"
diff --git a/src/rhlibrary/main.go b/src/rhlibrary/main.go
index 85e5b8a..cbc5deb 100644
--- a/src/rhlibrary/main.go
+++ b/src/rhlibrary/main.go
@@ -84,13 +84,20 @@ func main() {
defer db.Cleanup()
player, _ := NewPlayer("/home/equinox/helsinki/rivenhell/contrib/rhlibrary/snd")
+ player.Play(1, 1)
+
+ mw, err := NewMainWindow()
+ if err != nil {
+ rhl.Println("Error initilizing Main Window:", err)
+ return
+ }
var wg sync.WaitGroup
wg.Add(1)
go func() {
defer wg.Done()
- player.Play(1, 1)
+ mw.ShowAndRun()
}()
alldone := make(chan bool)
diff --git a/src/rhlibrary/mainwindow.go b/src/rhlibrary/mainwindow.go
new file mode 100644
index 0000000..bfa0ac7
--- /dev/null
+++ b/src/rhlibrary/mainwindow.go
@@ -0,0 +1,64 @@
+//
+// 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 (
+ "github.com/gotk3/gotk3/gtk"
+)
+
+func init() {
+ gtk.Init(nil)
+}
+
+type MainWindow struct {
+ win *gtk.Window
+}
+
+func (mw *MainWindow) ShowAndRun() {
+ mw.win.ShowAll()
+ gtk.Main()
+}
+
+func NewMainWindow() (mw *MainWindow, err error) {
+ mw = &MainWindow{}
+ // Create a new toplevel window, set its title, and connect it to the
+ // "destroy" signal to exit the GTK main loop when it is destroyed.
+ if mw.win, err = gtk.WindowNew(gtk.WINDOW_TOPLEVEL); err != nil {
+ return
+ }
+ mw.win.SetTitle("rhlibrary")
+ mw.win.Connect("destroy", func() {
+ gtk.MainQuit()
+ })
+
+ var l *gtk.Label
+ if l, err = gtk.LabelNew("Hello, world!"); err != nil {
+ return
+ }
+ mw.win.Add(l)
+
+ mw.win.SetDefaultSize(800, 600)
+ return
+}
diff --git a/src/rhlibrary/player.go b/src/rhlibrary/player.go
index 3e4211c..98b7e35 100644
--- a/src/rhlibrary/player.go
+++ b/src/rhlibrary/player.go
@@ -27,7 +27,6 @@ package main
import (
"fmt"
"github.com/revmischa/gst"
- "github.com/ziutek/glib"
"path"
)
@@ -55,7 +54,6 @@ func (p *Player) Play(cart, cut uint) (err error) {
p.pipe.SetProperty("uri", "file://"+filename)
p.pipe.SetState(gst.STATE_PLAYING)
- glib.NewMainLoop(nil).Run()
return
}