[gnome-todo] provider: add :get_default_task_list vfunc



commit ae518ec433b708576e2578a829cffd80b9bd284c
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Mon Oct 3 16:10:15 2016 -0300

    provider: add :get_default_task_list vfunc
    
    So we can know which is the default tasklist of a given
    provider.

 plugins/eds/gtd-provider-eds.c   |   19 +++++++++++++++++++
 plugins/eds/gtd-provider-eds.h   |    2 ++
 plugins/eds/gtd-provider-goa.c   |    7 +++++++
 plugins/eds/gtd-provider-local.c |    7 +++++++
 src/interfaces/gtd-provider.c    |   19 +++++++++++++++++++
 src/interfaces/gtd-provider.h    |    4 ++++
 6 files changed, 58 insertions(+), 0 deletions(-)
---
diff --git a/plugins/eds/gtd-provider-eds.c b/plugins/eds/gtd-provider-eds.c
index 3a4fb3b..85cb0d7 100644
--- a/plugins/eds/gtd-provider-eds.c
+++ b/plugins/eds/gtd-provider-eds.c
@@ -1002,3 +1002,22 @@ gtd_provider_eds_get_task_lists (GtdProviderEds *provider)
 
   return priv->task_lists;
 }
+
+GtdTaskList*
+gtd_provider_eds_get_default_task_list (GtdProviderEds *provider)
+{
+  GtdProviderEdsPrivate *priv;
+  GtdTaskList *default_task_list;
+  ESource *default_source;
+
+  priv = gtd_provider_eds_get_instance_private (provider);
+  default_source = e_source_registry_ref_default_task_list (priv->source_registry);
+  default_task_list = g_object_get_data (G_OBJECT (default_source), "task-list");
+
+  g_clear_object (&default_source);
+
+  if (gtd_task_list_get_provider (default_task_list) != GTD_PROVIDER (provider))
+    return NULL;
+
+  return default_task_list;
+}
diff --git a/plugins/eds/gtd-provider-eds.h b/plugins/eds/gtd-provider-eds.h
index 40568c7..2b48d44 100644
--- a/plugins/eds/gtd-provider-eds.h
+++ b/plugins/eds/gtd-provider-eds.h
@@ -62,6 +62,8 @@ void                 gtd_provider_eds_remove_task_list           (GtdProviderEds
 
 GList*               gtd_provider_eds_get_task_lists             (GtdProviderEds     *provider);
 
+GtdTaskList*         gtd_provider_eds_get_default_task_list      (GtdProviderEds     *provider);
+
 G_END_DECLS
 
 #endif /* GTD_PROVIDER_EDS_H */
diff --git a/plugins/eds/gtd-provider-goa.c b/plugins/eds/gtd-provider-goa.c
index d26f3fb..0e6ca70 100644
--- a/plugins/eds/gtd-provider-goa.c
+++ b/plugins/eds/gtd-provider-goa.c
@@ -160,6 +160,12 @@ gtd_provider_goa_get_task_lists (GtdProvider *provider)
   return gtd_provider_eds_get_task_lists (GTD_PROVIDER_EDS (provider));
 }
 
+static GtdTaskList*
+gtd_provider_goa_get_default_task_list (GtdProvider *provider)
+{
+  return gtd_provider_eds_get_default_task_list (GTD_PROVIDER_EDS (provider));
+}
+
 static void
 gtd_provider_iface_init (GtdProviderInterface *iface)
 {
@@ -176,6 +182,7 @@ gtd_provider_iface_init (GtdProviderInterface *iface)
   iface->update_task_list = gtd_provider_goa_update_task_list;
   iface->remove_task_list = gtd_provider_goa_remove_task_list;
   iface->get_task_lists = gtd_provider_goa_get_task_lists;
+  iface->get_default_task_list = gtd_provider_goa_get_default_task_list;
 }
 
 static void
