about summary refs log tree commit diff
diff options
context:
space:
mode:
authorRicky Kresslein <ricky@unobserved.io>2023-10-15 11:18:48 +0200
committerRicky Kresslein <ricky@unobserved.io>2023-10-15 11:18:48 +0200
commita7259d8cabadf9f35c29368837d90cdaa8b6bdd1 (patch)
treec78e9cdcd69b1e23cfc12e500d1b6050b6a61d84
parent17c269b9d51850e09087653f24e02825fd2079f3 (diff)
downloadFurtherance-a7259d8cabadf9f35c29368837d90cdaa8b6bdd1.tar.zst
Fix autocomplete preference bugs
-rw-r--r--src/ui/preferences_window.rs5
-rw-r--r--src/ui/window.rs19
2 files changed, 20 insertions, 4 deletions
diff --git a/src/ui/preferences_window.rs b/src/ui/preferences_window.rs
index 756e3ad..1b827fe 100644
--- a/src/ui/preferences_window.rs
+++ b/src/ui/preferences_window.rs
@@ -229,6 +229,11 @@ impl FurPreferencesWindow {
             window.reset_history_box();
         });
 
+        imp.autocomplete_switch.connect_active_notify(move |switch| {
+            let window = FurtheranceWindow::default();
+            window.reset_autocomplete();
+        });
+
         imp.pomodoro_expander
             .connect_enable_expansion_notify(move |_| {
                 let window = FurtheranceWindow::default();
diff --git a/src/ui/window.rs b/src/ui/window.rs
index 6160bdc..8591038 100644
--- a/src/ui/window.rs
+++ b/src/ui/window.rs
@@ -163,6 +163,15 @@ impl FurtheranceWindow {
         imp.history_box.create_tasks_page();
     }
 
+    pub fn reset_autocomplete(&self) {
+        let imp = imp::FurtheranceWindow::from_obj(self);
+        if settings_manager::get_bool("autocomplete") {
+            imp.task_input.set_completion(Some(&FurtheranceWindow::create_autocomplete()));
+        } else {
+            imp.task_input.set_completion(None);
+        }
+    }
+
     fn setup_widgets(&self) {
         let imp = imp::FurtheranceWindow::from_obj(self);
 
@@ -214,10 +223,12 @@ impl FurtheranceWindow {
                     imp2.start_button.set_sensitive(true);
                 }
 
-                if task_input.text().len() >= FurtheranceWindow::MIN_PREFIX_LENGTH.try_into().unwrap() {
-                    let task_autocomplete = task_input.completion().unwrap();
-                    let model = Self::update_list_model(task_name.to_string(), split_tags).unwrap();
-                    task_autocomplete.set_model(Some(&model));
+                if settings_manager::get_bool("autocomplete") {
+                    if task_input.text().len() >= FurtheranceWindow::MIN_PREFIX_LENGTH.try_into().unwrap() {
+                        let task_autocomplete = task_input.completion().unwrap();
+                        let model = Self::update_list_model(task_name.to_string(), split_tags).unwrap();
+                        task_autocomplete.set_model(Some(&model));
+                    }
                 }
             }));