about summary refs log tree commit diff
diff options
context:
space:
mode:
authorRicky Kresslein <ricky@unobserved.io>2023-10-15 11:01:39 +0200
committerRicky Kresslein <ricky@unobserved.io>2023-10-15 11:01:39 +0200
commit17c269b9d51850e09087653f24e02825fd2079f3 (patch)
treea8ddf58d173ca0b8c945957ae9ad1701f4e125ae
parent5a21b2528e30706cba939fd38102cafa5100c783 (diff)
downloadFurtherance-17c269b9d51850e09087653f24e02825fd2079f3.tar.zst
Add preference to toggle autocomplete
-rw-r--r--data/com.lakoliu.Furtherance.gschema.xml3
-rw-r--r--src/gtk/preferences_window.ui20
-rw-r--r--src/ui/preferences_window.rs9
-rw-r--r--src/ui/window.rs10
4 files changed, 37 insertions, 5 deletions
diff --git a/data/com.lakoliu.Furtherance.gschema.xml b/data/com.lakoliu.Furtherance.gschema.xml
index a321365..e3e9202 100644
--- a/data/com.lakoliu.Furtherance.gschema.xml
+++ b/data/com.lakoliu.Furtherance.gschema.xml
@@ -28,6 +28,9 @@
 	  <key name="show-tags" type="b">
       <default>true</default>
     </key>
+	  <key name="autocomplete" type="b">
+      <default>true</default>
+    </key>
 	  <key name="pomodoro" type="b">
       <default>false</default>
     </key>
diff --git a/src/gtk/preferences_window.ui b/src/gtk/preferences_window.ui
index 14ecaac..a1192ac 100644
--- a/src/gtk/preferences_window.ui
+++ b/src/gtk/preferences_window.ui
@@ -141,7 +141,7 @@
         <property name="icon_name">view-list-symbolic</property>
         <property name="title" translatable="yes" context="A page title of the preferences dialog">Tasks</property>
         <child>
-          <object class="AdwPreferencesGroup" id="task_group">
+          <object class="AdwPreferencesGroup" id="task_list_group">
             <property name="title" translatable="yes">Task List</property>
             <property name="visible">True</property>
             <child>
@@ -225,6 +225,24 @@
             </child>
           </object>
         </child>
+        <child>
+          <object class="AdwPreferencesGroup" id="task_input_group">
+            <property name="title" translatable="yes">Task Input</property>
+            <property name="visible">True</property>
+            <child>
+              <object class="AdwActionRow">
+                <property name="title" translatable="yes">_Autocomplete</property>
+                <property name="use_underline">True</property>
+                <property name="activatable_widget">autocomplete_switch</property>
+                <child>
+                  <object class="GtkSwitch" id="autocomplete_switch">
+                    <property name="valign">center</property>
+                  </object>
+                </child>
+              </object>
+            </child>
+          </object>
+        </child>
       </object>
     </child>
     <child>
diff --git a/src/ui/preferences_window.rs b/src/ui/preferences_window.rs
index 301250b..756e3ad 100644
--- a/src/ui/preferences_window.rs
+++ b/src/ui/preferences_window.rs
@@ -46,7 +46,7 @@ mod imp {
         pub notify_of_idle_spin: TemplateChild<gtk::SpinButton>,
 
         #[template_child]
-        pub task_group: TemplateChild<adw::PreferencesGroup>,
+        pub task_list_group: TemplateChild<adw::PreferencesGroup>,
         #[template_child]
         pub limit_tasks_expander: TemplateChild<adw::ExpanderRow>,
         #[template_child]
@@ -61,6 +61,11 @@ mod imp {
         pub show_tags_switch: TemplateChild<gtk::Switch>,
 
         #[template_child]
+        pub task_input_group: TemplateChild<adw::PreferencesGroup>,
+        #[template_child]
+        pub autocomplete_switch: TemplateChild<gtk::Switch>,
+
+        #[template_child]
         pub timer_group: TemplateChild<adw::PreferencesGroup>,
         #[template_child]
         pub pomodoro_expander: TemplateChild<adw::ExpanderRow>,
@@ -179,6 +184,8 @@ impl FurPreferencesWindow {
 
         settings_manager::bind_property("show-tags", &*imp.show_tags_switch, "active");
 
+        settings_manager::bind_property("autocomplete", &*imp.autocomplete_switch, "active");
+
         settings_manager::bind_property("pomodoro", &*imp.pomodoro_expander, "enable-expansion");
 
         settings_manager::bind_property("pomodoro-time", &*imp.pomodoro_spin, "value");
diff --git a/src/ui/window.rs b/src/ui/window.rs
index 5fa4581..6160bdc 100644
--- a/src/ui/window.rs
+++ b/src/ui/window.rs
@@ -185,7 +185,9 @@ impl FurtheranceWindow {
         imp.start_button.add_css_class("suggested-action");
         self.refresh_timer();
 
-        imp.task_input.set_completion(Some(&FurtheranceWindow::create_auto_complete()));
+        if settings_manager::get_bool("autocomplete") {
+            imp.task_input.set_completion(Some(&FurtheranceWindow::create_autocomplete()));
+        }
 
         imp.task_input.grab_focus();
 
@@ -350,7 +352,9 @@ impl FurtheranceWindow {
                 imp2.task_input.set_sensitive(true);
 
                 // Re-add auto-complete
-                imp2.task_input.set_completion(Some(&FurtheranceWindow::create_auto_complete()));
+                if settings_manager::get_bool("autocomplete") {
+                    imp2.task_input.set_completion(Some(&FurtheranceWindow::create_autocomplete()));
+                }
 
                 this.save_task(*start_time.borrow(), *stop_time.borrow());
                 FurtheranceWindow::delete_autosave();
@@ -812,7 +816,7 @@ impl FurtheranceWindow {
         Ok(vars)
     }
 
-    fn create_auto_complete() -> gtk::EntryCompletion {
+    fn create_autocomplete() -> gtk::EntryCompletion {
         let task_autocomplete = gtk::EntryCompletion::new();
         task_autocomplete.set_text_column(0);
         task_autocomplete.set_minimum_key_length(FurtheranceWindow::MIN_PREFIX_LENGTH);