[glib] Support NULL value for g_settings_set_strv()
- From: Ryan Lortie <ryanl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib] Support NULL value for g_settings_set_strv()
- Date: Wed, 2 Jun 2010 02:02:19 +0000 (UTC)
commit b5c8496b4c06fc7be5672e29a771064d3247d0cc
Author: Ryan Lortie <desrt desrt ca>
Date: Wed Jun 2 04:00:58 2010 +0200
Support NULL value for g_settings_set_strv()
Allow easy setting of the empty array that we lost with the last patch.
gio/gsettings.c | 14 +++++++++++---
1 files changed, 11 insertions(+), 3 deletions(-)
---
diff --git a/gio/gsettings.c b/gio/gsettings.c
index 66ff7c4..373b703 100644
--- a/gio/gsettings.c
+++ b/gio/gsettings.c
@@ -1833,13 +1833,14 @@ g_settings_get_strv (GSettings *settings,
* g_settings_set_strv:
* @settings: a #GSettings object
* @key: the name of the key to set
- * @value: the value to set it to
+ * @value: the value to set it to, or %NULL
* @returns: %TRUE if setting the key succeeded,
* %FALSE if the key was not writable
*
* Sets @key in @settings to @value.
*
- * A convenience variant of g_settings_set() for string arrays.
+ * A convenience variant of g_settings_set() for string arrays. If
+ * @value is %NULL, then @key is set to be the empty array.
*
* It is a programmer error to pass a @key that isn't valid for
* @settings or is not of type 'string array'.
@@ -1851,7 +1852,14 @@ g_settings_set_strv (GSettings *settings,
const gchar *key,
const gchar * const *value)
{
- return g_settings_set_value (settings, key, g_variant_new_strv (value, -1));
+ GVariant *array;
+
+ if (value)
+ array = g_variant_new_strv (value, -1);
+ else
+ array = g_variant_new_strv (NULL, 0);
+
+ return g_settings_set_value (settings, key, array);
}
#define __G_SETTINGS_C__
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]