InAppNofitication: Make revealer field private, change show signature
Accept an overlay widget that the revealer will be attached to into the show method. Thus revealer field no longer need to be public.
This commit is contained in:
parent
bdc6264701
commit
d525d1fe59
@ -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(_) => (),
|
||||
}
|
||||
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user