feat: make wivrn install box async component

This commit is contained in:
Gabriele Musco 2024-08-24 08:44:11 +02:00
commit 9790844ee3
2 changed files with 14 additions and 8 deletions

View file

@ -52,11 +52,12 @@ pub struct InstallWivrnBoxInit {
pub root_win: gtk::Window, pub root_win: gtk::Window,
} }
#[relm4::component(pub)] #[relm4::component(pub async)]
impl SimpleComponent for InstallWivrnBox { impl AsyncComponent for InstallWivrnBox {
type Init = InstallWivrnBoxInit; type Init = InstallWivrnBoxInit;
type Input = InstallWivrnBoxMsg; type Input = InstallWivrnBoxMsg;
type Output = (); type Output = ();
type CommandOutput = ();
view! { view! {
gtk::Box { gtk::Box {
@ -121,7 +122,12 @@ impl SimpleComponent for InstallWivrnBox {
} }
} }
fn update(&mut self, message: Self::Input, sender: ComponentSender<Self>) { async fn update(
&mut self,
message: Self::Input,
sender: AsyncComponentSender<Self>,
_root: &Self::Root,
) {
self.reset(); self.reset();
match message { match message {
@ -218,11 +224,11 @@ impl SimpleComponent for InstallWivrnBox {
} }
} }
fn init( async fn init(
init: Self::Init, init: Self::Init,
root: Self::Root, root: Self::Root,
sender: ComponentSender<Self>, sender: AsyncComponentSender<Self>,
) -> ComponentParts<Self> { ) -> AsyncComponentParts<Self> {
let model = Self { let model = Self {
selected_profile: init.selected_profile, selected_profile: init.selected_profile,
install_wivrn_status: InstallWivrnStatus::Done(None), install_wivrn_status: InstallWivrnStatus::Done(None),
@ -234,7 +240,7 @@ impl SimpleComponent for InstallWivrnBox {
let widgets = view_output!(); let widgets = view_output!();
ComponentParts { model, widgets } AsyncComponentParts { model, widgets }
} }
} }

View file

@ -42,7 +42,7 @@ pub struct MainView {
#[tracker::do_not_track] #[tracker::do_not_track]
profiles_dropdown: Option<gtk::DropDown>, profiles_dropdown: Option<gtk::DropDown>,
#[tracker::do_not_track] #[tracker::do_not_track]
install_wivrn_box: Controller<InstallWivrnBox>, install_wivrn_box: AsyncController<InstallWivrnBox>,
#[tracker::do_not_track] #[tracker::do_not_track]
steam_launch_options_box: Controller<SteamLaunchOptionsBox>, steam_launch_options_box: Controller<SteamLaunchOptionsBox>,
#[tracker::do_not_track] #[tracker::do_not_track]