[glib/gsettings] GSettings: schema-related fixes
- From: Ryan Lortie <ryanl src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [glib/gsettings] GSettings: schema-related fixes
- Date: Fri, 18 Sep 2009 18:44:08 +0000 (UTC)
commit 61af9b521f1c83feae31f517939ed09b15ec55ce
Author: Ryan Lortie <desrt desrt ca>
Date: Fri Sep 18 14:38:38 2009 -0400
GSettings: schema-related fixes
gio/gsettings-update-schema-cache.c | 53 +++++++++++++++++++++-------------
gio/gsettings.c | 2 +-
gio/gsettingsschema.c | 9 ++++-
3 files changed, 41 insertions(+), 23 deletions(-)
---
diff --git a/gio/gsettings-update-schema-cache.c b/gio/gsettings-update-schema-cache.c
index 984ed81..4c23fe8 100644
--- a/gio/gsettings-update-schema-cache.c
+++ b/gio/gsettings-update-schema-cache.c
@@ -192,9 +192,6 @@ token_stream_prepare (TokenStream *stream)
return FALSE;
}
- if (spaces == stream->this_indent)
- stream->stream = next_line + spaces;
-
stream->this_type = TOKEN_UNINDENT;
return TRUE;
}
@@ -202,7 +199,11 @@ token_stream_prepare (TokenStream *stream)
else /* spaces == stream->this_indent */
{
stream->stream = next_line + spaces;
- stream->this_type = TOKEN_NEXT;
+
+ if (stream->stream == stream->end)
+ stream->this_type = TOKEN_EOF;
+ else
+ stream->this_type = TOKEN_NEXT;
return TRUE;
}
@@ -595,10 +596,12 @@ read_schema (TokenStream *stream,
case TOKEN_ITEM:
{
gchar *item_name;
- item_name = g_strdup_printf ("%s/*item", schema->name);
+ item_name = g_strdup_printf ("%s//default", schema->name);
if (!read_schema (stream, table, item_name))
goto fail;
- g_free (item_name);
+
+ g_hash_table_insert (schema->children,
+ g_strdup ("/default"), item_name);
}
break;
@@ -614,7 +617,12 @@ read_schema (TokenStream *stream,
break;
default:
- token_stream_error (stream, "expected something here");
+ token_stream_error (stream,
+ "expected %s'key', %s'child', or unindent",
+ schema->base_path ? "'path', " : "",
+ g_hash_table_lookup (schema->children,
+ "/default") ?
+ "'item', " : "");
goto fail;
}
@@ -646,25 +654,30 @@ static gboolean
read_file (TokenStream *stream,
Cache *cache)
{
- TokenType type;
+ TokenType type = TOKEN_INVALID;
- for (;;)
+ while (type != TOKEN_EOF)
{
- if (!token_stream_get (stream, &type, NULL))
- return FALSE;
-
- if (type == TOKEN_EOF)
- return TRUE;
-
- if (type != TOKEN_SCHEMA)
+ switch (token_stream_consume_symbol (stream))
{
- token_stream_error (stream, "expected `schema' or end of file");
- return FALSE;
+ case TOKEN_SCHEMA:
+ if (!read_schema (stream, cache->schemas, NULL))
+ return FALSE;
+ break;
+
+ default:
+ token_stream_error (stream, "expected 'schema' declaration");
+ return FALSE;
+
+ break;
}
- if (!read_schema (stream, cache->schemas, NULL))
- return FALSE;
+ if (!token_stream_get (stream, &type, NULL))
+ g_assert_not_reached ();
+ g_assert (type == TOKEN_EOF || type == TOKEN_NEXT);
}
+
+ return TRUE;
}
static GVariant *
diff --git a/gio/gsettings.c b/gio/gsettings.c
index 988024d..81b2323 100644
--- a/gio/gsettings.c
+++ b/gio/gsettings.c
@@ -413,7 +413,7 @@ g_settings_get_settings (GSettings *settings,
if (schema_name == NULL)
{
schema_name = g_settings_schema_get_schema (settings->priv->schema,
- "//default");
+ "/default");
if G_UNLIKELY (schema_name == NULL)
g_error ("Schema has no child schema named '%s' and no "
diff --git a/gio/gsettingsschema.c b/gio/gsettingsschema.c
index 4d87980..29e54fe 100644
--- a/gio/gsettingsschema.c
+++ b/gio/gsettingsschema.c
@@ -128,11 +128,16 @@ g_settings_schema_type_check_key (GSettingsSchema *schema,
const gchar *key,
GVariant *value)
{
+ GVariantType *type;
const gchar *fmt;
+ gboolean match;
fmt = g_settings_schema_get_key_format (schema, key);
- /* XXX arg. fmt->type is not public API. fix this somehow. */
- return g_variant_matches (value, G_VARIANT_TYPE (fmt));
+ type = g_variant_format_string_scan_type (fmt, NULL, NULL);
+ match = g_variant_matches (value, type);
+ g_variant_type_free (type);
+
+ return match;
}
gboolean
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]