diff --git a/podcasts-gtk/src/app.rs b/podcasts-gtk/src/app.rs index 1d35ea6..68d946d 100644 --- a/podcasts-gtk/src/app.rs +++ b/podcasts-gtk/src/app.rs @@ -307,7 +307,7 @@ impl App { error!("An error notification was triggered: {}", err); let callback = || glib::Continue(false); let undo_cb: Option = None; - let notif = InAppNotification::new(&err, callback, undo_cb); + let notif = InAppNotification::new(&err, 6, callback, undo_cb); notif.show(&self.overlay); } Action::InitEpisode(rowid) => { diff --git a/podcasts-gtk/src/widgets/appnotif.rs b/podcasts-gtk/src/widgets/appnotif.rs index e6abd0a..fec5564 100644 --- a/podcasts-gtk/src/widgets/appnotif.rs +++ b/podcasts-gtk/src/widgets/appnotif.rs @@ -39,7 +39,12 @@ impl Default for InAppNotification { } impl InAppNotification { - pub(crate) fn new(text: &str, mut callback: F, undo_callback: Option) -> Self + pub(crate) fn new( + text: &str, + timer: u32, + mut callback: F, + undo_callback: Option, + ) -> Self where F: FnMut() -> glib::Continue + 'static, U: Fn() + 'static, @@ -48,10 +53,16 @@ impl InAppNotification { notif.text.set_text(&text); let revealer_weak = notif.revealer.downgrade(); - let id = timeout_add_seconds(6, move || { + let mut time = 0; + let id = timeout_add_seconds(1, move || { + if time < timer { + time += 1; + return glib::Continue(true); + }; + let revealer = match revealer_weak.upgrade() { Some(r) => r, - None => return, + None => return glib::Continue(false), }; revealer.set_reveal_child(false); diff --git a/podcasts-gtk/src/widgets/show_menu.rs b/podcasts-gtk/src/widgets/show_menu.rs index 45a5e07..3407b38 100644 --- a/podcasts-gtk/src/widgets/show_menu.rs +++ b/podcasts-gtk/src/widgets/show_menu.rs @@ -145,7 +145,7 @@ pub(crate) fn mark_all_notif(pd: Arc, sender: &Sender) -> InAppNot let undo_callback = clone!(sender => move || sender.send(Action::RefreshWidgetIfSame(id))); let text = i18n("Marked all episodes as listened"); - InAppNotification::new(&text, callback, Some(undo_callback)) + InAppNotification::new(&text, 6, callback, Some(undo_callback)) } pub(crate) fn remove_show_notif(pd: Arc, sender: Sender) -> InAppNotification { @@ -177,5 +177,5 @@ pub(crate) fn remove_show_notif(pd: Arc, sender: Sender) -> InAppN sender.send(Action::RefreshEpisodesView); }; - InAppNotification::new(&text, callback, Some(undo_callback)) + InAppNotification::new(&text, 6, callback, Some(undo_callback)) }