Setup UI for snapshot page app install

This commit is contained in:
heliguy4599
2024-10-10 18:09:07 -04:00
parent 28f7d42a2f
commit e7c1ba9217
3 changed files with 21 additions and 3 deletions

View File

@@ -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 {

View File

@@ -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()

View File

@@ -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):