From a6a34d8246a1ff48f683f4191c0f25dfffe7b121 Mon Sep 17 00:00:00 2001 From: Jordan Petridis Date: Fri, 15 Jun 2018 18:19:17 +0300 Subject: [PATCH] PlayerWidget: Group the button connect_clicked methods. --- hammond-gtk/src/widgets/player.rs | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/hammond-gtk/src/widgets/player.rs b/hammond-gtk/src/widgets/player.rs index 6b938be..dd53fc1 100644 --- a/hammond-gtk/src/widgets/player.rs +++ b/hammond-gtk/src/widgets/player.rs @@ -198,17 +198,7 @@ impl PlayerWidget { #[cfg_attr(rustfmt, rustfmt_skip)] fn init(s: &Rc, sender: &Sender) { - // 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())); + Self::connect_buttons(s); // Log gst warnings. 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) { + // 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) { self.action_bar.show(); }