diff --git a/hammond-gtk/src/app.rs b/hammond-gtk/src/app.rs index 6277887..4fa1b83 100644 --- a/hammond-gtk/src/app.rs +++ b/hammond-gtk/src/app.rs @@ -196,13 +196,9 @@ impl App { glib::Continue(false) }); - let text = "Marked all episodes as listened"; - let notif = - InAppNotification::new(text.into(), callback, || {}, sender.clone()); - overlay.add_overlay(¬if.revealer); - // We need to display the notification after the widget is added to the overlay - // so there will be a nice animation. - notif.show(); + let text = "Marked all episodes as listened".into(); + let notif = InAppNotification::new(text, callback, || {}, sender.clone()); + notif.show(&overlay); } Ok(Action::RemoveShow(pd)) => { let text = format!("Unsubscribed from {}", pd.title()); @@ -244,10 +240,7 @@ impl App { let sender_ = sender.clone(); let notif = InAppNotification::new(text, callback, undo_callback, sender_); - overlay.add_overlay(¬if.revealer); - // We need to display the notification after the widget is added to the overlay - // so there will be a nice animation. - notif.show(); + notif.show(&overlay); } Err(_) => (), } diff --git a/hammond-gtk/src/appnotif.rs b/hammond-gtk/src/appnotif.rs index 67168c1..19284fe 100644 --- a/hammond-gtk/src/appnotif.rs +++ b/hammond-gtk/src/appnotif.rs @@ -10,7 +10,7 @@ use std::sync::mpsc::Sender; #[derive(Debug, Clone)] pub struct InAppNotification { - pub revealer: gtk::Revealer, + revealer: gtk::Revealer, text: gtk::Label, undo: gtk::Button, close: gtk::Button, @@ -83,10 +83,13 @@ impl InAppNotification { } // This is a seperate method cause in order to get a nice animation - // the revealer should be attached to something that will display it. - // Previouslyi we where doing it in the constructor, which had the result + // the revealer should be attached to something that displays it. + // Previously we where doing it in the constructor, which had the result // of the animation being skipped cause there was no parent widget to display it. - pub fn show(&self) { + pub fn show(&self, overlay: >k::Overlay) { + overlay.add_overlay(&self.revealer); + // We need to display the notification after the widget is added to the overlay + // so there will be a nice animation. self.revealer.set_reveal_child(true); } }