pub struct Toaster { /* private fields */ }Available on crate feature
libadwaita only.Expand description
An abstraction over adw::ToastOverlay that
makes it easy to store it in the model of components.
The only allowed action is to add toasts, effectively keeping the separation between UI and application state.
Implementations§
Source§impl Toaster
impl Toaster
Sourcepub fn new(overlay: &ToastOverlay) -> Self
pub fn new(overlay: &ToastOverlay) -> Self
Create a new Toaster with a given overlay.
Sourcepub fn overlay_widget(&self) -> &ToastOverlay
pub fn overlay_widget(&self) -> &ToastOverlay
The adw::ToastOverlay used internally.
Examples found in repository?
relm4/examples/toast.rs (line 79)
69 fn init(
70 _: Self::Init,
71 root: Self::Root,
72 sender: ComponentSender<Self>,
73 ) -> ComponentParts<Self> {
74 let model = App {
75 activated: "Idle",
76 toaster: Toaster::default(),
77 };
78
79 let toast_overlay = model.toaster.overlay_widget();
80
81 // Insert the code generation of the view! macro here
82 let widgets = view_output!();
83
84 ComponentParts { model, widgets }
85 }Sourcepub fn toast(&self, title: &str)
pub fn toast(&self, title: &str)
Create a simple adw::Toast that only contains
a text message.
Sourcepub fn add_toast(&self, toast: Toast)
pub fn add_toast(&self, toast: Toast)
Add a adw::Toast to the overlay.
Examples found in repository?
relm4/examples/toast.rs (line 100)
87 fn update(&mut self, msg: Self::Input, sender: ComponentSender<Self>) {
88 match msg {
89 Msg::Activate => {
90 self.activated = "Active";
91 let toast = adw::Toast::builder()
92 .title("Activated")
93 .button_label("Cancel")
94 .timeout(0)
95 .build();
96 toast.connect_button_clicked(move |this| {
97 this.dismiss();
98 sender.input(Msg::Cancel);
99 });
100 self.toaster.add_toast(toast);
101 }
102 Msg::Cancel => self.activated = "Idle",
103 }
104 }Trait Implementations§
Auto Trait Implementations§
impl Freeze for Toaster
impl RefUnwindSafe for Toaster
impl !Send for Toaster
impl !Sync for Toaster
impl Unpin for Toaster
impl UnwindSafe for Toaster
Blanket Implementations§
Source§impl<C> AsyncPosition<()> for C
impl<C> AsyncPosition<()> for C
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more