GSettings: store (default, options) in gvdb

gvdb just dropped the ability to have a separate "options" field.  We
now store the options into a GVariant along with the default value.

For now, we use a small shim in GSettingsSchema in order not to touch
too much code.  A more complete rewrite will follow.

This represents a change to the schema file format with another likely
to follow.  glib-compile-schemas needs to be re-run after installing
this change.
This commit is contained in:
Ryan Lortie
2010-06-10 13:49:57 -04:00
parent 7300702179
commit 3a062d2e33
4 changed files with 27 additions and 20 deletions

View File

@@ -112,14 +112,14 @@ g_settings_schema_class_init (GSettingsSchemaClass *class)
g_type_class_add_private (class, sizeof (GSettingsSchemaPrivate));
}
static const gchar *
const gchar *
g_settings_schema_get_string (GSettingsSchema *schema,
const gchar *key)
{
const gchar *result = NULL;
GVariant *value;
if ((value = gvdb_table_get_value (schema->priv->table, key, NULL)))
if ((value = gvdb_table_get_value (schema->priv->table, key)))
{
result = g_variant_get_string (value, NULL);
g_variant_unref (value);
@@ -167,10 +167,11 @@ g_settings_schema_get_value (GSettingsSchema *schema,
const gchar *key,
GVariant **options)
{
GVariant *variant, *value;
#if G_BYTE_ORDER == G_BIG_ENDIAN
GVariant *variant, *tmp;
GVariant *tmp;
tmp = gvdb_table_get_value (schema->priv->table, key, options);
tmp = gvdb_table_get_value (schema->priv->table, key);
if (tmp)
{
@@ -179,13 +180,19 @@ g_settings_schema_get_value (GSettingsSchema *schema,
}
else
variant = NULL;
/* NOTE: no options have byteswapped data in them at the moment */
return variant;
#else
return gvdb_table_get_value (schema->priv->table, key, options);
variant = gvdb_table_get_value (schema->priv->table, key);
#endif
if (variant == NULL)
return NULL;
value = g_variant_get_child_value (variant, 0);
if (options != NULL)
*options = g_variant_get_child_value (variant, 1);
g_variant_unref (variant);
return value;
}
const gchar *