From 9fa2bb6e9ee03103eda1aca33525ce1207e6004e Mon Sep 17 00:00:00 2001 From: Heliguy Date: Mon, 23 Sep 2024 15:22:33 -0400 Subject: [PATCH] open the same package page again instead of resetting to the first row, if there are still snapshots left to delete for the current app --- src/snapshot_page/snapshot_box.py | 3 +-- src/snapshot_page/snapshots_list_page.blp | 2 +- src/snapshot_page/snapshots_list_page.py | 11 +++++++++-- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/snapshot_page/snapshot_box.py b/src/snapshot_page/snapshot_box.py index 88a14ad..6586387 100644 --- a/src/snapshot_page/snapshot_box.py +++ b/src/snapshot_page/snapshot_box.py @@ -94,8 +94,7 @@ class SnapshotBox(Gtk.Box): self.toast_overlay.add_toast(ErrorToast(_("Could not trash snapshot"), error[0]).toast) return - self.parent_page.parent_page.start_loading() - self.parent_page.parent_page.end_loading() + self.parent_page.on_trash() self.toast_overlay.add_toast(Adw.Toast.new(_("Trashed snapshot"))) def on_response(_, response): diff --git a/src/snapshot_page/snapshots_list_page.blp b/src/snapshot_page/snapshots_list_page.blp index 2e27e50..3d8187c 100644 --- a/src/snapshot_page/snapshots_list_page.blp +++ b/src/snapshot_page/snapshots_list_page.blp @@ -31,7 +31,7 @@ template $SnapshotsListPage : Adw.NavigationPage { } [bottom] ActionBar { - revealed: bind new_button.visible; + revealed: bind new_button.sensitive; [center] Button new_button { margin-top: 3; diff --git a/src/snapshot_page/snapshots_list_page.py b/src/snapshot_page/snapshots_list_page.py index 988985b..8b314ea 100644 --- a/src/snapshot_page/snapshots_list_page.py +++ b/src/snapshot_page/snapshots_list_page.py @@ -26,6 +26,10 @@ class SnapshotsListPage(Adw.NavigationPage): self.snapshots_rows.append(row) def callback(self, *args): + if len(self.snapshots_rows) == 0: + self.parent_page.refresh() + return + for i, row in enumerate(self.snapshots_rows): self.listbox.append(row) self.listbox.get_row_at_index(i).set_activatable(False) @@ -39,11 +43,11 @@ class SnapshotsListPage(Adw.NavigationPage): if type(package_or_folder) is str: self.set_title(package_or_folder) folder = package_or_folder - self.new_button.set_visible(False) + self.new_button.set_sensitive(False) else: folder = package_or_folder.info["id"] self.set_title(_("{} Snapshots").format(package_or_folder.info["name"])) - self.new_button.set_visible(os.path.exists(package_or_folder.data_path)) + self.new_button.set_sensitive(os.path.exists(package_or_folder.data_path)) self.current_folder = folder self.snapshots_rows.clear() @@ -75,6 +79,9 @@ class SnapshotsListPage(Adw.NavigationPage): row1 = row1.get_child() row2 = row2.get_child() return row1.epoch > row2.epoch + + def on_trash(self): + self.set_snapshots(self.package_or_folder, refresh=True) def __init__(self, parent_page, **kwargs): super().__init__(**kwargs)