diff options
-rwxr-xr-x | meson.build | 2 | ||||
-rwxr-xr-x | src/gtk/window.ui | 8 | ||||
-rwxr-xr-x | src/ui/task_details.rs | 36 | ||||
-rwxr-xr-x | src/ui/window.rs | 14 |
4 files changed, 42 insertions, 18 deletions
diff --git a/meson.build b/meson.build index 04c9746..ac9661f 100755 --- a/meson.build +++ b/meson.build @@ -1,5 +1,5 @@ project('furtherance', 'rust', - version: '1.0.6', + version: '1.0.7', meson_version: '>= 0.50.0', default_options: [ 'warning_level=2', ], diff --git a/src/gtk/window.ui b/src/gtk/window.ui index d6c5311..7ac6b01 100755 --- a/src/gtk/window.ui +++ b/src/gtk/window.ui @@ -83,13 +83,13 @@ <attribute name="action">app.preferences</attribute> </item> <item> - <attribute name="label" translatable="yes">_About Furtherance</attribute> - <attribute name="action">app.about</attribute> - </item> - <item> <attribute name="label" translatable="yes">_Delete history</attribute> <attribute name="action">app.delete-history</attribute> </item> + <item> + <attribute name="label" translatable="yes">_About Furtherance</attribute> + <attribute name="action">app.about</attribute> + </item> </section> </menu> </interface> diff --git a/src/ui/task_details.rs b/src/ui/task_details.rs index 4edd7bb..c45d561 100755 --- a/src/ui/task_details.rs +++ b/src/ui/task_details.rs @@ -51,6 +51,7 @@ mod imp { pub all_boxes: RefCell<Vec<gtk::Box>>, pub all_task_ids: RefCell<Vec<i32>>, + pub this_day: RefCell<String>, } #[glib::object_subclass] @@ -106,6 +107,8 @@ impl FurTaskDetails { let imp = imp::FurTaskDetails::from_instance(self); imp.task_name_label.set_text(&task_group[0].task_name); + let this_day_str = DateTime::parse_from_rfc3339(&task_group[0].start_time).unwrap(); + *imp.this_day.borrow_mut() = this_day_str.format("%h %d %Y").to_string(); for task in task_group.clone() { imp.all_task_ids.borrow_mut().push(task.id); @@ -177,13 +180,13 @@ impl FurTaskDetails { let times_box = gtk::Box::new(gtk::Orientation::Horizontal, 5); times_box.set_homogeneous(true); - let mut start_time_w_year = start_time.format("%h %e %Y %H:%M:%S").to_string(); + let mut start_time_w_year = start_time.format("%h %d %Y %H:%M:%S").to_string(); if !settings_manager::get_bool("show-seconds") { - start_time_w_year = start_time.format("%h %e %Y %H:%M").to_string(); + start_time_w_year = start_time.format("%h %d %Y %H:%M").to_string(); } - let mut stop_time_w_year = stop_time.format("%h %e %Y %H:%M:%S").to_string(); + let mut stop_time_w_year = stop_time.format("%h %d %Y %H:%M:%S").to_string(); if !settings_manager::get_bool("show-seconds") { - stop_time_w_year = stop_time.format("%h %e %Y %H:%M").to_string(); + stop_time_w_year = stop_time.format("%h %d %Y %H:%M").to_string(); } let start_time_edit = gtk::Entry::new(); start_time_edit.set_text(&start_time_w_year); @@ -289,11 +292,11 @@ impl FurTaskDetails { if settings_manager::get_bool("show-seconds") { new_start_time = NaiveDateTime::parse_from_str( &new_start_time_str, - "%h %e %Y %H:%M:%S"); + "%h %d %Y %H:%M:%S"); } else { new_start_time = NaiveDateTime::parse_from_str( &new_start_time_str, - "%h %e %Y %H:%M"); + "%h %d %Y %H:%M"); } if let Err(_) = new_start_time { instructions.set_visible(true); @@ -310,11 +313,11 @@ impl FurTaskDetails { if settings_manager::get_bool("show-seconds") { new_stop_time = NaiveDateTime::parse_from_str( &new_stop_time_str, - "%h %e %Y %H:%M:%S"); + "%h %d %Y %H:%M:%S"); } else { new_stop_time = NaiveDateTime::parse_from_str( &new_stop_time_str, - "%h %e %Y %H:%M"); + "%h %d %Y %H:%M"); } if let Err(_) = new_stop_time { instructions.set_visible(true); @@ -397,10 +400,25 @@ impl FurTaskDetails { imp.all_boxes.borrow_mut().clear(); // Get list from database by a vec of IDs let updated_list = database::get_list_by_id(imp.all_task_ids.clone().borrow().to_vec()); + let mut updated_list = updated_list.unwrap(); + // Check if dates in all_task_ids list match this date + // and if not, delete them. + updated_list.retain(|task| { + let delete = { + let start_time = DateTime::parse_from_rfc3339(&task.start_time).unwrap(); + let start_time_str = start_time.format("%h %d %Y").to_string(); + if imp.this_day.borrow().to_string() != start_time_str { + false + } else { + true + } + }; + delete + }); imp.all_task_ids.borrow_mut().clear(); let window = FurtheranceWindow::default(); window.reset_history_box(); - self.setup_widgets(updated_list.unwrap()); + self.setup_widgets(updated_list); } fn setup_signals(&self) { diff --git a/src/ui/window.rs b/src/ui/window.rs index 7c1e8cc..277daa5 100755 --- a/src/ui/window.rs +++ b/src/ui/window.rs @@ -77,6 +77,7 @@ mod imp { impl ObjectImpl for FurtheranceWindow { fn constructed(&self, obj: &Self::Type) { + obj.setup_widgets(); obj.setup_signals(); obj.setup_settings(); self.parent_constructed(obj); @@ -147,17 +148,22 @@ impl FurtheranceWindow { imp.history_box.create_tasks_page(); } - fn setup_signals(&self) { + fn setup_widgets(&self) { let imp = imp::FurtheranceWindow::from_instance(self); - let running = Arc::new(Mutex::new(false)); - let start_time = Rc::new(RefCell::new(Local::now())); - let stop_time = Rc::new(RefCell::new(Local::now())); // Development mode if config::PROFILE == "development" { self.add_css_class("devel"); } + imp.task_input.grab_focus(); + } + + fn setup_signals(&self) { + let imp = imp::FurtheranceWindow::from_instance(self); + let running = Arc::new(Mutex::new(false)); + let start_time = Rc::new(RefCell::new(Local::now())); + let stop_time = Rc::new(RefCell::new(Local::now())); imp.start_button.connect_clicked(clone!( @weak self as this, |