From 230f67129214e9d79e25c0e7960120d79a0d2452 Mon Sep 17 00:00:00 2001 From: bleakgrey Date: Sat, 3 Mar 2018 21:59:09 +0300 Subject: [PATCH] Don't hang when installing --- src/TransporterWindow.vala | 2 +- src/View/InstallView.vala | 18 ++++++++++++------ src/WormholeInterface.vala | 2 ++ 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/src/TransporterWindow.vala b/src/TransporterWindow.vala index 12b5ba6..6eb0d53 100644 --- a/src/TransporterWindow.vala +++ b/src/TransporterWindow.vala @@ -114,7 +114,7 @@ public class TransporterWindow: Gtk.Dialog { updateWindow (); } - private void replaceScreen(Widget screen){ + public void replaceScreen(Widget screen){ var box = get_content_area () as Gtk.Box; box.remove (currScreen); diff --git a/src/View/InstallView.vala b/src/View/InstallView.vala index d575ac0..ef66ca2 100644 --- a/src/View/InstallView.vala +++ b/src/View/InstallView.vala @@ -5,19 +5,25 @@ public class InstallView : ReceiveView { public InstallView(TransporterWindow window, WormholeInterface wormhole){ base (wormhole); this.window = window; - Timeout.add_seconds (1, install); } protected override void setup(){ title_label.set_text (_("Preparing Transporter")); subtitle_label.set_text (_("Installing magic-wormhole")); entry.hide (); - } - private bool install(){ - if(wormhole.install ()) - window.addScreen (new WelcomeView (window)); - return false; + wormhole.finished.connect(() => { + window.replaceScreen (new WelcomeView (window)); + }); + + if(Thread.supported ()){ + var thread = new Thread.try ("InstallThread", () => { + wormhole.install (); + return false; + }); + } + else + wormhole.install (); } } \ No newline at end of file diff --git a/src/WormholeInterface.vala b/src/WormholeInterface.vala index df7c3a1..349aeca 100644 --- a/src/WormholeInterface.vala +++ b/src/WormholeInterface.vala @@ -67,6 +67,8 @@ public class WormholeInterface : Object { var found = bin_present (); if(!found) errored(_("Couldn't install magic-wormhole automatically."), _("Installation Error"), true); + else + finished (); return found; }