diff options
author | Christian Pointner <equinox@helsinki.at> | 2016-02-04 17:08:19 (GMT) |
---|---|---|
committer | Christian Pointner <equinox@helsinki.at> | 2016-02-04 17:08:19 (GMT) |
commit | 5fdd4110cc0bbeefc1b5fcb334a271c2c801f195 (patch) | |
tree | 37ce385658db31b65b28b24c8f9012bde9df91bf /src/rhlibrary | |
parent | d569c9d62f1514e5c4144410841305b772ca8d5d (diff) |
fixed spacing for show selector combo box
Diffstat (limited to 'src/rhlibrary')
-rw-r--r-- | src/rhlibrary/player_widget.go | 98 | ||||
-rw-r--r-- | src/rhlibrary/show_selector_widget.go | 34 |
2 files changed, 79 insertions, 53 deletions
diff --git a/src/rhlibrary/player_widget.go b/src/rhlibrary/player_widget.go index fcaaeab..f990279 100644 --- a/src/rhlibrary/player_widget.go +++ b/src/rhlibrary/player_widget.go @@ -138,53 +138,6 @@ func addMeter(grid *gtk.Grid, p *player.PlayerChan) error { return nil } -func addScrubber(grid *gtk.Grid, p *player.PlayerChan) (err error) { - var scale *gtk.Scale - if scale, err = gtk.ScaleNew(gtk.ORIENTATION_HORIZONTAL, nil); err != nil { - return - } - if err = scale.SetProperty("draw-value", false); err != nil { - return - } - scale.SetRange(0, 1) - scale.SetValue(0) - - scale.Connect("change-value", func(s *gtk.Scale, _ interface{}, pos float64) { - if err := p.Seek(pos); err != nil { - rhdl.Println(err) // TODO: feedback at GUI? - } - }) - scale.SetSensitive(false) - - p.AddUpdateHandler(func(duration time.Duration, pos time.Duration, _ player.Meter, _ interface{}) bool { - glib.IdleAdd(func() { - if duration > 0 { - scale.SetValue(float64(pos) / float64(duration)) - } else { - scale.SetValue(0) - } - }) - return true - }, nil) - - p.AddStateChangeHandler(func(state player.State, _ interface{}) bool { - glib.IdleAdd(func() { - switch state { - case player.IDLE: - scale.SetSensitive(false) - case player.PAUSED: - scale.SetSensitive(true) - case player.PLAYING: - scale.SetSensitive(true) - } - }) - return true - }, nil) - - grid.Attach(scale, 1, 2, 3, 1) - return -} - func getPlayTimeString(duration, pos time.Duration, countdown bool) string { t := time.Unix(0, 0).UTC() if countdown { @@ -238,6 +191,53 @@ func addPlayTime(grid *gtk.Grid, p *player.PlayerChan) (err error) { return } +func addScrubber(grid *gtk.Grid, p *player.PlayerChan) (err error) { + var scale *gtk.Scale + if scale, err = gtk.ScaleNew(gtk.ORIENTATION_HORIZONTAL, nil); err != nil { + return + } + if err = scale.SetProperty("draw-value", false); err != nil { + return + } + scale.SetRange(0, 1) + scale.SetValue(0) + + scale.Connect("change-value", func(s *gtk.Scale, _ interface{}, pos float64) { + if err := p.Seek(pos); err != nil { + rhdl.Println(err) // TODO: feedback at GUI? + } + }) + scale.SetSensitive(false) + + p.AddUpdateHandler(func(duration time.Duration, pos time.Duration, _ player.Meter, _ interface{}) bool { + glib.IdleAdd(func() { + if duration > 0 { + scale.SetValue(float64(pos) / float64(duration)) + } else { + scale.SetValue(0) + } + }) + return true + }, nil) + + p.AddStateChangeHandler(func(state player.State, _ interface{}) bool { + glib.IdleAdd(func() { + switch state { + case player.IDLE: + scale.SetSensitive(false) + case player.PAUSED: + scale.SetSensitive(true) + case player.PLAYING: + scale.SetSensitive(true) + } + }) + return true + }, nil) + + grid.Attach(scale, 1, 2, 3, 1) + return +} + func getPlayerWidget(p *player.PlayerChan) (gtk.IWidget, error) { var err error var grid *gtk.Grid @@ -254,10 +254,10 @@ func getPlayerWidget(p *player.PlayerChan) (gtk.IWidget, error) { if err = addMeter(grid, p); err != nil { return nil, err } - if err = addScrubber(grid, p); err != nil { + if err = addPlayTime(grid, p); err != nil { return nil, err } - if err = addPlayTime(grid, p); err != nil { + if err = addScrubber(grid, p); err != nil { return nil, err } diff --git a/src/rhlibrary/show_selector_widget.go b/src/rhlibrary/show_selector_widget.go index ee49e57..5b3bcab 100644 --- a/src/rhlibrary/show_selector_widget.go +++ b/src/rhlibrary/show_selector_widget.go @@ -110,23 +110,49 @@ func selectShow() { } func addShowComboBox(grid *gtk.Grid, db *rddb.DBChan) (err error) { + var box *gtk.Box + if box, err = gtk.BoxNew(gtk.ORIENTATION_HORIZONTAL, 10); err != nil { + return + } + var label *gtk.Label if label, err = gtk.LabelNew("Sendung auswählen"); err != nil { return } - grid.Attach(label, 1, 1, 1, 1) + box.PackStart(label, false, false, 0) if showsComboBox, err = gtk.ComboBoxTextNew(); err != nil { return } - if err = updateShows(db); err != nil { return err } - showsComboBox.Connect("changed", func(_ *gtk.ComboBoxText) { selectShow() }) - grid.Attach(showsComboBox, 2, 1, 1, 1) + box.PackStart(showsComboBox, true, true, 0) + box.SetHExpand(true) + + var frame *gtk.Frame + if frame, err = gtk.FrameNew(""); err != nil { + return + } + + var cp *gtk.CssProvider + if cp, err = gtk.CssProviderNew(); err != nil { + return + } + if err = cp.LoadFromData(".frame { border: 0; padding: 25px 42px; }"); err != nil { + return + } + var sc *gtk.StyleContext + if sc, err = frame.GetStyleContext(); err != nil { + return + } + sc.AddProvider(cp, 600) // TOOD: hardcoded value + + frame.Add(box) + + grid.Attach(frame, 1, 1, 1, 1) return } |