[ekiga/ds-gsettings3] Added documentation as well as new GSList convenience methods.



commit b9e9516926990c70a851d0bbace369632c18331b
Author: Damien Sandras <dsandras beip be>
Date:   Sun Oct 20 18:16:53 2013 +0200

    Added documentation as well as new GSList convenience methods.

 lib/ekiga-settings.h |   33 +++++++++++++++++++++++++++++++--
 1 files changed, 31 insertions(+), 2 deletions(-)
---
diff --git a/lib/ekiga-settings.h b/lib/ekiga-settings.h
index 3e7be6d..fde6aee 100644
--- a/lib/ekiga-settings.h
+++ b/lib/ekiga-settings.h
@@ -65,12 +65,18 @@
 #define AUDIO_CODECS_SCHEMA CODECS_SCHEMA ".audio"
 #define VIDEO_CODECS_SCHEMA CODECS_SCHEMA ".video"
 
+#define CONTACTS_SCHEMA "org.gnome." PACKAGE_NAME ".contacts"
+
 namespace Ekiga {
 
   /*
-   * This is a C++ wrapper around the GSettings signal function.
+   * This is a C++ wrapper class around GSettings.
+   *
+   * It is recommended to use it in C++ code, but also
+   * when defining GObjects.
    *
-   * Please use it in C++ code.
+   * When defining GObjects, you can use the standard g_signal_connect
+   * instead of the "changed" C++ signal.
    */
   class Settings : boost::noncopyable {
 
@@ -163,6 +169,29 @@ public:
       g_strfreev (values);
     }
 
+    GSList* get_slist (const std::string & key)
+    {
+      GSList* list = NULL;
+      gchar **values = g_settings_get_strv (gsettings, key.c_str ());
+      if (values) {
+       for (int i = 0 ; values[i] ; i++) {
+           list = g_slist_append (list, g_strdup (values[i]));
+       }
+      }
+      g_strfreev (values);
+
+      return list;
+    }
+
+    void set_slist (const std::string & key, const GSList *list)
+    {
+      GArray* array = g_array_new (TRUE, TRUE, sizeof (gchar *));
+      for (const GSList *l = list ; l ; l = g_slist_next (l))
+       array = g_array_append_val (array, l->data);
+      g_settings_set_strv (gsettings, key.c_str (), (const gchar **) array->data);
+      g_array_free (array, TRUE);
+    }
+
     boost::signals2::signal<void(std::string)> changed;
 
 private:


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