From 0f05a52d429c41b538fa3b362cad3a54db04e5cd Mon Sep 17 00:00:00 2001 From: Ricky Kresslein Date: Thu, 3 Mar 2022 10:02:01 +0100 Subject: Added 'limit days shown' setting --- data/com.lakoliu.Furtherance.gschema.xml | 6 +++++ src/gtk/preferences_window.ui | 41 +++++++++++++++++++++++++++++--- src/ui/preferences_window.rs | 30 ++++++++++++++++++++++- 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 @@ -9,6 +9,12 @@ 6 + + + false + + + 6 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 @@ True - _Dark Theme + _Dark theme True dark_theme_switch @@ -29,13 +29,13 @@ True - Notify of Idle + Notify of idle (Gnome only) True True - _Minutes to Idle + _Minutes to idle Number of miniutes before the user is considered idle True @@ -58,6 +58,41 @@ + + + Task List + True + + + Limit tasks shown + Only show X number of days in the saved tasks list + True + True + + + _Days ago + Number of days to display in the list + True + + + center + + + 365 + 1 + 1 + 10 + + + True + + + + + + + + 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, #[template_child] pub notify_of_idle_spin: TemplateChild, + + #[template_child] + pub task_group: TemplateChild, + #[template_child] + pub limit_tasks_expander: TemplateChild, + #[template_child] + pub limit_days_spin: TemplateChild, } #[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 -- cgit 1.4.1