From a122acb0b81af76d9fea32a21be5a691d0182d81 Mon Sep 17 00:00:00 2001 From: Observer KRypt0n_ Date: Fri, 5 May 2023 11:35:26 +0200 Subject: [PATCH] feat(core): updated Relm4 to `0.6.0-beta.1` --- Cargo.lock | 8 ++++---- Cargo.toml | 2 +- src/ui/main/mod.rs | 14 +++++++------- src/ui/preferences/environment.rs | 10 +++------- src/ui/preferences/game.rs | 10 +++------- src/ui/preferences/general.rs | 8 ++++---- src/ui/preferences/sandbox.rs | 10 +++------- 7 files changed, 25 insertions(+), 37 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 67100c8..400d865 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2065,9 +2065,9 @@ checksum = "456c603be3e8d448b072f410900c09faf164fbce2d480456f50eea6e25f9c848" [[package]] name = "relm4" -version = "0.6.0-alpha.2" +version = "0.6.0-beta.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7acc5e3ddd682eeb0ca33da36b821fc907017c6d7758b09ce280247b0b0ea8cd" +checksum = "f169f698ce2e487eed2306898fcf262224a287d0e81480db4190e74cfec412cf" dependencies = [ "async-trait", "flume", @@ -2083,9 +2083,9 @@ dependencies = [ [[package]] name = "relm4-macros" -version = "0.6.0-alpha.2" +version = "0.6.0-beta.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8525ce12dcd7d2a9e9070d84b8b885600eccd0a143df6712ce34a87d001a8b7" +checksum = "7fa06febb3685960e7c1c44e21e44a3829325940b31d1e91391a43c32020c201" dependencies = [ "proc-macro2", "quote", diff --git a/Cargo.toml b/Cargo.toml index ade06a7..b067072 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,7 +23,7 @@ features = ["all", "genshin"] # path = "../anime-launcher-sdk" # ! for dev purposes only [dependencies] -relm4 = { version = "0.6.0-alpha.2", features = ["macros", "libadwaita"] } +relm4 = { version = "0.6.0-beta.1", features = ["macros", "libadwaita"] } gtk = { package = "gtk4", version = "0.6", features = ["v4_8"] } adw = { package = "libadwaita", version = "0.3", features = ["v1_2"] } diff --git a/src/ui/main/mod.rs b/src/ui/main/mod.rs index cebc160..2308bbe 100644 --- a/src/ui/main/mod.rs +++ b/src/ui/main/mod.rs @@ -557,11 +557,11 @@ impl SimpleComponent for App { .detach()); } - let group = RelmActionGroup::::new(); + let mut group = RelmActionGroup::::new(); // TODO: reduce code somehow - group.add_action::(&RelmAction::new_stateless(clone!(@strong sender => move |_| { + group.add_action::(RelmAction::new_stateless(clone!(@strong sender => move |_| { if let Err(err) = open::that(LAUNCHER_FOLDER.as_path()) { sender.input(AppMsg::Toast { title: tr("launcher-folder-opening-error"), @@ -572,7 +572,7 @@ impl SimpleComponent for App { } }))); - group.add_action::(&RelmAction::new_stateless(clone!(@strong sender => move |_| { + group.add_action::(RelmAction::new_stateless(clone!(@strong sender => move |_| { let path = match Config::get() { Ok(config) => config.game.path.for_edition(config.launcher.edition).to_path_buf(), Err(_) => CONFIG.game.path.for_edition(CONFIG.launcher.edition).to_path_buf(), @@ -588,7 +588,7 @@ impl SimpleComponent for App { } }))); - group.add_action::(&RelmAction::new_stateless(clone!(@strong sender => move |_| { + group.add_action::(RelmAction::new_stateless(clone!(@strong sender => move |_| { if let Ok(file) = config_file() { if let Err(err) = open::that(file) { sender.input(AppMsg::Toast { @@ -601,7 +601,7 @@ impl SimpleComponent for App { } }))); - group.add_action::(&RelmAction::new_stateless(clone!(@strong sender => move |_| { + group.add_action::(RelmAction::new_stateless(clone!(@strong sender => move |_| { if let Err(err) = open::that(crate::DEBUG_FILE.as_os_str()) { sender.input(AppMsg::Toast { title: tr("debug-file-opening-error"), @@ -612,7 +612,7 @@ impl SimpleComponent for App { } }))); - group.add_action::(&RelmAction::new_stateless(clone!(@strong sender => move |_| { + group.add_action::(RelmAction::new_stateless(clone!(@strong sender => move |_| { std::thread::spawn(clone!(@strong sender => move || { let config = Config::get().unwrap_or_else(|_| CONFIG.clone()); @@ -672,7 +672,7 @@ impl SimpleComponent for App { })); }))); - group.add_action::(&RelmAction::new_stateless(move |_| { + group.add_action::(RelmAction::new_stateless(move |_| { about_dialog_broker.send(AboutDialogMsg::Show); })); diff --git a/src/ui/preferences/environment.rs b/src/ui/preferences/environment.rs index 8b64807..6b71ee3 100644 --- a/src/ui/preferences/environment.rs +++ b/src/ui/preferences/environment.rs @@ -33,16 +33,12 @@ impl AsyncFactoryComponent for Variable { set_valign: gtk::Align::Center, connect_clicked[sender, index] => move |_| { - sender.input(EnvironmentAppMsg::Remove(index.clone())); + sender.output(EnvironmentAppMsg::Remove(index.clone())); } } } } - fn output_to_parent_input(output: Self::Output) -> Option { - Some(output) - } - async fn init_model( init: Self::Init, _index: &DynamicIndex, @@ -54,8 +50,8 @@ impl AsyncFactoryComponent for Variable { } } - async fn update(&mut self, msg: Self::Input, sender: AsyncFactorySender) { - sender.output(msg); + fn forward_to_parent(output: Self::Output) -> Option { + Some(output) } } diff --git a/src/ui/preferences/game.rs b/src/ui/preferences/game.rs index 6e2c613..ca98c67 100644 --- a/src/ui/preferences/game.rs +++ b/src/ui/preferences/game.rs @@ -38,16 +38,12 @@ impl AsyncFactoryComponent for GameSession { set_valign: gtk::Align::Center, connect_clicked[sender, index] => move |_| { - sender.input(GameAppMsg::RemoveSession(index.clone())); + sender.output(GameAppMsg::RemoveSession(index.clone())); } } } } - fn output_to_parent_input(output: Self::Output) -> Option { - Some(output) - } - async fn init_model( init: Self::Init, _index: &DynamicIndex, @@ -56,8 +52,8 @@ impl AsyncFactoryComponent for GameSession { init } - async fn update(&mut self, msg: Self::Input, sender: AsyncFactorySender) { - sender.output(msg); + fn forward_to_parent(output: Self::Output) -> Option { + Some(output) } } diff --git a/src/ui/preferences/general.rs b/src/ui/preferences/general.rs index 6c09ff2..749f4d9 100644 --- a/src/ui/preferences/general.rs +++ b/src/ui/preferences/general.rs @@ -84,10 +84,6 @@ impl AsyncFactoryComponent for VoicePackageComponent { } } - fn output_to_parent_input(output: Self::Output) -> Option { - Some(output) - } - async fn init_model( init: Self::Init, _index: &DynamicIndex, @@ -105,6 +101,10 @@ impl AsyncFactoryComponent for VoicePackageComponent { sender.output(msg); } + + fn forward_to_parent(output: Self::Output) -> Option { + Some(output) + } } pub struct GeneralApp { diff --git a/src/ui/preferences/sandbox.rs b/src/ui/preferences/sandbox.rs index f3d7958..74ede8a 100644 --- a/src/ui/preferences/sandbox.rs +++ b/src/ui/preferences/sandbox.rs @@ -41,16 +41,12 @@ macro_rules! impl_directory { set_valign: gtk::Align::Center, connect_clicked[sender, index] => move |_| { - sender.input($msg(index.clone())); + sender.output($msg(index.clone())); } } } } - fn output_to_parent_input(output: Self::Output) -> Option { - Some(output) - } - async fn init_model( init: Self::Init, _index: &DynamicIndex, @@ -62,8 +58,8 @@ macro_rules! impl_directory { } } - async fn update(&mut self, msg: Self::Input, sender: AsyncFactorySender) { - sender.output(msg); + fn forward_to_parent(output: Self::Output) -> Option { + Some(output) } } }