Added async preferences opening

May show white screen with no controls for unknown reason
This commit is contained in:
Observer KRypt0n_ 2022-07-14 14:53:51 +02:00
parent 9817cbd989
commit 8c0685836f
No known key found for this signature in database
GPG key ID: 844DA47BA25FE1E2
9 changed files with 29 additions and 15 deletions

View file

@ -17,4 +17,4 @@ serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0" serde_json = "1.0"
dirs = "4.0.0" dirs = "4.0.0"
# tokio = { version = "1.19.2", features = ["rt", "rt-multi-thread", "macros"]} tokio = { version = "1.19.2", features = ["rt", "rt-multi-thread", "macros"] }

@ -1 +1 @@
Subproject commit 9fd14137eaf494f2e6647c12f854c6cd0c20ebd2 Subproject commit 527a8d12e6e9fcea7bb696254657c937cb2e7f86

View file

@ -1,5 +1,10 @@
{ {
"vanilla": [ "vanilla": [
{
"version": "1.10.2",
"uri": "https://github.com/doitsujin/dxvk/releases/download/v1.10.2/dxvk-1.10.2.tar.gz",
"recommended": true
},
{ {
"version": "1.10.1", "version": "1.10.1",
"uri": "https://github.com/doitsujin/dxvk/releases/download/v1.10.1/dxvk-1.10.1.tar.gz", "uri": "https://github.com/doitsujin/dxvk/releases/download/v1.10.1/dxvk-1.10.1.tar.gz",

@ -1 +1 @@
Subproject commit 75475d1a457dce5fc8d66a2156e4489fe4204420 Subproject commit 664fa2250b02f64f2c1d8afd82801ab01e353c78

View file

@ -2,3 +2,4 @@ pub mod consts;
pub mod config; pub mod config;
pub mod game; pub mod game;
pub mod dxvk; pub mod dxvk;
pub mod tasks;

8
src/lib/tasks.rs Normal file
View file

@ -0,0 +1,8 @@
use std::future::Future;
pub fn run<T>(future: T) where
T: Future + Send + 'static,
<T as Future>::Output: Send
{
tokio::task::spawn(future);
}

View file

@ -8,8 +8,8 @@ pub mod lib;
use ui::*; use ui::*;
// #[tokio::main] #[tokio::main]
fn main() { async fn main() {
gtk::init().expect("GTK initialization failed"); gtk::init().expect("GTK initialization failed");
adw::init(); adw::init();

View file

@ -13,6 +13,7 @@ use super::preferences::PreferencesStack;
use super::ToastError; use super::ToastError;
use crate::lib::game; use crate::lib::game;
use crate::lib::tasks;
/// This structure is used to describe widgets used in application /// This structure is used to describe widgets used in application
/// ///
@ -154,21 +155,20 @@ impl App {
let values = this.values.take(); let values = this.values.take();
// Some debug output // Some debug output
println!("[update] action: {:?}, values: {:?}", &action, &values); println!("[main] [update] action: {:?}, values: {:?}", &action, &values);
match action { match action {
Actions::OpenPreferencesPage => { Actions::OpenPreferencesPage => {
this.widgets.leaflet.set_visible_child_name("preferences_page"); this.widgets.leaflet.set_visible_child_name("preferences_page");
tasks::run(clone!(@strong this => async move {
if let Err(err) = this.widgets.preferences_stack.update() { if let Err(err) = this.widgets.preferences_stack.update() {
glib::MainContext::default().invoke(move || {
this.update(Actions::PreferencesGoBack);
this.toast_error("Failed to update preferences", err); this.toast_error("Failed to update preferences", err);
});
} }
}));
/*tokio::task::spawn(async {
if let Err(err) = this.widgets.preferences_stack.update().await {
// this.update(Actions::ToastError(Rc::new((String::from("Failed to update preferences"), err))));
}
});*/
} }
Actions::PreferencesGoBack => { Actions::PreferencesGoBack => {

View file

@ -171,7 +171,7 @@ impl App {
let values = this.values.take(); let values = this.values.take();
// Some debug output // Some debug output
println!("[update] action: {:?}, values: {:?}", &action, &values); println!("[general page] [update] action: {:?}, values: {:?}", &action, &values);
match action { match action {
Actions::DownloadDXVK(i) => { Actions::DownloadDXVK(i) => {