fix: show loading spinner during startup
This commit is contained in:
parent
dd2616f0e5
commit
3315b38806
1 changed files with 16 additions and 2 deletions
18
src/main.rs
18
src/main.rs
|
@ -12,6 +12,7 @@ use relm4::{
|
|||
Component, ComponentController, Controller, RelmApp, Sender,
|
||||
adw::{self, prelude::*},
|
||||
gtk::{self, gio},
|
||||
loading_widgets::LoadingWidgets,
|
||||
prelude::{AsyncComponent, AsyncComponentParts},
|
||||
tokio,
|
||||
};
|
||||
|
@ -264,8 +265,6 @@ impl AsyncComponent for Tyrolienne {
|
|||
.forward(sender.input_sender(), |_| Message::Nothing),
|
||||
};
|
||||
|
||||
// TODO consider using the "loading" (?) mechanism from relm4
|
||||
// https://relm4.org/book/stable/threads_and_async/async.html
|
||||
let folders = match zipline::get_folders(&model.config).await {
|
||||
Ok(v) => v,
|
||||
Err(e) => {
|
||||
|
@ -296,6 +295,21 @@ impl AsyncComponent for Tyrolienne {
|
|||
AsyncComponentParts { model, widgets }
|
||||
}
|
||||
|
||||
fn init_loading_widgets(root: Self::Root) -> Option<LoadingWidgets> {
|
||||
relm4::view! {
|
||||
#[local]
|
||||
root {
|
||||
#[name(spinner)]
|
||||
gtk::Spinner {
|
||||
start: (),
|
||||
set_halign: gtk::Align::Center,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Some(LoadingWidgets::new(root, spinner))
|
||||
}
|
||||
|
||||
async fn update(
|
||||
&mut self,
|
||||
message: Self::Input,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue