[gnome-todo/gbsneto/planning: 1/6] manager: Add inbox model
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-todo/gbsneto/planning: 1/6] manager: Add inbox model
- Date: Tue, 5 May 2020 15:58:09 +0000 (UTC)
commit 47282328c114f29d7ec4a66a8425a87229f43723
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Tue May 5 09:33:36 2020 -0300
manager: Add inbox model
src/engine/gtd-manager.c | 29 +++++++++++++++++++++++++++++
src/engine/gtd-manager.h | 2 ++
2 files changed, 31 insertions(+)
---
diff --git a/src/engine/gtd-manager.c b/src/engine/gtd-manager.c
index ffa9c36..13a6656 100644
--- a/src/engine/gtd-manager.c
+++ b/src/engine/gtd-manager.c
@@ -57,6 +57,7 @@ struct _GtdManager
GSettings *settings;
GtdPluginManager *plugin_manager;
+ GListModel *inbox_model;
GListModel *lists_model;
GListModel *tasks_model;
GListModel *unarchived_tasks_model;
@@ -131,6 +132,15 @@ filter_achived_lists_func (gpointer item,
return !gtd_task_list_get_archived (list);
}
+static gboolean
+filter_inbox_cb (gpointer item,
+ gpointer user_data)
+{
+ GtdProvider *provider = gtd_task_list_get_provider (item);
+
+ return gtd_provider_get_inbox (provider) == item;
+}
+
static gint
compare_lists_cb (GtdTaskList *list_a,
GtdTaskList *list_b,
@@ -245,6 +255,7 @@ gtd_manager_finalize (GObject *object)
g_clear_object (&self->clock);
g_clear_object (&self->unarchived_tasks_model);
g_clear_object (&self->lists_model);
+ g_clear_object (&self->inbox_model);
G_OBJECT_CLASS (gtd_manager_parent_class)->finalize (object);
}
@@ -495,6 +506,7 @@ gtd_manager_init (GtdManager *self)
self->clock = gtd_clock_new ();
self->cancellable = g_cancellable_new ();
self->lists_model = (GListModel*) gtd_list_store_new (GTD_TYPE_TASK_LIST);
+ self->inbox_model = (GListModel*) gtk_filter_list_model_new (self->lists_model, filter_inbox_cb, self,
NULL);
self->tasks_model = (GListModel*) _gtd_task_model_new (self);
self->unarchived_tasks_model = (GListModel*) gtk_filter_list_model_new (self->tasks_model,
filter_achived_lists_func,
@@ -857,6 +869,23 @@ gtd_manager_get_tasks_model (GtdManager *self)
return self->unarchived_tasks_model;
}
+/**
+ * gtd_manager_get_inbox_model:
+ * @self: a #GtdManager
+ *
+ * Retrieves the #GListModel containing #GtdTaskLists that are
+ * inbox.
+ *
+ * Returns: (transfer none): a #GListModel
+ */
+GListModel*
+gtd_manager_get_inbox_model (GtdManager *self)
+{
+ g_return_val_if_fail (GTD_IS_MANAGER (self), NULL);
+
+ return self->inbox_model;
+}
+
void
gtd_manager_load_plugins (GtdManager *self)
{
diff --git a/src/engine/gtd-manager.h b/src/engine/gtd-manager.h
index 071472a..7b46400 100644
--- a/src/engine/gtd-manager.h
+++ b/src/engine/gtd-manager.h
@@ -79,4 +79,6 @@ GListModel* gtd_manager_get_all_tasks_model (GtdManager
GListModel* gtd_manager_get_tasks_model (GtdManager *self);
+GListModel* gtd_manager_get_inbox_model (GtdManager *self);
+
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]