Add refresh lockout to package installs

This commit is contained in:
heliguy4599
2024-10-11 13:28:29 -04:00
parent c494e7b2e2
commit 45fb11efa2

View File

@@ -1,4 +1,5 @@
from gi.repository import Adw, Gtk, GLib, Gio from gi.repository import Adw, Gtk, GLib, Gio
from .host_info import HostInfo
import subprocess, re import subprocess, re
class PackageInstallWorker: class PackageInstallWorker:
@@ -106,6 +107,7 @@ class PackageInstallWorker:
def on_done(this, *args): def on_done(this, *args):
this.process = None this.process = None
this.cancelled = False this.cancelled = False
HostInfo.main_window.remove_refresh_lockout("installing packages")
if not this.loading_status is None: if not this.loading_status is None:
this.loading_status.progress_bar.set_fraction(0.0) this.loading_status.progress_bar.set_fraction(0.0)
@@ -114,8 +116,6 @@ class PackageInstallWorker:
@classmethod @classmethod
def on_error(this, user_facing_label, error_message): def on_error(this, user_facing_label, error_message):
print("\nPackageInstallWorker error:", user_facing_label)
print(error_message, "\n")
if not this.error_callback is None: if not this.error_callback is None:
this.error_callback(user_facing_label, error_message) this.error_callback(user_facing_label, error_message)
@@ -135,5 +135,6 @@ class PackageInstallWorker:
this.on_error(_("Could not install packages"), _("No packages were asked to be installed.")) this.on_error(_("Could not install packages"), _("No packages were asked to be installed."))
return False return False
HostInfo.main_window.add_refresh_lockout("installing packages")
Gio.Task.new(None, None, this.on_done).run_in_thread(lambda *_: this.install_thread()) Gio.Task.new(None, None, this.on_done).run_in_thread(lambda *_: this.install_thread())
return True return True