From 28a85e445066a379cd6ec82b936e727f0508be70 Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Fri, 15 Jan 2016 02:36:13 +0100 Subject: fixed name of new file diff --git a/src/rhlibrary/payer_widget.go b/src/rhlibrary/payer_widget.go deleted file mode 100644 index 8e2d7e3..0000000 --- a/src/rhlibrary/payer_widget.go +++ /dev/null @@ -1,95 +0,0 @@ -// -// rhlibrary -// -// The Radio Helsinki Rivendell Library -// -// -// Copyright (C) 2016 Christian Pointner -// -// 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 . -// - -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 -} diff --git a/src/rhlibrary/player_widget.go b/src/rhlibrary/player_widget.go new file mode 100644 index 0000000..8e2d7e3 --- /dev/null +++ b/src/rhlibrary/player_widget.go @@ -0,0 +1,95 @@ +// +// rhlibrary +// +// The Radio Helsinki Rivendell Library +// +// +// Copyright (C) 2016 Christian Pointner +// +// 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 . +// + +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 +} -- cgit v0.10.2