Bug 631263 - GSettings needs range/choice APIs

Add g_settings_get_range() to describe the possible values that may be
provided to g_settings_set_value() without causing an error.

Add a test case.
This commit is contained in:
Ryan Lortie
2010-10-04 02:58:46 -04:00
parent 833e389516
commit d6d76783ae
4 changed files with 159 additions and 1 deletions

View File

@@ -260,6 +260,37 @@ strinfo_string_from_alias (const guint32 *strinfo,
return 1 + (const gchar *) &strinfo[GUINT32_TO_LE (strinfo[index]) + 1];
}
G_GNUC_UNUSED static GVariant *
strinfo_enumerate (const guint32 *strinfo,
guint length)
{
GVariantBuilder builder;
const gchar *ptr, *end;
ptr = (gpointer) strinfo;
end = ptr + 4 * length;
ptr += 4;
g_variant_builder_init (&builder, G_VARIANT_TYPE_STRING_ARRAY);
while (ptr < end)
{
/* don't include aliases */
if (*ptr == '\xff')
g_variant_builder_add (&builder, "s", ptr + 1);
/* find the end of this string */
ptr = memchr (ptr, '\xff', end - ptr);
g_assert (ptr != NULL);
/* skip over the int to the next string */
ptr += 5;
}
return g_variant_builder_end (&builder);
}
G_GNUC_UNUSED static void
strinfo_builder_append_item (GString *builder,
const gchar *string,