[ekiga/ds-gsettings3] Settings: Added C++ convenience wrappers.



commit f97d0b61035636e0a98de5f54c8a3e3bbc2993ac
Author: Damien Sandras <dsandras beip be>
Date:   Sun Oct 6 19:53:15 2013 +0200

    Settings: Added C++ convenience wrappers.
    
    This allows more efficient memory management and prevents stupid
    conversions between gchar* and std::string.

 lib/ekiga-settings.h |   38 ++++++++++++++++++++++++++++++++++++++
 1 files changed, 38 insertions(+), 0 deletions(-)
---
diff --git a/lib/ekiga-settings.h b/lib/ekiga-settings.h
index 8455af9..968a7cb 100644
--- a/lib/ekiga-settings.h
+++ b/lib/ekiga-settings.h
@@ -48,6 +48,7 @@
 
 #define USER_INTERFACE "org.gnome." PACKAGE_NAME ".general.user-interface"
 
+#define PERSONAL_DATA_SCHEMA "org.gnome." PACKAGE_NAME ".general.personal-data"
 #define SOUND_EVENTS_SCHEMA "org.gnome." PACKAGE_NAME ".general.sound-events"
 #define AUDIO_DEVICES_SCHEMA "org.gnome." PACKAGE_NAME ".devices.audio"
 #define VIDEO_DEVICES_SCHEMA "org.gnome." PACKAGE_NAME ".devices.video"
@@ -91,6 +92,43 @@ public:
       return gsettings;
     }
 
+    const std::string get_string (const std::string & key)
+    {
+      gchar *value = g_settings_get_string (gsettings, key.c_str ());
+      std::string result;
+
+      if (value)
+       result = value;
+
+      g_free (value);
+      return result;
+    }
+
+    void set_string (const std::string & key, const std::string & value)
+    {
+      g_settings_set_string (gsettings, key.c_str (), value.c_str ());
+    }
+    
+    int get_int (const std::string & key)
+    {
+      return g_settings_get_int (gsettings, key.c_str ());
+    }
+
+    void set_int (const std::string & key, int i)
+    {
+      g_settings_set_int (gsettings, key.c_str (), i);
+    }
+
+    bool get_bool (const std::string & key)
+    {
+      return g_settings_get_boolean (gsettings, key.c_str ());
+    }
+
+    void set_bool (const std::string & key, bool i)
+    {
+      g_settings_set_boolean (gsettings, key.c_str (), i);
+    }
+
     boost::signals2::signal<void(std::string)> changed;
 
 private:


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