From 93f5df97760109fe5c7877c516e28fa250ad9e2b Mon Sep 17 00:00:00 2001 From: Gabriele Musco Date: Mon, 5 Aug 2024 10:21:06 +0200 Subject: [PATCH] feat: use stateless_action macro for wivrn install actions --- src/ui/install_wivrn_box.rs | 39 ++++++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 16 deletions(-) diff --git a/src/ui/install_wivrn_box.rs b/src/ui/install_wivrn_box.rs index 52daa4f..4c7cfbd 100644 --- a/src/ui/install_wivrn_box.rs +++ b/src/ui/install_wivrn_box.rs @@ -11,6 +11,7 @@ use crate::{ downloader::download_file_sync, paths::wivrn_apk_download_path, profile::{Profile, XRServiceType}, + stateless_action, }; use gtk::prelude::*; use gtk4::glib::clone; @@ -246,26 +247,32 @@ impl SimpleComponent for InstallWivrnBox { let mut actions = RelmActionGroup::::new(); - let apk_oculus_action = { - let oculus_sender = sender.clone(); - RelmAction::::new_stateless(move |_| { - oculus_sender.input(Self::Input::InstallWivrnApk( + stateless_action!( + actions, + WivrnApkStandardAction, + clone!( + #[strong] + sender, + move |_| { + sender.input(Self::Input::InstallWivrnApk( "https://github.com/Meumeu/WiVRn/releases/latest/download/WiVRn-standard-release.apk".into() )); - }) - }; - - let apk_pico_action = { - let pico_sender = sender.clone(); - RelmAction::::new_stateless(move |_| { - pico_sender.input(Self::Input::InstallWivrnApk( + } + ) + ); + stateless_action!( + actions, + WivrnApkPicoAction, + clone!( + #[strong] + sender, + move |_| { + sender.input(Self::Input::InstallWivrnApk( "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( InstallWivrnActionGroup::NAME,