nemiver r854 - in branches/0.5: . src/confmgr



Author: dodji
Date: Sat Jun 21 12:38:47 2008
New Revision: 854
URL: http://svn.gnome.org/viewvc/nemiver?rev=854&view=rev

Log:
[gconfmgr] support values of type 'list'



Modified:
   branches/0.5/ChangeLog
   branches/0.5/src/confmgr/nmv-gconf-mgr.cc
   branches/0.5/src/confmgr/nmv-i-conf-mgr.h

Modified: branches/0.5/src/confmgr/nmv-gconf-mgr.cc
==============================================================================
--- branches/0.5/src/confmgr/nmv-gconf-mgr.cc	(original)
+++ branches/0.5/src/confmgr/nmv-gconf-mgr.cc	Sat Jun 21 12:38:47 2008
@@ -56,8 +56,13 @@
     bool get_key_value (const UString &a_key, int &a_value);
     void set_key_value (const UString &a_key, int a_value);
 
-    bool get_key_value (const UString &a_key, double &a_value) ;
-    void set_key_value (const UString &a_key, double a_value) ;
+    bool get_key_value (const UString &a_key, double &a_value);
+    void set_key_value (const UString &a_key, double a_value);
+
+    bool get_key_value (const UString &a_key,
+                                std::list<UString> &a_value);
+    void set_key_value (const UString &a_key,
+                                const std::list<UString> &a_value);
 
     sigc::signal<void, const UString&, IConfMgr::Value&>& value_changed_signal ();
 
@@ -313,7 +318,72 @@
                             &err);
     GErrorSafePtr error (err);
     if (error) {
-        THROW (error->message) ;
+        THROW (error->message);
+    }
+}
+
+bool
+GConfMgr::get_key_value (const UString &a_key,
+                         std::list<UString> &a_value)
+{
+    bool result=false;
+    THROW_IF_FAIL (m_gconf_client);
+
+    GError *err=NULL;
+    GSList *list=NULL;
+    list = gconf_client_get_list (m_gconf_client,
+                                  a_key.c_str (),
+                                  GCONF_VALUE_STRING,
+                                  &err);
+    GErrorSafePtr error (err);
+    if (error) {
+        LOG_ERROR (error->message);
+        result = false;
+        goto out;
+    }
+    for (GSList *cur = list; cur; cur = cur->next) {
+        a_value.push_back ((char*)cur->data);
+    }
+    result = true;
+out:
+    if (list) {
+        for (GSList *cur = list; cur; cur = cur->next) {
+            g_free (cur->data);
+        }
+        g_slist_free (list);
+        list = NULL;
+    }
+    return result;
+}
+
+void
+GConfMgr::set_key_value (const UString &a_key,
+                         const std::list<UString> &a_value)
+{
+    if (a_value.empty ())
+        return;
+    THROW_IF_FAIL (m_gconf_client);
+    GSList *list=NULL;
+    std::list<UString>::const_iterator it;
+    for (it = a_value.begin (); it != a_value.end (); ++it) {
+        list = g_slist_prepend (list, g_strdup (it->c_str ()));
+    }
+    THROW_IF_FAIL (list);
+    list = g_slist_reverse (list);
+    THROW_IF_FAIL (list);
+
+    GError *err=NULL;
+    gconf_client_set_list (m_gconf_client, a_key.c_str (),
+                           GCONF_VALUE_STRING,
+                           list, &err);
+    for (GSList *cur=list; cur; cur = cur->next) {
+        g_free (cur->data);
+    }
+    g_slist_free (list);
+    list = NULL;
+    GErrorSafePtr error (err);
+    if (error) {
+        THROW (error->message);
     }
 }
 

Modified: branches/0.5/src/confmgr/nmv-i-conf-mgr.h
==============================================================================
--- branches/0.5/src/confmgr/nmv-i-conf-mgr.h	(original)
+++ branches/0.5/src/confmgr/nmv-i-conf-mgr.h	Sat Jun 21 12:38:47 2008
@@ -75,6 +75,11 @@
     virtual bool get_key_value (const UString &a_key, double &a_value) = 0;
     virtual void set_key_value (const UString &a_key, double a_value) = 0;
 
+    virtual bool get_key_value (const UString &a_key,
+                                std::list<UString> &a_value) = 0;
+    virtual void set_key_value (const UString &a_key,
+                                const std::list<UString> &a_value) = 0;
+
     virtual sigc::signal<void, const UString&, IConfMgr::Value&>&
                                                     value_changed_signal () = 0;
 



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