[gnome-todo] panels: Fix open task counters
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-todo] panels: Fix open task counters
- Date: Fri, 20 Sep 2019 16:15:47 +0000 (UTC)
commit 34788b2bd9e8c0c0a9d87c13fc187fcd663f3b47
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Fri Sep 20 13:15:22 2019 -0300
panels: Fix open task counters
https://gitlab.gnome.org/GNOME/gnome-todo/issues/281
plugins/next-week-panel/gtd-next-week-panel.c | 14 +++++++++++++-
plugins/today-panel/gtd-panel-today.c | 14 +++++++++++++-
2 files changed, 26 insertions(+), 2 deletions(-)
---
diff --git a/plugins/next-week-panel/gtd-next-week-panel.c b/plugins/next-week-panel/gtd-next-week-panel.c
index 6d9a31a..92e8f6c 100644
--- a/plugins/next-week-panel/gtd-next-week-panel.c
+++ b/plugins/next-week-panel/gtd-next-week-panel.c
@@ -42,6 +42,7 @@ struct _GtdNextWeekPanel
GtdTaskListView *view;
GtkFilterListModel *filter_model;
+ GtkFilterListModel *incomplete_model;
GtkSortListModel *sort_model;
};
@@ -305,6 +306,15 @@ filter_func (gpointer item,
((days_offset < 0 && !complete) || days_offset >= 0);
}
+static gboolean
+filter_complete_func (gpointer item,
+ gpointer user_data)
+{
+ GtdTask *task = (GtdTask*) item;
+
+ return !gtd_task_get_complete (task);
+}
+
static void
on_model_items_changed_cb (GListModel *model,
guint position,
@@ -403,6 +413,7 @@ gtd_next_week_panel_finalize (GObject *object)
g_clear_object (&self->icon);
g_clear_object (&self->filter_model);
+ g_clear_object (&self->incomplete_model);
g_clear_object (&self->sort_model);
G_OBJECT_CLASS (gtd_next_week_panel_parent_class)->finalize (object);
@@ -483,6 +494,7 @@ gtd_next_week_panel_init (GtdNextWeekPanel *self)
self->filter_model = gtk_filter_list_model_new (gtd_manager_get_tasks_model (manager), filter_func, self,
NULL);
self->sort_model = gtk_sort_list_model_new (G_LIST_MODEL (self->filter_model), sort_func, self, NULL);
+ self->incomplete_model = gtk_filter_list_model_new (G_LIST_MODEL (self->sort_model), filter_complete_func,
self, NULL);
/* The main view */
self->view = GTD_TASK_LIST_VIEW (gtd_task_list_view_new ());
@@ -500,7 +512,7 @@ gtd_next_week_panel_init (GtdNextWeekPanel *self)
(GtdTaskListViewHeaderFunc) header_func,
self);
- g_signal_connect_object (self->sort_model,
+ g_signal_connect_object (self->incomplete_model,
"items-changed",
G_CALLBACK (on_model_items_changed_cb),
self,
diff --git a/plugins/today-panel/gtd-panel-today.c b/plugins/today-panel/gtd-panel-today.c
index 0f3713c..3dbe6a2 100644
--- a/plugins/today-panel/gtd-panel-today.c
+++ b/plugins/today-panel/gtd-panel-today.c
@@ -35,6 +35,7 @@ struct _GtdPanelToday
GtdTaskListView *view;
GtkFilterListModel *filter_model;
+ GtkFilterListModel *incomplete_model;
GtkSortListModel *sort_model;
};
@@ -173,6 +174,15 @@ filter_func (gpointer item,
return is_today (now, task_dt) || (!complete && is_overdue (now, task_dt));
}
+static gboolean
+filter_complete_func (gpointer item,
+ gpointer user_data)
+{
+ GtdTask *task = (GtdTask*) item;
+
+ return !gtd_task_get_complete (task);
+}
+
static gint
sort_func (gconstpointer a,
gconstpointer b,
@@ -305,6 +315,7 @@ gtd_panel_today_finalize (GObject *object)
g_clear_object (&self->icon);
g_clear_object (&self->filter_model);
+ g_clear_object (&self->incomplete_model);
g_clear_object (&self->sort_model);
G_OBJECT_CLASS (gtd_panel_today_parent_class)->finalize (object);
@@ -387,6 +398,7 @@ gtd_panel_today_init (GtdPanelToday *self)
self->filter_model = gtk_filter_list_model_new (gtd_manager_get_tasks_model (manager), filter_func, self,
NULL);
self->sort_model = gtk_sort_list_model_new (G_LIST_MODEL (self->filter_model), sort_func, self, NULL);
+ self->incomplete_model = gtk_filter_list_model_new (G_LIST_MODEL (self->sort_model), filter_complete_func,
self, NULL);
/* Connect to GtdManager::list-* signals to update the title */
manager = gtd_manager_get_default ();
@@ -406,7 +418,7 @@ gtd_panel_today_init (GtdPanelToday *self)
gtd_task_list_view_set_header_func (self->view, header_func, self);
- g_signal_connect_object (self->sort_model,
+ g_signal_connect_object (self->incomplete_model,
"items-changed",
G_CALLBACK (on_model_items_changed_cb),
self,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]