diff options
author | Christian Pointner <equinox@helsinki.at> | 2016-01-15 01:34:50 (GMT) |
---|---|---|
committer | Christian Pointner <equinox@helsinki.at> | 2016-01-15 01:34:50 (GMT) |
commit | 11418af287bf6724b2465da76c1a6e82a043d610 (patch) | |
tree | bc5eb6f9d44b5671261031ef1129dd9ae4fccca4 /src | |
parent | bea42956cfc714d7199c7cfcf93feb378abb10f8 (diff) |
added missing file...
Diffstat (limited to 'src')
-rw-r--r-- | src/rhlibrary/payer_widget.go | 95 |
1 files changed, 95 insertions, 0 deletions
diff --git a/src/rhlibrary/payer_widget.go b/src/rhlibrary/payer_widget.go new file mode 100644 index 0000000..8e2d7e3 --- /dev/null +++ b/src/rhlibrary/payer_widget.go @@ -0,0 +1,95 @@ +// +// 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 addPlayButton(grid *gtk.Grid, p *player.PlayerChan) (err error) { + var btn *gtk.Button + if btn, err = gtk.ButtonNewFromIconName("media-playback-start", gtk.ICON_SIZE_DIALOG); err != nil { + return + } + btn.Connect("clicked", func(_ *gtk.Button) { + if err := p.Play(); err != nil { + rhdl.Println(err) // TODO: feedback at GUI? + } + }) + grid.Add(btn) + return +} + +func addPauseButton(grid *gtk.Grid, p *player.PlayerChan) (err error) { + var btn *gtk.Button + if btn, err = gtk.ButtonNewFromIconName("media-playback-pause", gtk.ICON_SIZE_DIALOG); err != nil { + return + } + btn.Connect("clicked", func(_ *gtk.Button) { + if err := p.Pause(); err != nil { + rhdl.Println(err) // TODO: feedback at GUI? + } + }) + grid.Add(btn) + return +} + +func addStopButton(grid *gtk.Grid, p *player.PlayerChan) (err error) { + var btn *gtk.Button + if btn, err = gtk.ButtonNewFromIconName("media-playback-stop", gtk.ICON_SIZE_DIALOG); err != nil { + return + } + btn.Connect("clicked", func(_ *gtk.Button) { + if err := p.Stop(); err != nil { + rhdl.Println(err) // TODO: feedback at GUI? + } + }) + grid.Add(btn) + return +} + +func getPlayerWidget(p *player.PlayerChan) (gtk.IWidget, error) { + + var grid *gtk.Grid + grid, err := gtk.GridNew() + if err != nil { + return nil, err + } + grid.SetOrientation(gtk.ORIENTATION_HORIZONTAL) + grid.SetColumnSpacing(3) + + if err = addPlayButton(grid, p); err != nil { + return nil, err + } + if err = addPauseButton(grid, p); err != nil { + return nil, err + } + if err = addStopButton(grid, p); err != nil { + return nil, err + } + + return grid, nil +} |