PlayerWidget: Group the button connect_clicked methods.

This commit is contained in:
Jordan Petridis 2018-06-15 18:19:17 +03:00
parent 0080399db2
commit a6a34d8246

View File

@ -198,17 +198,7 @@ impl PlayerWidget {
#[cfg_attr(rustfmt, rustfmt_skip)] #[cfg_attr(rustfmt, rustfmt_skip)]
fn init(s: &Rc<Self>, sender: &Sender<Action>) { fn init(s: &Rc<Self>, sender: &Sender<Action>) {
// Connect the play button to the gst Player. Self::connect_buttons(s);
s.controls.play.connect_clicked(clone!(s => move |_| s.play()));
// Connect the pause button to the gst Player.
s.controls.pause.connect_clicked(clone!(s => move |_| s.pause()));
// Connect the rewind button to the gst Player.
s.controls.rewind.connect_clicked(clone!(s => move |_| s.rewind()));
// Connect the fast-forward button to the gst Player.
s.controls.forward.connect_clicked(clone!(s => move |_| s.fast_forward()));
// Log gst warnings. // Log gst warnings.
s.player.connect_warning(move |_, warn| warn!("gst warning: {}", warn)); s.player.connect_warning(move |_, warn| warn!("gst warning: {}", warn));
@ -235,6 +225,22 @@ impl PlayerWidget {
})); }));
} }
#[cfg_attr(rustfmt, rustfmt_skip)]
/// Connect the `PlayerControls` buttons to the `PlayerExt` methods.
fn connect_buttons(s: &Rc<Self>) {
// Connect the play button to the gst Player.
s.controls.play.connect_clicked(clone!(s => move |_| s.play()));
// Connect the pause button to the gst Player.
s.controls.pause.connect_clicked(clone!(s => move |_| s.pause()));
// Connect the rewind button to the gst Player.
s.controls.rewind.connect_clicked(clone!(s => move |_| s.rewind()));
// Connect the fast-forward button to the gst Player.
s.controls.forward.connect_clicked(clone!(s => move |_| s.fast_forward()));
}
fn reveal(&self) { fn reveal(&self) {
self.action_bar.show(); self.action_bar.show();
} }