From 8814c0f53d39ea28b20ce5c2e150f4e819fe3fa0 Mon Sep 17 00:00:00 2001 From: heliguy Date: Fri, 1 Sep 2023 03:22:15 -0400 Subject: [PATCH] Added please wait screen Added a please wait screen for flatpak uninstalls --- src/window.blp | 7 ++++++- src/window.py | 35 ++++++++++++++++++++--------------- 2 files changed, 26 insertions(+), 16 deletions(-) diff --git a/src/window.blp b/src/window.blp index 8322920..c2181dd 100644 --- a/src/window.blp +++ b/src/window.blp @@ -93,8 +93,13 @@ template FlattoolGuiWindow : Adw.ApplicationWindow { } Adw.StatusPage no_flatpaks { icon-name: "error-symbolic"; - description: _("Flattool cannot see the list of installed flatpaks or the system has no flatpaks installed."); title: _("No Flatpaks Found"); + description: _("Flattool cannot see the list of installed flatpaks or the system has no flatpaks installed."); + } + Adw.StatusPage uninstall_please_wait { + icon-name: "user-trash-symbolic"; + title: _("Please Wait"); + description: _("Flattool is uninstalling the selected apps. This could take a while."); } } } diff --git a/src/window.py b/src/window.py index fc4f6d4..e12473e 100644 --- a/src/window.py +++ b/src/window.py @@ -40,6 +40,8 @@ class FlattoolGuiWindow(Adw.ApplicationWindow): batch_uninstall_button = Gtk.Template.Child() batch_clean_button = Gtk.Template.Child() batch_copy_button = Gtk.Template.Child() + uninstall_please_wait = Gtk.Template.Child() + main_box = Gtk.Template.Child() clipboard = Gdk.Display.get_default().get_clipboard() host_home = str(pathlib.Path.home()) @@ -73,21 +75,6 @@ class FlattoolGuiWindow(Adw.ApplicationWindow): except subprocess.CalledProcessError: return(2) - def uninstall_response(self, widget, response_id, _c, index): - ref = self.host_flatpaks[index][8] - name = self.host_flatpaks[index][0] - command = ['flatpak-spawn', '--host', 'flatpak', 'remove', ref, '-y'] - if response_id == "cancel": - return(1) - if response_id == "purge": - command.append('--delete-data') - try: - subprocess.run(command, capture_output=True, check=True) - self.toast_overlay.add_toast(Adw.Toast.new(_(f"Uninstalled {name}"))) - self.refresh_list_of_flatpaks(self, False) - except subprocess.CalledProcessError: - self.toast_overlay.add_toast(Adw.Toast.new(_(f"Error while trying to uninstall {name}"))) - def get_size_format(self, b): factor=1024 suffix="B" @@ -120,7 +107,25 @@ class FlattoolGuiWindow(Adw.ApplicationWindow): return 0 return total + def uninstall_response(self, widget, response_id, _c, index): + ref = self.host_flatpaks[index][8] + name = self.host_flatpaks[index][0] + command = ['flatpak-spawn', '--host', 'flatpak', 'remove', ref, '-y'] + if response_id == "cancel": + self.main_stack.set_visible_child(self.main_box) + return(1) + if response_id == "purge": + command.append('--delete-data') + try: + subprocess.run(command, capture_output=True, check=True) + self.toast_overlay.add_toast(Adw.Toast.new(_(f"Uninstalled {name}"))) + self.refresh_list_of_flatpaks(self, False) + except subprocess.CalledProcessError: + self.toast_overlay.add_toast(Adw.Toast.new(_(f"Error while trying to uninstall {name}"))) + self.main_stack.set_visible_child(self.main_box) + def uninstall_flatpak(self, _widget, index): + self.main_stack.set_visible_child(self.uninstall_please_wait) name = self.host_flatpaks[index][0] id = self.host_flatpaks[index][2] dialog = Adw.MessageDialog.new(self, _(f"Uninstall {name}?"), _("The app will be removed from your system."))