Sort snapshot list by date and time created

This commit is contained in:
Heliguy
2024-09-23 14:46:03 -04:00
parent 025c3f0c0c
commit 9ec552dd38
2 changed files with 8 additions and 1 deletions

View File

@@ -123,7 +123,8 @@ class SnapshotBox(Gtk.Box):
self.parent_page = parent_page
self.folder = folder
self.snapshots_path = snapshots_path
date_data = GLib.DateTime.new_from_unix_local(int(split_folder[0])).format("%x %X")
self.epoch = int(split_folder[0])
date_data = GLib.DateTime.new_from_unix_local(self.epoch).format("%x %X")
self.date.set_label(date_data)
self.version.set_label(_("Version: {}").format(split_folder[1].replace(".tar.zst", "")))
self.json_path = f"{snapshots_path}{folder.replace('tar.zst', 'json')}"

View File

@@ -70,6 +70,11 @@ class SnapshotsListPage(Adw.NavigationPage):
dialog = NewSnapshotDialog(self.parent_page, self.parent_page.snapshotting_status, self.on_done, self.package_or_folder)
dialog.create_button.connect("clicked", lambda *_: self.parent_page.status_stack.set_visible_child(self.parent_page.snapshotting_view))
dialog.present(HostInfo.main_window)
def sort_func(self, row1, row2):
row1 = row1.get_child()
row2 = row2.get_child()
return row1.epoch > row2.epoch
def __init__(self, parent_page, **kwargs):
super().__init__(**kwargs)
@@ -86,3 +91,4 @@ class SnapshotsListPage(Adw.NavigationPage):
self.new_button.connect("clicked", self.on_new)
# Apply
self.listbox.set_sort_func(self.sort_func)