From a37326b710baafd44b5d3034f8e65a8240341813 Mon Sep 17 00:00:00 2001 From: heliguy4599 Date: Mon, 14 Oct 2024 19:53:06 -0400 Subject: [PATCH] Don't allow the option to make new snapshots when no data is present --- src/snapshot_page/snapshot_page.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/snapshot_page/snapshot_page.py b/src/snapshot_page/snapshot_page.py index cdf3cee..d26c30f 100644 --- a/src/snapshot_page/snapshot_page.py +++ b/src/snapshot_page/snapshot_page.py @@ -216,6 +216,26 @@ class SnapshotPage(Adw.BreakpointBin): GLib.idle_add(lambda *_: self.stack.set_visible_child(self.scrolled_window)) GLib.idle_add(lambda *_: self.status_stack.set_visible_child(self.split_view)) + data_path = f"{HostInfo.home}/.var/app" + total_data = 0 + for folder in os.listdir(data_path): + if folder == "io.github.flattool.Warehouse": + continue + + total_data += 1 + break + + if total_data > 0: + self.new_button.set_sensitive(True) + self.new_button.set_tooltip_text(None) + self.status_new_button.set_sensitive(True) + self.status_new_button.set_tooltip_text(None) + else: + self.new_button.set_sensitive(False) + self.new_button.set_tooltip_text(_("No Data Found to Snapshot")) + self.status_new_button.set_sensitive(False) + self.status_new_button.set_tooltip_text(_("No Data Found to Snapshot")) + Gio.Task.new(None, None, callback).run_in_thread(self.sort_snapshots) def open_snapshots_folder(self, button):