mirror of
https://github.com/morgan9e/warehouse
synced 2026-04-14 00:04:08 +09:00
Spruce up the UI for applying snapshots, and ask for confirmation
This commit is contained in:
@@ -98,6 +98,7 @@ class NewSnapshotDialog(Adw.Dialog):
|
||||
|
||||
def on_create(self, button):
|
||||
self.loading_status.title_label.set_label(_("Creating Snapshot"))
|
||||
self.loading_status.progress_bar.set_fraction(0.0)
|
||||
self.snapshot_page.status_stack.set_visible_child(self.snapshot_page.snapshotting_view)
|
||||
self.workers.clear()
|
||||
for row in self.selected_rows:
|
||||
@@ -114,6 +115,7 @@ class NewSnapshotDialog(Adw.Dialog):
|
||||
self.workers.append(worker)
|
||||
worker.compress()
|
||||
|
||||
self.loading_status.progress_label.set_visible(len(self.workers) > 1)
|
||||
GLib.timeout_add(200, self.get_total_fraction)
|
||||
self.close()
|
||||
|
||||
|
||||
@@ -113,18 +113,35 @@ class SnapshotBox(Gtk.Box):
|
||||
|
||||
def get_fraction(self):
|
||||
loading_status = self.snapshot_page.snapshotting_status
|
||||
loading_status.title_label.set_label(_("Applying Snapshot"))
|
||||
loading_status.progress_bar.set_fraction(self.worker.fraction)
|
||||
if self.worker.stop:
|
||||
self.snapshot_page.status_stack.set_visible_child(self.snapshot_page.split_view)
|
||||
self.parent_page.set_snapshots(self.parent_page.package_or_folder, True)
|
||||
return False # Stop the timeout
|
||||
else:
|
||||
return True # Continue the timeout
|
||||
|
||||
def on_apply(self, button):
|
||||
self.snapshot_page.status_stack.set_visible_child(self.snapshot_page.snapshotting_view)
|
||||
self.worker.extract()
|
||||
GLib.timeout_add(200, self.get_fraction)
|
||||
def on_response(dialog, response):
|
||||
if response != "continue":
|
||||
return
|
||||
|
||||
self.snapshot_page.snapshotting_status.title_label.set_label(_("Applying Snapshot"))
|
||||
self.snapshot_page.snapshotting_status.progress_label.set_visible(False)
|
||||
self.snapshot_page.snapshotting_status.progress_bar.set_fraction(0.0)
|
||||
self.snapshot_page.status_stack.set_visible_child(self.snapshot_page.snapshotting_view)
|
||||
self.worker.extract()
|
||||
GLib.timeout_add(200, self.get_fraction)
|
||||
|
||||
has_data = os.path.exists(self.worker.new_path)
|
||||
dialog = Adw.AlertDialog(
|
||||
heading=_("Apply Snapshot?"),
|
||||
body=_("Any current user data for this app will be trashed") if has_data else "",
|
||||
)
|
||||
dialog.add_response("cancel", _("Cancel"))
|
||||
dialog.add_response("continue", _("Apply"))
|
||||
dialog.connect("response", on_response)
|
||||
dialog.present(HostInfo.main_window)
|
||||
|
||||
def __init__(self, parent_page, folder, snapshots_path, toast_overlay, **kwargs):
|
||||
super().__init__(**kwargs)
|
||||
|
||||
Reference in New Issue
Block a user