diff options
author | Christian Pointner <equinox@helsinki.at> | 2016-01-15 01:34:25 (GMT) |
---|---|---|
committer | Christian Pointner <equinox@helsinki.at> | 2016-01-15 01:34:25 (GMT) |
commit | bea42956cfc714d7199c7cfcf93feb378abb10f8 (patch) | |
tree | 6afc7db467ad87d75ffeb283a5e453f7b7cf20f4 /src | |
parent | f822ebb0563902401024efcaa535d33603e2d1f6 (diff) |
refactored GUI creation code
Diffstat (limited to 'src')
-rw-r--r-- | src/rhlibrary/app_window.go | 48 |
1 files changed, 5 insertions, 43 deletions
diff --git a/src/rhlibrary/app_window.go b/src/rhlibrary/app_window.go index b28e950..d6131df 100644 --- a/src/rhlibrary/app_window.go +++ b/src/rhlibrary/app_window.go @@ -90,50 +90,12 @@ func (aw *AppWindow) drawSelector(grid *gtk.Grid) (err error) { return } -func (aw *AppWindow) drawPlayer(grid *gtk.Grid) (err error) { - var playergrid *gtk.Grid - if playergrid, err = gtk.GridNew(); err != nil { - return - } - playergrid.SetOrientation(gtk.ORIENTATION_HORIZONTAL) - playergrid.SetColumnSpacing(3) - - var playBtn *gtk.Button - if playBtn, err = gtk.ButtonNewFromIconName("media-playback-start", gtk.ICON_SIZE_DIALOG); err != nil { - return - } - playBtn.Connect("clicked", func(_ *gtk.Button) { - if err := aw.player.Play(); err != nil { - rhdl.Println(err) - } - }) - - var pauseBtn *gtk.Button - if pauseBtn, err = gtk.ButtonNewFromIconName("media-playback-pause", gtk.ICON_SIZE_DIALOG); err != nil { - return - } - pauseBtn.Connect("clicked", func(_ *gtk.Button) { - if err := aw.player.Pause(); err != nil { - rhdl.Println(err) - } - }) - - var stopBtn *gtk.Button - if stopBtn, err = gtk.ButtonNewFromIconName("media-playback-stop", gtk.ICON_SIZE_DIALOG); err != nil { - return +func (aw *AppWindow) drawPlayer(grid *gtk.Grid) error { + widget, err := getPlayerWidget(aw.player) + if err == nil { + grid.Add(widget) } - stopBtn.Connect("clicked", func(_ *gtk.Button) { - if err := aw.player.Stop(); err != nil { - rhdl.Println(err) - } - }) - - playergrid.Add(playBtn) - playergrid.Add(pauseBtn) - playergrid.Add(stopBtn) - - grid.Add(playergrid) - return + return err } func NewAppWindow(player *player.PlayerChan, width, height int) (aw *AppWindow, err error) { |