[gnome-todo/wip/lists] storage: add URL property



commit 632237c990ba62f8f2a87fa3f180c0bde2b2cfae
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Mon Jun 15 10:32:13 2015 -0300

    storage: add URL property

 src/gtd-storage.c |   67 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 src/gtd-storage.h |    5 ++++
 2 files changed, 72 insertions(+), 0 deletions(-)
---
diff --git a/src/gtd-storage.c b/src/gtd-storage.c
index bfcb759..40f82d6 100644
--- a/src/gtd-storage.c
+++ b/src/gtd-storage.c
@@ -28,6 +28,7 @@ typedef struct
   gchar                 *name;
   gchar                 *provider;
   gchar                 *provider_name;
+  gchar                 *url;
 
   gint                   enabled : 1;
   gint                   is_default : 1;
@@ -52,6 +53,7 @@ enum {
   PROP_NAME,
   PROP_PROVIDER,
   PROP_PROVIDER_NAME,
+  PROP_URL,
   LAST_PROP
 };
 
@@ -108,6 +110,10 @@ gtd_storage_get_property (GObject    *object,
       g_value_set_string (value, self->priv->provider_name);
       break;
 
+    case PROP_URL:
+      g_value_set_string (value, self->priv->url);
+      break;
+
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
     }
@@ -152,6 +158,10 @@ gtd_storage_set_property (GObject      *object,
       gtd_storage_set_provider_name (self, g_value_get_string (value));
       break;
 
+    case PROP_URL:
+      gtd_storage_set_url (self, g_value_get_string (value));
+      break;
+
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
     }
@@ -263,6 +273,20 @@ gtd_storage_class_init (GtdStorageClass *klass)
                              _("The name of the provider of the storage location."),
                              NULL,
                              G_PARAM_READWRITE));
+
+  /**
+   * GtdStorage::url:
+   *
+   * The url of this storage.
+   */
+  g_object_class_install_property (
+        object_class,
+        PROP_URL,
+        g_param_spec_string ("url",
+                             _("Url of the storage"),
+                             _("The url of the storage location."),
+                             NULL,
+                             G_PARAM_READWRITE));
 }
 
 static void
@@ -558,6 +582,49 @@ gtd_storage_set_provider_name (GtdStorage  *storage,
 }
 
 /**
+ * gtd_storage_get_url:
+ * @storage: a #GtdStorage
+ *
+ * Retrieves the URL of @storage.
+ *
+ * Returns: (transfer none): the url of @storage, or %NULL if none is set.
+ */
+const gchar*
+gtd_storage_get_url (GtdStorage *storage)
+{
+  g_return_val_if_fail (GTD_IS_STORAGE (storage), NULL);
+
+  return storage->priv->url;
+}
+
+/**
+ * gtd_storage_set_url:
+ *
+ * Sets the #GtdStorage::url property of @storage.
+ *
+ * Returns:
+ */
+void
+gtd_storage_set_url (GtdStorage  *storage,
+                     const gchar *url)
+{
+  GtdStoragePrivate *priv;
+
+  g_return_if_fail (GTD_IS_STORAGE (storage));
+
+  priv = storage->priv;
+
+  if (g_strcmp0 (priv->url, url) != 0)
+    {
+      g_clear_pointer (&priv->url, g_free);
+
+      priv->url = g_strdup (url);
+
+      g_object_notify (G_OBJECT (storage), "url");
+    }
+}
+
+/**
  * gtd_storage_compare:
  * @a: a #GtdStorage
  * @b: a #GtdStorage
diff --git a/src/gtd-storage.h b/src/gtd-storage.h
index b193fd0..b262248 100644
--- a/src/gtd-storage.h
+++ b/src/gtd-storage.h
@@ -64,6 +64,11 @@ const gchar*       gtd_storage_get_provider_name                 (GtdStorage
 void               gtd_storage_set_provider_name                 (GtdStorage         *storage,
                                                                   const gchar        *provider_name);
 
+const gchar*       gtd_storage_get_url                           (GtdStorage         *storage);
+
+void               gtd_storage_set_url                           (GtdStorage         *storage,
+                                                                  const gchar        *url);
+
 gint               gtd_storage_compare                           (GtdStorage         *a,
                                                                   GtdStorage         *b);
 


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