pub struct LoadingWidgets { /* private fields */ }Expand description
A type that stores widget containers and their child widgets and removes all children automatically when dropped.
This mechanism is used by async components and factories to show widgets while the async init function isn’t completed. Once the actual widgets are initialized, the temporary loading widgets can be removed again, which is simply done with this type.
Implementations§
Source§impl LoadingWidgets
impl LoadingWidgets
Sourcepub fn new<C, W>(container: C, child: W) -> Self
pub fn new<C, W>(container: C, child: W) -> Self
Create new LoadingWidgets with one child.
Examples found in repository?
relm4/examples/simple_async.rs (line 70)
54 fn init_loading_widgets(root: Self::Root) -> Option<LoadingWidgets> {
55 view! {
56 #[local]
57 root {
58 set_title: Some("Simple app"),
59 set_default_size: (300, 100),
60
61 // This will be removed automatically by
62 // LoadingWidgets when the full view has loaded
63 #[name(spinner)]
64 gtk::Spinner {
65 start: (),
66 set_halign: gtk::Align::Center,
67 }
68 }
69 }
70 Some(LoadingWidgets::new(root, spinner))
71 }More examples
relm4/examples/factory_async.rs (line 108)
91 fn init_loading_widgets(root: Self::Root) -> Option<LoadingWidgets> {
92 view! {
93 #[local]
94 root {
95 set_orientation: gtk::Orientation::Horizontal,
96 set_spacing: 10,
97
98 #[name(spinner)]
99 gtk::Spinner {
100 start: (),
101 set_hexpand: true,
102 set_halign: gtk::Align::Center,
103 // Reserve vertical space
104 set_height_request: 34,
105 }
106 }
107 }
108 Some(LoadingWidgets::new(root, spinner))
109 }Sourcepub fn with_children<C, W>(container: C, children: &[W]) -> Self
pub fn with_children<C, W>(container: C, children: &[W]) -> Self
Create new LoadingWidgets with multiple children.
Trait Implementations§
Source§impl Debug for LoadingWidgets
impl Debug for LoadingWidgets
Auto Trait Implementations§
impl Freeze for LoadingWidgets
impl !RefUnwindSafe for LoadingWidgets
impl !Send for LoadingWidgets
impl !Sync for LoadingWidgets
impl Unpin for LoadingWidgets
impl !UnwindSafe for LoadingWidgets
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