From e7c1ba9217ab0415a7449c12a52531eeb652a5fb Mon Sep 17 00:00:00 2001 From: heliguy4599 Date: Thu, 10 Oct 2024 18:09:07 -0400 Subject: [PATCH] Setup UI for snapshot page app install --- src/snapshot_page/snapshot_page.blp | 6 +++++- src/snapshot_page/snapshot_page.py | 15 +++++++++++++-- src/snapshot_page/snapshots_list_page.py | 3 +++ 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/src/snapshot_page/snapshot_page.blp b/src/snapshot_page/snapshot_page.blp index 245026e..9e10549 100644 --- a/src/snapshot_page/snapshot_page.blp +++ b/src/snapshot_page/snapshot_page.blp @@ -221,7 +221,11 @@ Popover more_popover { styles ["menu"] ListBox more_menu { Label new_snapshots { - label: _("New Snapshots"); + label: _("Snapshot Apps"); + halign: start; + } + Label install_from_snapshots { + label: _("Install Apps"); halign: start; } Label apply_snapshots { diff --git a/src/snapshot_page/snapshot_page.py b/src/snapshot_page/snapshot_page.py index df8a4ee..67f977e 100644 --- a/src/snapshot_page/snapshot_page.py +++ b/src/snapshot_page/snapshot_page.py @@ -78,6 +78,7 @@ class SnapshotPage(Adw.BreakpointBin): more_menu = gtc() new_snapshots = gtc() apply_snapshots = gtc() + install_from_snapshots = gtc() trash_snapshots = gtc() # Referred to in the main window @@ -322,8 +323,13 @@ class SnapshotPage(Adw.BreakpointBin): i = 0 while row := self.more_menu.get_row_at_index(i): i += 1 - if row.get_child() is self.new_snapshots: - row.set_visible(total_active > 0) + match row.get_child(): + case self.new_snapshots: + row.set_visible(total_active > 0 and total_leftover == 0) + case self.apply_snapshots: + row.set_visible(total_active > 0 and total_leftover == 0) + case self.install_from_snapshots: + row.set_visible(total_active == 0 and total_leftover > 0) def select_copy_handler(self, *args): to_copy = "" @@ -441,6 +447,9 @@ class SnapshotPage(Adw.BreakpointBin): dialog.connect("response", self.on_apply_response) dialog.present(HostInfo.main_window) + def install_handler(self): + print("install") + def select_trash_handler(self): def on_response(dialog, response): to_trash = [] @@ -476,6 +485,8 @@ class SnapshotPage(Adw.BreakpointBin): self.select_new_handler() case self.apply_snapshots: self.select_apply_handler() + case self.install_from_snapshots: + self.install_handler() case self.trash_snapshots: self.select_trash_handler() diff --git a/src/snapshot_page/snapshots_list_page.py b/src/snapshot_page/snapshots_list_page.py index d009840..e17bb11 100644 --- a/src/snapshot_page/snapshots_list_page.py +++ b/src/snapshot_page/snapshots_list_page.py @@ -18,11 +18,14 @@ class SnapshotsListPage(Adw.NavigationPage): new_button = gtc() def thread(self, *args): + is_leftover = type(self.package_or_folder) is str for snapshot in os.listdir(folder := f"{self.snapshots_path}{self.current_folder}/"): if snapshot.endswith(".json"): continue row = SnapshotBox(self, snapshot, folder, self.toast_overlay) + row.apply_button.set_sensitive(not is_leftover) + row.apply_button.set_tooltip_text(_("This App is not Installed")) self.snapshots_rows.append(row) def callback(self, *args):