Commit 3a062d2e authored by Allison Karlitskaya's avatar Allison Karlitskaya

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.
parent 73007021
......@@ -551,10 +551,9 @@ end_element (GMarkupParseContext *context,
state->choices = NULL;
}
gvdb_item_set_value (state->key, state->value);
gvdb_item_set_options (state->key,
g_variant_builder_end (&state->key_options));
gvdb_item_set_value (state->key,
g_variant_new ("(*a{sv})", state->value,
&state->key_options));
state->value = NULL;
}
......
......@@ -991,7 +991,7 @@ GSettings *
g_settings_get_child (GSettings *settings,
const gchar *name)
{
GVariant *child_schema;
const gchar *child_schema;
gchar *child_path;
gchar *child_name;
GSettings *child;
......@@ -999,19 +999,17 @@ g_settings_get_child (GSettings *settings,
g_return_val_if_fail (G_IS_SETTINGS (settings), NULL);
child_name = g_strconcat (name, "/", NULL);
child_schema = g_settings_schema_get_value (settings->priv->schema,
child_name, NULL);
if (child_schema == NULL ||
!g_variant_is_of_type (child_schema, G_VARIANT_TYPE_STRING))
child_schema = g_settings_schema_get_string (settings->priv->schema,
child_name);
if (child_schema == NULL)
g_error ("Schema '%s' has no child '%s'",
settings->priv->schema_name, name);
child_path = g_strconcat (settings->priv->path, child_name, NULL);
child = g_object_new (G_TYPE_SETTINGS,
"schema", g_variant_get_string (child_schema, NULL),
"schema", child_schema,
"path", child_path,
NULL);
g_variant_unref (child_schema);
g_free (child_path);
g_free (child_name);
......
......@@ -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 *
......
......@@ -70,6 +70,9 @@ gboolean g_settings_schema_has_key (GSettin
G_GNUC_INTERNAL
const GQuark * g_settings_schema_list (GSettingsSchema *schema,
gint *n_items);
G_GNUC_INTERNAL
const gchar * g_settings_schema_get_string (GSettingsSchema *schema,
const gchar *key);
G_END_DECLS
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment