From 7de118adeb542d37de0cada59c1cbbda1b6f8fc7 Mon Sep 17 00:00:00 2001 From: Jordan Petridis Date: Thu, 8 Mar 2018 23:14:48 +0200 Subject: [PATCH] Minor style changes. --- hammond-gtk/src/app.rs | 5 ++--- hammond-gtk/src/widgets/show.rs | 25 +++++++++++-------------- 2 files changed, 13 insertions(+), 17 deletions(-) diff --git a/hammond-gtk/src/app.rs b/hammond-gtk/src/app.rs index 8027d4b..7f47456 100644 --- a/hammond-gtk/src/app.rs +++ b/hammond-gtk/src/app.rs @@ -114,9 +114,8 @@ impl App { pub fn run(self) { let window = self.window.clone(); - let app = self.app_instance.clone(); - self.app_instance.connect_startup(move |_| { - build_ui(&window, &app); + self.app_instance.connect_startup(move |app| { + build_ui(&window, app); }); self.setup_timed_callbacks(); diff --git a/hammond-gtk/src/widgets/show.rs b/hammond-gtk/src/widgets/show.rs index b2791f5..1d7597c 100644 --- a/hammond-gtk/src/widgets/show.rs +++ b/hammond-gtk/src/widgets/show.rs @@ -193,19 +193,13 @@ fn on_played_button_clicked( notif.set_reveal_child(true); // Set up the callback - let id = timeout_add_seconds( - 10, - clone!(sender => move || { + let callback = clone!(sender => move || { if let Err(err) = wrap(&pd, sender.clone()) { - error!( - "Something went horribly wrong with the notif callback: {}", - err - ); + error!("Something went horribly wrong with the notif callback: {}", err); } glib::Continue(false) - }), - ); - + }); + let id = timeout_add_seconds(10, callback); let id = Rc::new(RefCell::new(Some(id))); // Cancel the callback @@ -213,10 +207,13 @@ fn on_played_button_clicked( let foo = id.borrow_mut().take(); if let Some(id) = foo { glib::source::source_remove(id); - notif.set_reveal_child(false); - if let Err(err) = sender.send(Action::RefreshWidgetIfVis) { - error!("Something went horribly wrong with the Action channel: {}", err) - } + } + + // Hide the notification + notif.set_reveal_child(false); + // Refresh the widget if visible + if let Err(err) = sender.send(Action::RefreshWidgetIfVis) { + error!("Something went horribly wrong with the Action channel: {}", err) } })); }