[gnome-todo] next-week, today: Also show completed tasks



commit 88ac1818793d91574b70c50ad5951f083d8757d3
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Thu Sep 19 09:14:52 2019 -0300

    next-week, today: Also show completed tasks
    
    It's useful when one wants to know how much was accomplished
    in a day.
    
    https://gitlab.gnome.org/GNOME/gnome-todo/issues/280

 plugins/next-week-panel/gtd-next-week-panel.c |  8 +++++---
 plugins/today-panel/gtd-panel-today.c         | 12 ++++--------
 2 files changed, 9 insertions(+), 11 deletions(-)
---
diff --git a/plugins/next-week-panel/gtd-next-week-panel.c b/plugins/next-week-panel/gtd-next-week-panel.c
index 4424e6c..6d9a31a 100644
--- a/plugins/next-week-panel/gtd-next-week-panel.c
+++ b/plugins/next-week-panel/gtd-next-week-panel.c
@@ -292,15 +292,17 @@ filter_func (gpointer item,
 {
   g_autoptr (GDateTime) task_dt = NULL;
   GtdTask *task;
+  gboolean complete;
   gint days_offset;
 
   task = (GtdTask*) item;
+  complete = gtd_task_get_complete (task);
   task_dt = gtd_task_get_due_date (task);
 
-  return !gtd_task_get_complete (task) &&
-         task_dt != NULL &&
+  return task_dt != NULL &&
          get_date_offset (task_dt, &days_offset, NULL) &&
-         days_offset < 7;
+         days_offset < 7 &&
+         ((days_offset < 0 && !complete) || days_offset >= 0);
 }
 
 static void
diff --git a/plugins/today-panel/gtd-panel-today.c b/plugins/today-panel/gtd-panel-today.c
index 34fdddf..0f3713c 100644
--- a/plugins/today-panel/gtd-panel-today.c
+++ b/plugins/today-panel/gtd-panel-today.c
@@ -98,13 +98,6 @@ is_today (GDateTime *today,
   return FALSE;
 }
 
-static inline gboolean
-should_be_added (GDateTime *today,
-                 GDateTime *dt)
-{
-  return is_today (today, dt) || is_overdue (today, dt);
-}
-
 static GtkWidget*
 create_label (const gchar *text,
               gboolean     overdue)
@@ -169,12 +162,15 @@ filter_func (gpointer  item,
   g_autoptr (GDateTime) task_dt = NULL;
   g_autoptr (GDateTime) now = NULL;
   GtdTask *task;
+  gboolean complete;
 
   task = (GtdTask*) item;
   now = g_date_time_new_now_local ();
   task_dt = gtd_task_get_due_date (task);
 
-  return !gtd_task_get_complete (task) && should_be_added (now, task_dt);
+  complete = gtd_task_get_complete (task);
+
+  return is_today (now, task_dt) || (!complete && is_overdue (now, task_dt));
 }
 
 static gint


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]