From 7045edb78a46a46abc650b3b5b8d78a65932c6bb Mon Sep 17 00:00:00 2001 From: heliguy4599 Date: Fri, 11 Oct 2024 16:10:37 -0400 Subject: [PATCH] Add refresh lockout to package uninstalls --- src/host_info.py | 8 +++++++- src/packages_page/packages_page.py | 2 ++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/host_info.py b/src/host_info.py index 72c66d8..6e54eb5 100644 --- a/src/host_info.py +++ b/src/host_info.py @@ -98,10 +98,16 @@ class Flatpak: Gio.Task.new(None, None, callback).run_in_thread(thread) - def uninstall(self, callback=None): + def uninstall(self, callee_callback=None): self.failed_uninstall = None + + def callback(*args): + HostInfo.main_window.remove_refresh_lockout("uninstalling packages") + if not callee_callback is None: + callee_callback() def thread(*args): + HostInfo.main_window.add_refresh_lockout("uninstalling packages") cmd = ['flatpak-spawn', '--host', 'flatpak', 'uninstall', '-y', self.info["ref"]] installation = self.info["installation"] if installation == "system" or installation == "user": diff --git a/src/packages_page/packages_page.py b/src/packages_page/packages_page.py index 839075d..ca13a7f 100644 --- a/src/packages_page/packages_page.py +++ b/src/packages_page/packages_page.py @@ -243,6 +243,7 @@ class PackagesPage(Adw.BreakpointBin): GLib.idle_add(lambda *_: self.set_status(self.uninstalling)) error = [None] def thread(*args): + HostInfo.main_window.add_refresh_lockout("batch uninstalling packages") cmd = ['flatpak-spawn', '--host', 'flatpak', 'uninstall', '-y'] to_trash = [] for row in self.selected_rows: @@ -261,6 +262,7 @@ class PackagesPage(Adw.BreakpointBin): def callback(*args): self.main_window.refresh_handler() + HostInfo.main_window.remove_refresh_lockout("batch uninstalling packages") if err := error[0]: details = err.stderr if type(err) == subprocess.CalledProcessError else str(err) GLib.idle_add(lambda *args: self.packages_toast_overlay.add_toast(ErrorToast(_("Could not uninstall packages"), details).toast))