From fb19347a62919fc9b04e307b4a68bec561aa9399 Mon Sep 17 00:00:00 2001 From: heliguy Date: Thu, 31 Aug 2023 23:18:59 -0400 Subject: [PATCH] The uninstall app message dialog now hides the trash data response when no data is present --- src/window.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/window.py b/src/window.py index e02710b..af2fddf 100644 --- a/src/window.py +++ b/src/window.py @@ -121,14 +121,18 @@ class FlattoolGuiWindow(Adw.ApplicationWindow): def uninstall_flatpak(self, _widget, index): name = self.host_flatpaks[index][0] - dialog = Adw.MessageDialog.new(self, _(f"Uninstall {name}?")) - dialog.set_body(_("The app will be removed from your system but its user data will be preserved")) + id = self.host_flatpaks[index][2] + dialog = Adw.MessageDialog.new(self, _(f"Uninstall {name}?"), _("The app will be removed from your system.")) dialog.set_close_response("cancel") dialog.add_response("cancel", _("Cancel")) dialog.add_response("continue", _("Uninstall")) - dialog.add_response("purge", _("Uninstall and Trash Data")) dialog.set_response_appearance("continue", Adw.ResponseAppearance.DESTRUCTIVE) - dialog.set_response_appearance("purge", Adw.ResponseAppearance.DESTRUCTIVE) + + if os.path.exists(f"{self.user_data_path}{id}"): + dialog.set_body(_("The app will be removed from your system. Optionally, you can also trash its user data.")) + dialog.add_response("purge", _("Uninstall and Trash Data")) + dialog.set_response_appearance("purge", Adw.ResponseAppearance.DESTRUCTIVE) + dialog.connect("response", self.uninstall_response, dialog.choose_finish, index) Gtk.Window.present(dialog)