Probably fixed startup gtk errors

This commit is contained in:
Observer KRypt0n_ 2022-07-30 09:20:11 +02:00
parent 4c5a38dfc2
commit cb1125dfbc
No known key found for this signature in database
GPG key ID: 844DA47BA25FE1E2
2 changed files with 14 additions and 14 deletions

View file

@ -39,7 +39,7 @@ impl Default for LauncherState {
}
impl LauncherState {
pub fn get(status_page: Option<&libadwaita::StatusPage>) -> std::io::Result<Self> {
pub fn get<T: Fn(&str)>(status: T) -> std::io::Result<Self> {
let config = config::get()?;
// Check wine existance
@ -55,18 +55,14 @@ impl LauncherState {
}
// Check game installation status
if let Some(status_page) = &status_page {
status_page.set_description(Some("Updating game info..."));
}
status("Updating game info...");
let game = Game::new(&config.game.path);
let diff = game.try_get_diff()?;
Ok(match diff {
VersionDiff::Latest(_) => {
if let Some(status_page) = &status_page {
status_page.set_description(Some("Updating voice info..."));
}
status("Updating voice info...");
for voice_package in &config.game.voices {
let mut voice_package = VoicePackage::with_locale(match VoiceLocale::from_str(voice_package) {
@ -74,9 +70,7 @@ impl LauncherState {
None => return Err(Error::new(ErrorKind::Other, format!("Incorrect voice locale \"{}\" specified in the config", voice_package)))
})?;
if let Some(status_page) = &status_page {
status_page.set_description(Some(format!("Updating voice info ({})...", voice_package.locale().to_name()).as_str()));
}
status(format!("Updating voice info ({})...", voice_package.locale().to_name()).as_str());
// Replace voice package struct with the one constructed in the game's folder
// so it'll properly calculate its difference instead of saying "not installed"
@ -97,9 +91,7 @@ impl LauncherState {
}
}
if let Some(status_page) = &status_page {
status_page.set_description(Some("Updating patch info..."));
}
status("Updating patch info...");
let patch = Patch::try_fetch(config.patch.servers.clone())?;

View file

@ -530,8 +530,16 @@ impl App {
this.widgets.status_page.show();
this.widgets.launcher_content.hide();
let (sender, receiver) = glib::MainContext::channel::<String>(glib::PRIORITY_DEFAULT);
receiver.attach(None, clone!(@strong this.widgets.status_page as status_page => move |description| {
status_page.set_description(Some(&description));
glib::Continue(true)
}));
std::thread::spawn(move || {
match LauncherState::get(Some(&this.widgets.status_page)) {
match LauncherState::get(move |status| sender.send(status.to_string()).unwrap()) {
Ok(state) => {
this.set_state(state.clone());