InAppNotification: Fix autohiding after the callback is executed.

This commit is contained in:
Jordan Petridis 2018-03-09 20:24:28 +02:00
parent 064879c4ce
commit dbbb4e589e
No known key found for this signature in database
GPG Key ID: CEABAD9F5683B9A6

View File

@ -35,14 +35,18 @@ impl Default for InAppNotification {
} }
impl InAppNotification { impl InAppNotification {
pub fn new<F>(text: String, callback: F, sender: Sender<Action>) -> Self pub fn new<F>(text: String, mut callback: F, sender: Sender<Action>) -> Self
where where
F: FnMut() -> glib::Continue + 'static, F: FnMut() -> glib::Continue + 'static,
{ {
let notif = InAppNotification::default(); let notif = InAppNotification::default();
notif.text.set_text(&text); 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))); let id = Rc::new(RefCell::new(Some(id)));
// Cancel the callback // Cancel the callback