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?
examples/simple_async.rs (line 69)
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
fn init_loading_widgets(root: Self::Root) -> Option<LoadingWidgets> {
view! {
#[local]
root {
set_title: Some("Simple app"),
set_default_size: (300, 100),
// This will be removed automatically by
// LoadingWidgets when the full view has loaded
#[name(spinner)]
gtk::Spinner {
start: (),
set_halign: gtk::Align::Center,
}
}
}
Some(LoadingWidgets::new(root, spinner))
}
More examples
examples/factory_async.rs (line 108)
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109
fn init_loading_widgets(root: Self::Root) -> Option<LoadingWidgets> {
view! {
#[local]
root {
set_orientation: gtk::Orientation::Horizontal,
set_spacing: 10,
#[name(spinner)]
gtk::Spinner {
start: (),
set_hexpand: true,
set_halign: gtk::Align::Center,
// Reserve vertical space
set_height_request: 34,
}
}
}
Some(LoadingWidgets::new(root, spinner))
}
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