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.
- 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));
g_settings_get_child (GSettings *settings,
const gchar *name)
{
g_settings_get_child (GSettings *settings,
const gchar *name)
{
- GVariant *child_schema;
+ const gchar *child_schema;
gchar *child_path;
gchar *child_name;
GSettings *child;
gchar *child_path;
gchar *child_name;
GSettings *child;
g_return_val_if_fail (G_IS_SETTINGS (settings), NULL);
child_name = g_strconcat (name, "/", NULL);
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,
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);
"path", child_path,
NULL);
- g_variant_unref (child_schema);
g_free (child_path);
g_free (child_name);
g_free (child_path);
g_free (child_name);
g_type_class_add_private (class, sizeof (GSettingsSchemaPrivate));
}
g_type_class_add_private (class, sizeof (GSettingsSchemaPrivate));
}
g_settings_schema_get_string (GSettingsSchema *schema,
const gchar *key)
{
const gchar *result = NULL;
GVariant *value;
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);
{
result = g_variant_get_string (value, NULL);
g_variant_unref (value);
const gchar *key,
GVariant **options)
{
const gchar *key,
GVariant **options)
{
+ GVariant *variant, *value;
#if G_BYTE_ORDER == G_BIG_ENDIAN
#if G_BYTE_ORDER == G_BIG_ENDIAN
- GVariant *variant, *tmp;
- tmp = gvdb_table_get_value (schema->priv->table, key, options);
+ tmp = gvdb_table_get_value (schema->priv->table, key);
-
- /* NOTE: no options have byteswapped data in them at the moment */
-
- return variant;
- return gvdb_table_get_value (schema->priv->table, key, options);
+ variant = gvdb_table_get_value (schema->priv->table, key);
+
+ 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;
G_GNUC_INTERNAL
const GQuark * g_settings_schema_list (GSettingsSchema *schema,
gint *n_items);
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);