[gnome-todo] welcome-workspace: Filter out completed tasks from inbox
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-todo] welcome-workspace: Filter out completed tasks from inbox
- Date: Fri, 30 Apr 2021 18:51:14 +0000 (UTC)
commit 4bcaf59d0d519d653aafc4375bb85234895f13c1
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Fri Apr 30 15:49:12 2021 -0300
welcome-workspace: Filter out completed tasks from inbox
Otherwise the counter won't match the panel's counter.
src/plugins/welcome/gtd-welcome-workspace.c | 16 +++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)
---
diff --git a/src/plugins/welcome/gtd-welcome-workspace.c b/src/plugins/welcome/gtd-welcome-workspace.c
index 16842c10..3e3b6f16 100644
--- a/src/plugins/welcome/gtd-welcome-workspace.c
+++ b/src/plugins/welcome/gtd-welcome-workspace.c
@@ -113,6 +113,14 @@ is_today (GDateTime *today,
* Callbacks
*/
+static gboolean
+inbox_filter_func (gpointer item,
+ gpointer user_data)
+{
+ GtdTask *task = (GtdTask*) item;
+ return !gtd_task_get_complete (task);
+}
+
static gboolean
filter_func (gpointer item,
gpointer user_data)
@@ -305,8 +313,10 @@ gtd_welcome_workspace_class_init (GtdWelcomeWorkspaceClass *klass)
static void
gtd_welcome_workspace_init (GtdWelcomeWorkspace *self)
{
+ g_autoptr (GtkFlattenListModel) flatten_inbox_model = NULL;
GtdManager *manager;
GListModel *inbox_model;
+ GtkCustomFilter *inbox_filter;
GtkCustomFilter *filter;
gtk_widget_init_template (GTK_WIDGET (self));
@@ -320,8 +330,12 @@ gtd_welcome_workspace_init (GtdWelcomeWorkspace *self)
update_welcome_label (self);
/* Inbox */
+ inbox_filter = gtk_custom_filter_new (inbox_filter_func, self, NULL);
inbox_model = gtd_manager_get_inbox_model (manager);
- self->inbox_tasks_model = G_LIST_MODEL (gtk_flatten_list_model_new (inbox_model));
+ flatten_inbox_model = gtk_flatten_list_model_new (inbox_model);
+ self->inbox_tasks_model =
+ G_LIST_MODEL (gtk_filter_list_model_new (G_LIST_MODEL (flatten_inbox_model),
+ GTK_FILTER (inbox_filter)));
g_signal_connect_object (self->inbox_tasks_model,
"items-changed",
G_CALLBACK (on_inbox_model_items_changed_cb),
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]