Remove length parameter for g_settings_[gs]et_strv

Length of the array is redundant since it's NULL-terminated. This is not
consistent with many GLib and GTK+ functions, and adds complexity with
no real gain, while these convenience functions should be kept simple.

Closes bug #620312
This commit is contained in:
Milan Bouchet-Valat 2010-06-01 23:16:19 +02:00 committed by Ryan Lortie
parent dc7b1c5b42
commit bf9edb5cd5
2 changed files with 6 additions and 12 deletions

View File

@ -1804,7 +1804,6 @@ g_settings_set_boolean (GSettings *settings,
* g_settings_get_strv: * g_settings_get_strv:
* @settings: a #GSettings object * @settings: a #GSettings object
* @key: the key to get the value for * @key: the key to get the value for
* @length: return location for the length of the result, or %NULL
* @returns: a newly-allocated, %NULL-terminated array of strings * @returns: a newly-allocated, %NULL-terminated array of strings
* *
* Gets the value that is stored at @key in @settings. * Gets the value that is stored at @key in @settings.
@ -1818,14 +1817,13 @@ g_settings_set_boolean (GSettings *settings,
*/ */
gchar ** gchar **
g_settings_get_strv (GSettings *settings, g_settings_get_strv (GSettings *settings,
const gchar *key, const gchar *key)
gsize *length)
{ {
GVariant *value; GVariant *value;
gchar **result; gchar **result;
value = g_settings_get_value (settings, key); value = g_settings_get_value (settings, key);
result = g_variant_dup_strv (value, length); result = g_variant_dup_strv (value, NULL);
g_variant_unref (value); g_variant_unref (value);
return result; return result;
@ -1836,7 +1834,6 @@ g_settings_get_strv (GSettings *settings,
* @settings: a #GSettings object * @settings: a #GSettings object
* @key: the name of the key to set * @key: the name of the key to set
* @value: the value to set it to * @value: the value to set it to
* @length: the length of the @value array, or -1
* @returns: %TRUE if setting the key succeeded, * @returns: %TRUE if setting the key succeeded,
* %FALSE if the key was not writable * %FALSE if the key was not writable
* *
@ -1852,10 +1849,9 @@ g_settings_get_strv (GSettings *settings,
gboolean gboolean
g_settings_set_strv (GSettings *settings, g_settings_set_strv (GSettings *settings,
const gchar *key, const gchar *key,
const gchar * const *value, const gchar * const *value)
gssize length)
{ {
return g_settings_set_value (settings, key, g_variant_new_strv (value, length)); return g_settings_set_value (settings, key, g_variant_new_strv (value, -1));
} }
#define __G_SETTINGS_C__ #define __G_SETTINGS_C__

View File

@ -113,12 +113,10 @@ gboolean g_settings_set_double (GSettin
const gchar *key, const gchar *key,
gdouble value); gdouble value);
gchar ** g_settings_get_strv (GSettings *settings, gchar ** g_settings_get_strv (GSettings *settings,
const gchar *key, const gchar *key);
gsize *length);
gboolean g_settings_set_strv (GSettings *settings, gboolean g_settings_set_strv (GSettings *settings,
const gchar *key, const gchar *key,
const gchar *const *value, const gchar *const *value);
gssize length);
GSettings * g_settings_get_child (GSettings *settings, GSettings * g_settings_get_child (GSettings *settings,
const gchar *name); const gchar *name);