[glibmm] Settings: Add [get|set]_strv().



commit 2b782d7786bb061bb3ea4d3fe9156729851a0ed7
Author: José Alburquerque <jaalburqu svn gnome org>
Date:   Fri May 28 11:01:24 2010 -0400

    	Settings: Add [get|set]_strv().
    
    	* gio/src/settings.ccg:
    	* gio/src/settings.hg: Added [get|set]_strv().  Also added a
    	get_child() const version.  Reordered signal wrappings to reflect the
    	order of the C API docs.

 ChangeLog            |    9 +++++++++
 gio/src/settings.ccg |   15 ++++++++++++++-
 gio/src/settings.hg  |   31 ++++++++++++++++++++++++++++---
 3 files changed, 51 insertions(+), 4 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index a33a35c..b785a7b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2010-05-28  José Alburquerque  <jaalburqu svn gnome org>
+
+	Settings: Add [get|set]_strv().
+
+	* gio/src/settings.ccg:
+	* gio/src/settings.hg: Added [get|set]_strv().  Also added a
+	get_child() const version.  Reordered signal wrappings to reflect the
+	order of the C API docs.
+
 2010-05-27  José Alburquerque  <jaalburqu svn gnome org>
 
 	OptionGroup: set_translate_slot(): Rename to set_translate_func().
diff --git a/gio/src/settings.ccg b/gio/src/settings.ccg
index 14f649c..a99c880 100644
--- a/gio/src/settings.ccg
+++ b/gio/src/settings.ccg
@@ -9,6 +9,20 @@ Glib::RefPtr<Settings> Settings::create_with_context(const Glib::ustring& schema
     return Glib::RefPtr<Settings>(new Settings(g_settings_new_with_context(schema.c_str(), context.c_str())));
 }
 
+Glib::ArrayHandle<Glib::ustring> Settings::get_strv(const Glib::ustring& key)
+  const
+{
+  gchar** result = g_settings_get_strv(const_cast<GSettings*>(gobj()),
+    key.c_str(), 0);
+  return Glib::ArrayHandle<Glib::ustring>(result, Glib::OWNERSHIP_DEEP);
+}
+
+bool Settings::set_strv(const Glib::ustring& key,
+  const Glib::ArrayHandle<Glib::ustring>& value)
+{
+  return g_settings_set_strv(gobj(), key.c_str(), value.data(), value.size());
+}
+
 void Settings::bind(const Glib::ustring& key,
                     const Glib::PropertyProxy_Base& property_proxy,
                     SettingsBindFlags flags)
@@ -23,5 +37,4 @@ void Settings::bind_writable(const Glib::ustring& key,
     bind_writable(key, property_proxy.get_object(), property_proxy.get_name(), inverted);
 }
 
-
 }
diff --git a/gio/src/settings.hg b/gio/src/settings.hg
index ea7026f..55acb27 100644
--- a/gio/src/settings.hg
+++ b/gio/src/settings.hg
@@ -59,9 +59,31 @@ public:
   _WRAP_METHOD(void set_string(const Glib::ustring& key, const Glib::ustring& value), g_settings_set_string)
   _WRAP_METHOD(double get_double(const Glib::ustring& key) const, g_settings_get_double)
   _WRAP_METHOD(void set_double(const Glib::ustring& key, double value), g_settings_set_double)
-  // FIXME: get/set strv
+
+  /** Gets the value that is stored at key in the settings.
+   * It is a programmer error to pass a @a key that isn't valid for settings or
+   * is not of type 'string array'.
+   *
+   * @param key The key to get the value for.
+   * @return a newly-allocated, <tt>0</tt>-terminated array of strings.
+   */
+  Glib::ArrayHandle<Glib::ustring> get_strv(const Glib::ustring& key) const;
+  _IGNORE(g_settings_get_strv)
+
+  /** Sets @a key in the settings to @a value.
+   * It is a programmer error to pass a @a key  that isn't valid for settings
+   * or is not of type 'string array'.
+   *
+   * @param key The name of the key to set.
+   * @param value The value to set it to.
+   * @return <tt>true</tt> if setting the key succeeded, <tt>false</tt> if the
+   * key was not writable.
+   */
+  bool set_strv(const Glib::ustring& key,
+    const Glib::ArrayHandle<Glib::ustring>& value);
 
   _WRAP_METHOD(Glib::RefPtr<Settings> get_child(const Glib::ustring& name), g_settings_get_child)
+  _WRAP_METHOD(Glib::RefPtr<const Settings> get_child(const Glib::ustring& name) const, g_settings_get_child, constversion)
   _WRAP_METHOD(bool is_writable(const Glib::ustring& key) const, g_settings_is_writable)
 
   _WRAP_METHOD(void delay(), g_settings_delay)
@@ -77,10 +99,13 @@ public:
   void bind_writable(const Glib::ustring& key, const Glib::PropertyProxy_Base& property_proxy, bool inverted=false);
   // FIXME: unbind is not actually a class method
 
+  //TODO?: _WRAP_SIGNAL(bool change_event(const Glib::ArrayHandle<Glib::QueryQuark>& keys, int n_keys), "change-event")
+
 #m4 _CONVERSION(`const char*',`const Glib::ustring&',__GCHARP_TO_USTRING)
-  _WRAP_SIGNAL(void writable_changed(const Glib::ustring& key), writable_changed)
-  _WRAP_SIGNAL(void changed(const Glib::ustring& key), changed)
+  _WRAP_SIGNAL(void changed(const Glib::ustring& key), "changed")
 
+  //TODO?: _WRAP_SIGNAL(bool writable_change_event(guint key), "writable-change-event")
+  _WRAP_SIGNAL(void writable_changed(const Glib::ustring& key), writable_changed)
 };
 
 } // namespace Gio



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