diff --git a/hammond-gtk/src/appnotif.rs b/hammond-gtk/src/appnotif.rs index 83ac31a..9c9d5f9 100644 --- a/hammond-gtk/src/appnotif.rs +++ b/hammond-gtk/src/appnotif.rs @@ -5,6 +5,13 @@ use gtk::prelude::*; use std::cell::RefCell; use std::rc::Rc; +#[allow(dead_code)] +#[derive(Debug, Clone)] +pub enum UndoState { + Shown, + Hidden, +} + #[derive(Debug, Clone)] pub struct InAppNotification { revealer: gtk::Revealer, @@ -32,7 +39,7 @@ impl Default for InAppNotification { } impl InAppNotification { - pub fn new(text: &str, mut callback: F, undo_callback: U) -> Self + pub fn new(text: &str, mut callback: F, undo_callback: U, show_undo: UndoState) -> Self where F: FnMut() -> glib::Continue + 'static, U: Fn() + 'static, @@ -67,6 +74,11 @@ impl InAppNotification { revealer.set_reveal_child(false); }); + match show_undo { + UndoState::Shown => (), + UndoState::Hidden => notif.undo.hide(), + } + notif } diff --git a/hammond-gtk/src/widgets/show.rs b/hammond-gtk/src/widgets/show.rs index e41945d..674e693 100644 --- a/hammond-gtk/src/widgets/show.rs +++ b/hammond-gtk/src/widgets/show.rs @@ -13,7 +13,7 @@ use hammond_data::utils::delete_show; use hammond_data::Podcast; use app::Action; -use appnotif::InAppNotification; +use appnotif::{InAppNotification, UndoState}; use utils::{self, lazy_load}; use widgets::EpisodeWidget; @@ -279,7 +279,7 @@ pub fn mark_all_notif(pd: Arc, sender: &Sender) -> InAppNotific }); let text = "Marked all episodes as listened"; - InAppNotification::new(text, callback, undo_callback) + InAppNotification::new(text, callback, undo_callback, UndoState::Shown) } pub fn remove_show_notif(pd: Arc, sender: Sender) -> InAppNotification { @@ -319,7 +319,7 @@ pub fn remove_show_notif(pd: Arc, sender: Sender) -> InAppNotif undo_wrap().map_err(|err| error!("{}", err)).ok(); }; - InAppNotification::new(&text, callback, undo_callback) + InAppNotification::new(&text, callback, undo_callback, UndoState::Shown) } // Ideally if we had a custom widget this would have been as simple as: