about summary refs log tree commit diff
diff options
context:
space:
mode:
authorRicky Kresslein <rk@lakoliu.com>2022-06-11 08:02:04 +0300
committerRicky Kresslein <rk@lakoliu.com>2022-06-11 08:02:04 +0300
commit9f9ac2b47c86630d4864f9748ca0c3a1b18caff1 (patch)
tree0373abb6e3374c668ded03422a1aee04858d8989
parent2e25f23cd9d5ba2a90021c4daffbf9395fec8fb7 (diff)
downloadFurtherance-9f9ac2b47c86630d4864f9748ca0c3a1b18caff1.tar.zst
Export CSV disabled if no tasks
-rwxr-xr-xsrc/application.rs20
-rwxr-xr-xsrc/ui/history_box.rs2
2 files changed, 15 insertions, 7 deletions
diff --git a/src/application.rs b/src/application.rs
index 157c432..cfacd93 100755
--- a/src/application.rs
+++ b/src/application.rs
@@ -163,13 +163,6 @@ impl FurtheranceApplication {
             imp.pomodoro_dialog.lock().unwrap().response(gtk::ResponseType::Reject);
         }));
         self.add_action(&stop_pomodoro_action);
-
-        let export_csv_action = gio::SimpleAction::new("export-csv", None);
-        export_csv_action.connect_activate(clone!(@weak self as app => move |_, _| {
-            let window = FurtheranceWindow::default();
-            window.open_csv_export_dialog();
-        }));
-        self.add_action(&export_csv_action);
     }
 
     fn setup_application(&self) {
@@ -257,6 +250,19 @@ impl FurtheranceApplication {
         }
     }
 
+    pub fn export_csv_enabled(&self, enabled: bool) {
+        if enabled {
+            let export_csv_action = gio::SimpleAction::new("export-csv", None);
+            export_csv_action.connect_activate(clone!(@weak self as app => move |_, _| {
+                let window = FurtheranceWindow::default();
+                window.open_csv_export_dialog();
+            }));
+            self.add_action(&export_csv_action);
+        } else {
+            self.remove_action("export-csv");
+        }
+    }
+
     pub fn update_light_dark(&self) {
         let manager = adw::StyleManager::default();
 
diff --git a/src/ui/history_box.rs b/src/ui/history_box.rs
index 445d796..87631b0 100755
--- a/src/ui/history_box.rs
+++ b/src/ui/history_box.rs
@@ -93,6 +93,7 @@ impl FurHistoryBox {
         let imp = imp::FurHistoryBox::from_instance(self);
         let app = FurtheranceApplication::default();
         app.delete_enabled(false);
+        app.export_csv_enabled(false);
         imp.spinner.set_spinning(false);
 
         let name = match view {
@@ -103,6 +104,7 @@ impl FurHistoryBox {
             View::Empty => "empty",
             View::Tasks => {
                 app.delete_enabled(true);
+                app.export_csv_enabled(true);
                 "tasks"
             }
         };