diff options
-rwxr-xr-x | data/com.lakoliu.Furtherance.gschema.xml | 6 | ||||
-rwxr-xr-x | src/gtk/preferences_window.ui | 41 | ||||
-rwxr-xr-x | src/ui/preferences_window.rs | 30 | ||||
-rwxr-xr-x | src/ui/tasks_page.rs | 10 |
4 files changed, 83 insertions, 4 deletions
diff --git a/data/com.lakoliu.Furtherance.gschema.xml b/data/com.lakoliu.Furtherance.gschema.xml index ae8edc4..9ebfa45 100755 --- a/data/com.lakoliu.Furtherance.gschema.xml +++ b/data/com.lakoliu.Furtherance.gschema.xml @@ -10,5 +10,11 @@ <key name="idle-time" type="i"> <default>6</default> </key> + <key name="limit-tasks" type="b"> + <default>false</default> + </key> + <key name="limit-days" type="i"> + <default>6</default> + </key> </schema> </schemalist> diff --git a/src/gtk/preferences_window.ui b/src/gtk/preferences_window.ui index 0ac2337..e6de99a 100755 --- a/src/gtk/preferences_window.ui +++ b/src/gtk/preferences_window.ui @@ -11,7 +11,7 @@ <property name="visible">True</property> <child> <object class="AdwActionRow"> - <property name="title" translatable="yes">_Dark Theme</property> + <property name="title" translatable="yes">_Dark theme</property> <property name="use_underline">True</property> <property name="activatable_widget">dark_theme_switch</property> <child> @@ -29,13 +29,13 @@ <property name="visible">True</property> <child> <object class="AdwExpanderRow" id="notify_of_idle_expander"> - <property name="title" translatable="yes">Notify of Idle</property> + <property name="title" translatable="yes">Notify of idle</property> <property name="subtitle" translatable="yes">(Gnome only)</property> <property name="show_enable_switch">True</property> <property name="use_underline">True</property> <child> <object class="AdwActionRow"> - <property name="title" translatable="yes">_Minutes to Idle</property> + <property name="title" translatable="yes">_Minutes to idle</property> <property name="subtitle" translatable="yes">Number of miniutes before the user is considered idle</property> <property name="use_underline">True</property> <child> @@ -58,6 +58,41 @@ </child> </object> </child> + <child> + <object class="AdwPreferencesGroup" id="task_group"> + <property name="title" translatable="yes">Task List</property> + <property name="visible">True</property> + <child> + <object class="AdwExpanderRow" id="limit_tasks_expander"> + <property name="title" translatable="yes">Limit tasks shown</property> + <property name="subtitle" translatable="yes">Only show X number of days in the saved tasks list</property> + <property name="show_enable_switch">True</property> + <property name="use_underline">True</property> + <child> + <object class="AdwActionRow"> + <property name="title" translatable="yes">_Days ago</property> + <property name="subtitle" translatable="yes">Number of days to display in the list</property> + <property name="use_underline">True</property> + <child> + <object class="GtkSpinButton" id="limit_days_spin"> + <property name="valign">center</property> + <property name="adjustment"> + <object class="GtkAdjustment"> + <property name="upper">365</property> + <property name="lower">1</property> + <property name="step_increment">1</property> + <property name="page_increment">10</property> + </object> + </property> + <property name="numeric">True</property> + </object> + </child> + </object> + </child> + </object> + </child> + </object> + </child> </object> </child> </template> diff --git a/src/ui/preferences_window.rs b/src/ui/preferences_window.rs index b6088ec..644ca22 100755 --- a/src/ui/preferences_window.rs +++ b/src/ui/preferences_window.rs @@ -41,6 +41,13 @@ mod imp { pub notify_of_idle_expander: TemplateChild<adw::ExpanderRow>, #[template_child] pub notify_of_idle_spin: TemplateChild<gtk::SpinButton>, + + #[template_child] + pub task_group: TemplateChild<adw::PreferencesGroup>, + #[template_child] + pub limit_tasks_expander: TemplateChild<adw::ExpanderRow>, + #[template_child] + pub limit_days_spin: TemplateChild<gtk::SpinButton>, } #[glib::object_subclass] @@ -119,7 +126,28 @@ impl FurPreferencesWindow { &*imp.notify_of_idle_spin, "value", ); - } + settings_manager::bind_property( + "limit-tasks", + &*imp.limit_tasks_expander, + "enable-expansion", + ); + + settings_manager::bind_property( + "limit-days", + &*imp.limit_days_spin, + "value", + ); + + imp.limit_tasks_expander.connect_enable_expansion_notify(move |_|{ + let window = FurtheranceWindow::default(); + window.reset_history_box(); + }); + + imp.limit_days_spin.connect_value_changed(move |_|{ + let window = FurtheranceWindow::default(); + window.reset_history_box(); + }); + } } diff --git a/src/ui/tasks_page.rs b/src/ui/tasks_page.rs index fbbaf0c..9f0aed3 100755 --- a/src/ui/tasks_page.rs +++ b/src/ui/tasks_page.rs @@ -22,6 +22,7 @@ use chrono::{DateTime, Local, Duration}; use crate::ui::FurTasksGroup; use crate::database; +use crate::settings_manager; mod imp { use super::*; @@ -122,6 +123,15 @@ impl FurTasksPage { tasks_sorted_by_day.push(same_date_list.clone()); } i += 1; + if settings_manager::get_bool("limit-tasks") { + if uniq_date_list.len() > settings_manager::get_int("limit-days") as usize { + if same_date_list.len() > 0 && i != len { + tasks_sorted_by_day.push(same_date_list.clone()); + } + uniq_date_list.pop(); + break; + } + } } // Create FurTasksGroups for all unique days |