feat: use stateless_action macro for wivrn install actions

This commit is contained in:
Gabriele Musco 2024-08-05 10:21:06 +02:00
commit 93f5df9776

View file

@ -11,6 +11,7 @@ use crate::{
downloader::download_file_sync, downloader::download_file_sync,
paths::wivrn_apk_download_path, paths::wivrn_apk_download_path,
profile::{Profile, XRServiceType}, profile::{Profile, XRServiceType},
stateless_action,
}; };
use gtk::prelude::*; use gtk::prelude::*;
use gtk4::glib::clone; use gtk4::glib::clone;
@ -246,26 +247,32 @@ impl SimpleComponent for InstallWivrnBox {
let mut actions = RelmActionGroup::<InstallWivrnActionGroup>::new(); let mut actions = RelmActionGroup::<InstallWivrnActionGroup>::new();
let apk_oculus_action = { stateless_action!(
let oculus_sender = sender.clone(); actions,
RelmAction::<WivrnApkStandardAction>::new_stateless(move |_| { WivrnApkStandardAction,
oculus_sender.input(Self::Input::InstallWivrnApk( clone!(
#[strong]
sender,
move |_| {
sender.input(Self::Input::InstallWivrnApk(
"https://github.com/Meumeu/WiVRn/releases/latest/download/WiVRn-standard-release.apk".into() "https://github.com/Meumeu/WiVRn/releases/latest/download/WiVRn-standard-release.apk".into()
)); ));
}) }
}; )
);
let apk_pico_action = { stateless_action!(
let pico_sender = sender.clone(); actions,
RelmAction::<WivrnApkPicoAction>::new_stateless(move |_| { WivrnApkPicoAction,
pico_sender.input(Self::Input::InstallWivrnApk( clone!(
#[strong]
sender,
move |_| {
sender.input(Self::Input::InstallWivrnApk(
"https://github.com/Meumeu/WiVRn/releases/latest/download/WiVRn-pico-release.apk".into() "https://github.com/Meumeu/WiVRn/releases/latest/download/WiVRn-pico-release.apk".into()
)); ));
}) }
}; )
);
actions.add_action(apk_oculus_action);
actions.add_action(apk_pico_action);
root.insert_action_group( root.insert_action_group(
InstallWivrnActionGroup::NAME, InstallWivrnActionGroup::NAME,