diff --git a/plugins/eds/gtd-provider-local.c b/plugins/eds/gtd-provider-local.c
index 4e7f812..116e16e 100644
--- a/plugins/eds/gtd-provider-local.c
+++ b/plugins/eds/gtd-provider-local.c
@@ -180,6 +180,12 @@ gtd_provider_local_get_task_lists (GtdProvider *provider)
   return gtd_provider_eds_get_task_lists (GTD_PROVIDER_EDS (provider));
 }
 
+static GtdTaskList*
+gtd_provider_local_get_default_task_list (GtdProvider *provider)
+{
+  return gtd_provider_eds_get_default_task_list (GTD_PROVIDER_EDS (provider));
+}
+
 static void
 gtd_provider_iface_init (GtdProviderInterface *iface)
 {
@@ -196,6 +202,7 @@ gtd_provider_iface_init (GtdProviderInterface *iface)
   iface->update_task_list = gtd_provider_local_update_task_list;
   iface->remove_task_list = gtd_provider_local_remove_task_list;
   iface->get_task_lists = gtd_provider_local_get_task_lists;
+  iface->get_default_task_list = gtd_provider_local_get_default_task_list;
 }
 
 GtdProviderLocal*
diff --git a/src/interfaces/gtd-provider.c b/src/interfaces/gtd-provider.c
index 5eb0eb7..0c5e823 100644
--- a/src/interfaces/gtd-provider.c
+++ b/src/interfaces/gtd-provider.c
@@ -334,6 +334,7 @@ gtd_provider_update_task_list (GtdProvider *provider,
 
   GTD_PROVIDER_GET_IFACE (provider)->update_task_list (provider, list);
 }
+
 /**
  * gtd_provider_remove_task_list:
  * @provider: a #GtdProvider
@@ -350,6 +351,7 @@ gtd_provider_remove_task_list (GtdProvider *provider,
 
   GTD_PROVIDER_GET_IFACE (provider)->remove_task_list (provider, list);
 }
+
 /**
  * gtd_provider_get_task_lists:
  * @provider: a #GtdProvider
@@ -366,3 +368,20 @@ gtd_provider_get_task_lists (GtdProvider *provider)
 
   return GTD_PROVIDER_GET_IFACE (provider)->get_task_lists (provider);
 }
+
+/**
+ * gtd_provider_get_default_task_list:
+ * @provider: a #GtdProvider
+ *
+ * Retrieves the default tasklist of @provider.
+ *
+ * Returns: (transfer none)(nullable): the default tasklist, or %NULL
+ */
+GtdTaskList*
+gtd_provider_get_default_task_list (GtdProvider *provider)
+{
+  g_return_val_if_fail (GTD_IS_PROVIDER (provider), NULL);
+  g_return_val_if_fail (GTD_PROVIDER_GET_IFACE (provider)->get_default_task_list, NULL);
+
+  return GTD_PROVIDER_GET_IFACE (provider)->get_default_task_list (provider);
+}
diff --git a/src/interfaces/gtd-provider.h b/src/interfaces/gtd-provider.h
index 2c24947..24983b5 100644
--- a/src/interfaces/gtd-provider.h
+++ b/src/interfaces/gtd-provider.h
@@ -70,6 +70,8 @@ struct _GtdProviderInterface
                                                                   GtdTaskList        *list);
 
   GList*             (*get_task_lists)                           (GtdProvider        *provider);
+
+  GtdTaskList*       (*get_default_task_list)                    (GtdProvider        *provider);
 };
 
 const gchar*         gtd_provider_get_id                         (GtdProvider        *provider);
@@ -104,6 +106,8 @@ void                 gtd_provider_remove_task_list               (GtdProvider
 
 GList*               gtd_provider_get_task_lists                 (GtdProvider        *provider);
 
+GtdTaskList*         gtd_provider_get_default_task_list          (GtdProvider        *provider);
+
 G_END_DECLS
 
 #endif /* GTD_PROVIDER_H */


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