diff --git a/Cargo.toml b/Cargo.toml index 5823269..a21abc5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "anime-game-launcher" -version = "0.3.0" +version = "0.3.1" description = "Anime Game launcher" authors = ["Nikita Podvirnyy "] license = "GPL-3.0" diff --git a/assets/ui/first_run.blp b/assets/ui/first_run.blp index 8f42701..156f909 100644 --- a/assets/ui/first_run.blp +++ b/assets/ui/first_run.blp @@ -250,6 +250,7 @@ Adw.ApplicationWindow window { Gtk.Button { label: "Pause"; sensitive: false; + tooltip-text: "Work in progress"; } } } diff --git a/assets/ui/main.blp b/assets/ui/main.blp index 83e612b..6c3a781 100644 --- a/assets/ui/main.blp +++ b/assets/ui/main.blp @@ -103,6 +103,7 @@ Adw.ApplicationWindow window { Gtk.Button { label: "Pause"; sensitive: false; + tooltip-text: "Work in progress"; } } } diff --git a/src/main.rs b/src/main.rs index 44960c2..f805dbe 100644 --- a/src/main.rs +++ b/src/main.rs @@ -26,7 +26,8 @@ async fn main() { .expect("Failed to register resources"); // Set application's title - gtk::glib::set_prgname(Some("An Anime Game Launcher")); + gtk::glib::set_application_name("An Anime Game Launcher"); + gtk::glib::set_program_name(Some("An Anime Game Launcher")); // Create app let application = gtk::Application::new( diff --git a/src/ui/main.rs b/src/ui/main.rs index 2c61241..927a7fe 100644 --- a/src/ui/main.rs +++ b/src/ui/main.rs @@ -9,6 +9,7 @@ use std::cell::Cell; use std::io::Error; use anime_game_core::prelude::*; +use wait_not_await::Await; use crate::ui::*; @@ -293,8 +294,9 @@ impl App { ProgressUpdateResult::Updated => (), ProgressUpdateResult::Error(msg, err) => { - this.update(Actions::ToastError(Rc::new((msg, err)))).unwrap(); - this.update(Actions::HideProgressBar).unwrap(); + this.widgets.progress_bar.hide(); + + this.toast_error(msg, err); } ProgressUpdateResult::Finished => { @@ -304,7 +306,8 @@ impl App { config::update(config); - this.update(Actions::HideProgressBar).unwrap(); + this.widgets.progress_bar.hide(); + this.update_state(); } } @@ -345,7 +348,9 @@ impl App { this.widgets.launch_game.set_sensitive(false); if let Err(err) = prefix.update(&config.game.wine.builds, wine) { - this.toast_error("Failed to create wine prefix", err); + this.update(Actions::ToastError(Rc::new(( + String::from("Failed to create wine prefix"), err + )))).unwrap(); } this.widgets.launch_game.set_sensitive(true); @@ -373,14 +378,29 @@ impl App { ProgressUpdateResult::Updated => (), ProgressUpdateResult::Error(msg, err) => { - this.update(Actions::ToastError(Rc::new((msg, err)))).unwrap(); - this.update(Actions::HideProgressBar).unwrap(); + this.widgets.progress_bar.hide(); + + this.toast_error(msg, err); } ProgressUpdateResult::Finished => { - this.update(Actions::HideProgressBar).unwrap(); + this.widgets.progress_bar.hide(); - this.update_state(); + let this = this.clone(); + + this.update_state().then(move |result| { + if let Ok(state) = result { + match state { + LauncherState::VoiceUpdateAvailable(_) | + LauncherState::VoiceNotInstalled(_) | + LauncherState::GameUpdateAvailable(_) | + LauncherState::GameNotInstalled(_) => { + this.update(Actions::PerformButtonEvent).unwrap(); + }, + _ => () + } + } + }); } } @@ -497,27 +517,37 @@ impl App { self.values.set(values); } - pub fn update_state(&self) { + pub fn update_state(&self) -> Await> { let this = self.clone(); + let (send, recv) = std::sync::mpsc::channel(); + this.widgets.status_page.show(); this.widgets.launcher_content.hide(); std::thread::spawn(move || { match LauncherState::get(Some(&this.widgets.status_page)) { Ok(state) => { - this.set_state(state); + this.set_state(state.clone()); this.widgets.status_page.hide(); this.widgets.launcher_content.show(); + + send.send(Ok(state)).unwrap(); }, Err(err) => { + send.send(Err(err.to_string())).unwrap(); + glib::MainContext::default().invoke(move || { this.toast_error("Failed to get initial launcher state", err); }); } } }); + + Await::new(move || { + recv.recv().unwrap() + }) } }