[gnome-todo] task-list: add :set_provider() API



commit 4c5bb10234d3b93ee915cde555a9c16bbe60103a
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Wed Oct 5 20:57:27 2016 -0300

    task-list: add :set_provider() API

 src/gtd-task-list.c |   27 +++++++++++++++++++++++----
 src/gtd-task-list.h |    3 +++
 2 files changed, 26 insertions(+), 4 deletions(-)
---
diff --git a/src/gtd-task-list.c b/src/gtd-task-list.c
index 976af8c..656f2ec 100644
--- a/src/gtd-task-list.c
+++ b/src/gtd-task-list.c
@@ -111,7 +111,6 @@ gtd_task_list_set_property (GObject      *object,
                             GParamSpec   *pspec)
 {
   GtdTaskList *self = GTD_TASK_LIST (object);
-  GtdTaskListPrivate *priv = gtd_task_list_get_instance_private (self);
 
   switch (prop_id)
     {
@@ -128,8 +127,7 @@ gtd_task_list_set_property (GObject      *object,
       break;
 
     case PROP_PROVIDER:
-      if (g_set_object (&priv->provider, g_value_get_object (value)))
-        g_object_notify (object, "provider");
+      gtd_task_list_set_provider (self, g_value_get_object (value));
       break;
 
     default:
@@ -200,7 +198,7 @@ gtd_task_list_class_init (GtdTaskListClass *klass)
                              "Provider of the list",
                              "The provider that handles the list",
                              GTD_TYPE_PROVIDER,
-                             G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+                             G_PARAM_READWRITE));
 
   /**
    * GtdTaskList::task-added:
@@ -407,6 +405,27 @@ gtd_task_list_get_provider (GtdTaskList *list)
 }
 
 /**
+ * gtd_task_list_set_provider:
+ * @self: a #GtdTaskList
+ * @provider: (nullable): a #GtdProvider, or %NULL
+ *
+ * Sets the provider of this tasklist.
+ */
+void
+gtd_task_list_set_provider (GtdTaskList *self,
+                            GtdProvider *provider)
+{
+  GtdTaskListPrivate *priv;
+
+  g_assert (GTD_IS_TASK_LIST (self));
+
+  priv = gtd_task_list_get_instance_private (self);
+
+  if (g_set_object (&priv->provider, provider))
+    g_object_notify (G_OBJECT (self), "provider");
+}
+
+/**
  * gtd_task_list_get_tasks:
  * @list: a #GtdTaskList
  *
diff --git a/src/gtd-task-list.h b/src/gtd-task-list.h
index f62659e..6528240 100644
--- a/src/gtd-task-list.h
+++ b/src/gtd-task-list.h
@@ -66,6 +66,9 @@ void                    gtd_task_list_set_name                  (GtdTaskList
 
 GtdProvider*            gtd_task_list_get_provider              (GtdTaskList            *list);
 
+void                    gtd_task_list_set_provider              (GtdTaskList            *self,
+                                                                 GtdProvider            *provider);
+
 GList*                  gtd_task_list_get_tasks                 (GtdTaskList            *list);
 
 void                    gtd_task_list_save_task                 (GtdTaskList            *list,


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