mirror of
https://github.com/an-anime-team/sleepy-launcher.git
synced 2025-03-15 06:28:27 +03:00
core: made some components async and updated launcher sdk
which fixed app's blocking when downloading wine/dxvk
This commit is contained in:
parent
2a96982fd7
commit
0916894165
8 changed files with 82 additions and 99 deletions
60
Cargo.lock
generated
60
Cargo.lock
generated
|
@ -31,7 +31,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "anime-game-core"
|
||||
version = "1.3.2"
|
||||
version = "1.3.3"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"bzip2",
|
||||
|
@ -188,9 +188,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "cached"
|
||||
version = "0.40.0"
|
||||
version = "0.42.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "72b4147cd94d5fbdc2ab71b11d50a2f45493625576b3bb70257f59eedea69f3d"
|
||||
checksum = "5e5877db5d1af7fae60d06b5db9430b68056a69b3582a0be8e3691e87654aeb6"
|
||||
dependencies = [
|
||||
"async-trait",
|
||||
"async_once",
|
||||
|
@ -207,12 +207,13 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "cached_proc_macro"
|
||||
version = "0.15.0"
|
||||
version = "0.16.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "751f7f4e7a091545e7f6c65bacc404eaee7e87bfb1f9ece234a1caa173dc16f2"
|
||||
checksum = "e10ca87c81aaa3a949dbbe2b5e6c2c45dbc94ba4897e45ea31ff9ec5087be3dc"
|
||||
dependencies = [
|
||||
"cached_proc_macro_types",
|
||||
"darling 0.13.4",
|
||||
"darling",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
@ -395,38 +396,14 @@ dependencies = [
|
|||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "darling"
|
||||
version = "0.13.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a01d95850c592940db9b8194bc39f4bc0e89dee5c4265e4b1807c34a9aba453c"
|
||||
dependencies = [
|
||||
"darling_core 0.13.4",
|
||||
"darling_macro 0.13.4",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "darling"
|
||||
version = "0.14.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b0dd3cd20dc6b5a876612a6e5accfe7f3dd883db6d07acfbf14c128f61550dfa"
|
||||
dependencies = [
|
||||
"darling_core 0.14.2",
|
||||
"darling_macro 0.14.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "darling_core"
|
||||
version = "0.13.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "859d65a907b6852c9361e3185c862aae7fafd2887876799fa55f5f99dc40d610"
|
||||
dependencies = [
|
||||
"fnv",
|
||||
"ident_case",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"strsim",
|
||||
"syn",
|
||||
"darling_core",
|
||||
"darling_macro",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -443,24 +420,13 @@ dependencies = [
|
|||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "darling_macro"
|
||||
version = "0.13.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9c972679f83bdf9c42bd905396b6c3588a843a17f0f16dfcfa3e2c5d57441835"
|
||||
dependencies = [
|
||||
"darling_core 0.13.4",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "darling_macro"
|
||||
version = "0.14.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7618812407e9402654622dd402b0a89dff9ba93badd6540781526117b92aab7e"
|
||||
dependencies = [
|
||||
"darling_core 0.14.2",
|
||||
"darling_core",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
@ -480,7 +446,7 @@ version = "0.12.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c11bdc11a0c47bc7d37d582b5285da6849c96681023680b906673c5707af7b0f"
|
||||
dependencies = [
|
||||
"darling 0.14.2",
|
||||
"darling",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
|
@ -1104,9 +1070,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "hashbrown"
|
||||
version = "0.12.3"
|
||||
version = "0.13.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888"
|
||||
checksum = "43a3c133739dddd0d2990f9a4bdf8eb4b21ef50e4851ca85ab661199821d510e"
|
||||
|
||||
[[package]]
|
||||
name = "heck"
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 3a7486e6b725bfdb8e2c511fcbf2bc2cb7ea595d
|
||||
Subproject commit 8a32066c07cd471fe2a33ecfa778edffb8796f19
|
|
@ -1,4 +1,5 @@
|
|||
use relm4::prelude::*;
|
||||
use relm4::component::*;
|
||||
|
||||
use adw::prelude::*;
|
||||
|
||||
|
@ -8,7 +9,7 @@ pub struct ComponentGroup {
|
|||
pub title: String,
|
||||
pub show_recommended_only: bool,
|
||||
|
||||
pub versions: Vec<Controller<super::ComponentVersion>>
|
||||
pub versions: Vec<AsyncController<super::ComponentVersion>>
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
|
@ -18,8 +19,8 @@ pub enum AppMsg {
|
|||
CallOnDeleted
|
||||
}
|
||||
|
||||
#[relm4::component(pub)]
|
||||
impl SimpleComponent for ComponentGroup {
|
||||
#[relm4::component(async, pub)]
|
||||
impl SimpleAsyncComponent for ComponentGroup {
|
||||
type Init = (super::ComponentsListGroup, PathBuf);
|
||||
type Input = AppMsg;
|
||||
type Output = super::list::AppMsg;
|
||||
|
@ -30,11 +31,12 @@ impl SimpleComponent for ComponentGroup {
|
|||
}
|
||||
}
|
||||
|
||||
fn init(
|
||||
#[allow(clippy::redundant_clone)]
|
||||
async fn init(
|
||||
init: Self::Init,
|
||||
root: &Self::Root,
|
||||
sender: ComponentSender<Self>,
|
||||
) -> ComponentParts<Self> {
|
||||
root: Self::Root,
|
||||
sender: AsyncComponentSender<Self>,
|
||||
) -> AsyncComponentParts<Self> {
|
||||
let model = ComponentGroup {
|
||||
title: init.0.title,
|
||||
show_recommended_only: true,
|
||||
|
@ -55,10 +57,10 @@ impl SimpleComponent for ComponentGroup {
|
|||
widgets.group.add_row(version.widget());
|
||||
}
|
||||
|
||||
ComponentParts { model, widgets }
|
||||
AsyncComponentParts { model, widgets }
|
||||
}
|
||||
|
||||
fn update(&mut self, msg: Self::Input, sender: ComponentSender<Self>) {
|
||||
async fn update(&mut self, msg: Self::Input, sender: AsyncComponentSender<Self>) {
|
||||
tracing::debug!("Called component group [{}] event: {:?}", self.title, msg);
|
||||
|
||||
match msg {
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
use relm4::prelude::*;
|
||||
use relm4::component::*;
|
||||
|
||||
use adw::prelude::*;
|
||||
|
||||
|
@ -13,7 +14,7 @@ pub struct ComponentsList {
|
|||
pub show_recommended_only: bool,
|
||||
pub init: ComponentsListInit,
|
||||
|
||||
pub groups: Vec<Controller<super::ComponentGroup>>
|
||||
pub groups: Vec<AsyncController<super::ComponentGroup>>
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
|
@ -23,8 +24,8 @@ pub enum AppMsg {
|
|||
CallOnDeleted
|
||||
}
|
||||
|
||||
#[relm4::component(pub)]
|
||||
impl SimpleComponent for ComponentsList {
|
||||
#[relm4::component(async, pub)]
|
||||
impl SimpleAsyncComponent for ComponentsList {
|
||||
type Init = ComponentsListInit;
|
||||
type Input = AppMsg;
|
||||
type Output = crate::ui::preferences::main::AppMsg;
|
||||
|
@ -33,11 +34,12 @@ impl SimpleComponent for ComponentsList {
|
|||
group = adw::PreferencesGroup {}
|
||||
}
|
||||
|
||||
fn init(
|
||||
#[allow(clippy::redundant_clone)]
|
||||
async fn init(
|
||||
init: Self::Init,
|
||||
root: &Self::Root,
|
||||
sender: ComponentSender<Self>,
|
||||
) -> ComponentParts<Self> {
|
||||
root: Self::Root,
|
||||
sender: AsyncComponentSender<Self>,
|
||||
) -> AsyncComponentParts<Self> {
|
||||
let init_copy = init.clone();
|
||||
|
||||
let model = ComponentsList {
|
||||
|
@ -60,10 +62,10 @@ impl SimpleComponent for ComponentsList {
|
|||
widgets.group.add(group.widget());
|
||||
}
|
||||
|
||||
ComponentParts { model, widgets }
|
||||
AsyncComponentParts { model, widgets }
|
||||
}
|
||||
|
||||
fn update(&mut self, msg: Self::Input, sender: ComponentSender<Self>) {
|
||||
async fn update(&mut self, msg: Self::Input, sender: AsyncComponentSender<Self>) {
|
||||
tracing::debug!("Called components list event: {:?}", msg);
|
||||
|
||||
match msg {
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
use relm4::prelude::*;
|
||||
use relm4::component::*;
|
||||
|
||||
use adw::prelude::*;
|
||||
|
||||
|
@ -28,14 +29,15 @@ pub enum AppMsg {
|
|||
SetVisible(bool)
|
||||
}
|
||||
|
||||
#[relm4::component(pub)]
|
||||
impl SimpleComponent for ProgressBar {
|
||||
#[relm4::component(async, pub)]
|
||||
impl SimpleAsyncComponent for ProgressBar {
|
||||
type Init = (Option<String>, bool);
|
||||
type Input = AppMsg;
|
||||
type Output = ();
|
||||
|
||||
view! {
|
||||
progress_bar = gtk::ProgressBar {
|
||||
#[root]
|
||||
gtk::ProgressBar {
|
||||
set_valign: gtk::Align::Center,
|
||||
|
||||
#[watch]
|
||||
|
@ -61,11 +63,12 @@ impl SimpleComponent for ProgressBar {
|
|||
}
|
||||
}
|
||||
|
||||
fn init(
|
||||
#[allow(clippy::redundant_clone)]
|
||||
async fn init(
|
||||
init: Self::Init,
|
||||
root: &Self::Root,
|
||||
_sender: ComponentSender<Self>,
|
||||
) -> ComponentParts<Self> {
|
||||
root: Self::Root,
|
||||
_sender: AsyncComponentSender<Self>,
|
||||
) -> AsyncComponentParts<Self> {
|
||||
let model = ProgressBar {
|
||||
fraction: 0.0,
|
||||
caption: init.0,
|
||||
|
@ -75,10 +78,10 @@ impl SimpleComponent for ProgressBar {
|
|||
|
||||
let widgets = view_output!();
|
||||
|
||||
ComponentParts { model, widgets }
|
||||
AsyncComponentParts { model, widgets }
|
||||
}
|
||||
|
||||
fn update(&mut self, msg: Self::Input, _sender: ComponentSender<Self>) {
|
||||
async fn update(&mut self, msg: Self::Input, _sender: AsyncComponentSender<Self>) {
|
||||
tracing::debug!("Called components list event: {:?}", msg);
|
||||
|
||||
match msg {
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
use relm4::prelude::*;
|
||||
use relm4::component::*;
|
||||
|
||||
use gtk::prelude::*;
|
||||
use adw::prelude::*;
|
||||
|
@ -30,7 +31,7 @@ pub struct ComponentVersion {
|
|||
pub show_recommended_only: bool,
|
||||
pub state: VersionState,
|
||||
|
||||
pub progress_bar: Controller<super::ProgressBar>
|
||||
pub progress_bar: AsyncController<super::ProgressBar>
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
|
@ -40,8 +41,8 @@ pub enum AppMsg {
|
|||
SetState(VersionState)
|
||||
}
|
||||
|
||||
#[relm4::component(pub)]
|
||||
impl SimpleComponent for ComponentVersion {
|
||||
#[relm4::component(async, pub)]
|
||||
impl SimpleAsyncComponent for ComponentVersion {
|
||||
type Init = (super::ComponentsListVersion, PathBuf);
|
||||
type Input = AppMsg;
|
||||
type Output = super::group::AppMsg;
|
||||
|
@ -73,11 +74,12 @@ impl SimpleComponent for ComponentVersion {
|
|||
}
|
||||
}
|
||||
|
||||
fn init(
|
||||
#[allow(clippy::redundant_clone)]
|
||||
async fn init(
|
||||
init: Self::Init,
|
||||
root: &Self::Root,
|
||||
_sender: ComponentSender<Self>,
|
||||
) -> ComponentParts<Self> {
|
||||
root: Self::Root,
|
||||
_sender: AsyncComponentSender<Self>,
|
||||
) -> AsyncComponentParts<Self> {
|
||||
let mut model = ComponentVersion {
|
||||
name: init.0.name,
|
||||
title: init.0.title,
|
||||
|
@ -102,16 +104,16 @@ impl SimpleComponent for ComponentVersion {
|
|||
};
|
||||
|
||||
// Set progress bar width
|
||||
model.progress_bar.widgets().progress_bar.set_width_request(200);
|
||||
model.progress_bar.widget().set_width_request(200);
|
||||
|
||||
let widgets = view_output!();
|
||||
|
||||
widgets.row.add_suffix(model.progress_bar.widget());
|
||||
|
||||
ComponentParts { model, widgets }
|
||||
AsyncComponentParts { model, widgets }
|
||||
}
|
||||
|
||||
fn update(&mut self, msg: Self::Input, sender: ComponentSender<Self>) {
|
||||
async fn update(&mut self, msg: Self::Input, sender: AsyncComponentSender<Self>) {
|
||||
tracing::debug!("Called component version [{}] event: {:?} (state = {:?})", self.title, msg, self.state);
|
||||
|
||||
match msg {
|
||||
|
|
|
@ -1,4 +1,9 @@
|
|||
use relm4::{prelude::*, actions::*, MessageBroker};
|
||||
use relm4::{
|
||||
prelude::*,
|
||||
component::*,
|
||||
actions::*,
|
||||
MessageBroker
|
||||
};
|
||||
|
||||
use gtk::prelude::*;
|
||||
use adw::prelude::*;
|
||||
|
@ -16,7 +21,7 @@ relm4::new_stateless_action!(ConfigFile, WindowActionGroup, "config_file");
|
|||
|
||||
relm4::new_stateless_action!(About, WindowActionGroup, "about");
|
||||
|
||||
static mut PREFERENCES_WINDOW: Option<Controller<PreferencesApp>> = None;
|
||||
static mut PREFERENCES_WINDOW: Option<AsyncController<PreferencesApp>> = None;
|
||||
static mut ABOUT_DIALOG: Option<Controller<AboutDialog>> = None;
|
||||
|
||||
pub struct App {
|
||||
|
@ -193,11 +198,11 @@ impl SimpleComponent for App {
|
|||
|
||||
match msg {
|
||||
AppMsg::OpenPreferences => unsafe {
|
||||
PREFERENCES_WINDOW.as_ref().unwrap_unchecked().widgets().preferences_window.show();
|
||||
PREFERENCES_WINDOW.as_ref().unwrap_unchecked().widget().show();
|
||||
}
|
||||
|
||||
AppMsg::ClosePreferences => unsafe {
|
||||
PREFERENCES_WINDOW.as_ref().unwrap_unchecked().widgets().preferences_window.hide();
|
||||
PREFERENCES_WINDOW.as_ref().unwrap_unchecked().widget().hide();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
use relm4::prelude::*;
|
||||
use relm4::component::*;
|
||||
|
||||
use gtk::prelude::*;
|
||||
use adw::prelude::*;
|
||||
|
@ -11,8 +12,8 @@ use crate::i18n::tr;
|
|||
use crate::CONFIG;
|
||||
|
||||
pub struct App {
|
||||
wine_components: Controller<ComponentsList>,
|
||||
dxvk_components: Controller<ComponentsList>,
|
||||
wine_components: AsyncController<ComponentsList>,
|
||||
dxvk_components: AsyncController<ComponentsList>,
|
||||
|
||||
downloaded_wine_versions: Vec<wine::Version>,
|
||||
downloaded_dxvk_versions: Vec<dxvk::Version>,
|
||||
|
@ -29,13 +30,14 @@ pub enum AppMsg {
|
|||
UpdateDownloadedDxvk
|
||||
}
|
||||
|
||||
#[relm4::component(pub)]
|
||||
impl SimpleComponent for App {
|
||||
#[relm4::component(async, pub)]
|
||||
impl SimpleAsyncComponent for App {
|
||||
type Init = gtk::Window;
|
||||
type Input = AppMsg;
|
||||
type Output = ();
|
||||
|
||||
view! {
|
||||
#[root]
|
||||
preferences_window = adw::PreferencesWindow {
|
||||
set_title: Some(&tr("preferences")),
|
||||
set_default_size: (700, 560),
|
||||
|
@ -102,11 +104,12 @@ impl SimpleComponent for App {
|
|||
}
|
||||
}
|
||||
|
||||
fn init(
|
||||
#[allow(clippy::redundant_clone)]
|
||||
async fn init(
|
||||
parent: Self::Init,
|
||||
root: &Self::Root,
|
||||
sender: ComponentSender<Self>,
|
||||
) -> ComponentParts<Self> {
|
||||
root: Self::Root,
|
||||
sender: AsyncComponentSender<Self>,
|
||||
) -> AsyncComponentParts<Self> {
|
||||
tracing::info!("Initializing preferences window");
|
||||
|
||||
let model = App {
|
||||
|
@ -146,10 +149,10 @@ impl SimpleComponent for App {
|
|||
sender.input(AppMsg::UpdateDownloadedWine);
|
||||
sender.input(AppMsg::UpdateDownloadedDxvk);
|
||||
|
||||
ComponentParts { model, widgets }
|
||||
AsyncComponentParts { model, widgets }
|
||||
}
|
||||
|
||||
fn update(&mut self, msg: Self::Input, _sender: ComponentSender<Self>) {
|
||||
async fn update(&mut self, msg: Self::Input, _sender: AsyncComponentSender<Self>) {
|
||||
tracing::debug!("Called preferences window event: {:?}", msg);
|
||||
|
||||
match msg {
|
||||
|
|
Loading…
Add table
Reference in a new issue