From dbbb4e589e693a579b4d326176e275b194a45aec Mon Sep 17 00:00:00 2001 From: Jordan Petridis Date: Fri, 9 Mar 2018 20:24:28 +0200 Subject: [PATCH] InAppNotification: Fix autohiding after the callback is executed. --- hammond-gtk/src/appnotif.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/hammond-gtk/src/appnotif.rs b/hammond-gtk/src/appnotif.rs index 1ba012e..07291a7 100644 --- a/hammond-gtk/src/appnotif.rs +++ b/hammond-gtk/src/appnotif.rs @@ -35,14 +35,18 @@ impl Default for InAppNotification { } impl InAppNotification { - pub fn new(text: String, callback: F, sender: Sender) -> Self + pub fn new(text: String, mut callback: F, sender: Sender) -> Self where F: FnMut() -> glib::Continue + 'static, { let notif = InAppNotification::default(); notif.text.set_text(&text); - let id = timeout_add_seconds(6, callback); + let revealer = notif.revealer.clone(); + let id = timeout_add_seconds(6, move || { + revealer.set_reveal_child(false); + callback() + }); let id = Rc::new(RefCell::new(Some(id))); // Cancel the callback