/* Internal read/write utilities, enum/flags conversion, validation {{{1 */
typedef struct
{
- GSettings *settings;
-
const gchar *schema_name;
const gchar *gettext_domain;
const gchar *key;
info->default_value = g_variant_iter_next_value (iter);
endian_fixup (&info->default_value);
info->type = g_variant_get_type (info->default_value);
- info->settings = g_object_ref (settings);
info->key = g_intern_string (key);
while (g_variant_iter_next (iter, "(y*)", &code, &data))
g_variant_unref (info->maximum);
g_variant_unref (info->default_value);
- g_object_unref (info->settings);
}
static gboolean
-g_settings_write_to_backend (GSettingsKeyInfo *info,
+g_settings_write_to_backend (GSettings *settings,
+ GSettingsKeyInfo *info,
GVariant *value)
{
gboolean success;
gchar *path;
- path = g_strconcat (info->settings->priv->path, info->key, NULL);
- success = g_settings_backend_write (info->settings->priv->backend,
- path, value, NULL);
+ path = g_strconcat (settings->priv->path, info->key, NULL);
+ success = g_settings_backend_write (settings->priv->backend, path, value, NULL);
g_free (path);
return success;
}
static GVariant *
-g_settings_read_from_backend (GSettingsKeyInfo *info)
+g_settings_read_from_backend (GSettings *settings,
+ GSettingsKeyInfo *info)
{
GVariant *value;
GVariant *fixup;
gchar *path;
- path = g_strconcat (info->settings->priv->path, info->key, NULL);
- value = g_settings_backend_read (info->settings->priv->backend,
- path, info->type, FALSE);
+ path = g_strconcat (settings->priv->path, info->key, NULL);
+ value = g_settings_backend_read (settings->priv->backend, path, info->type, FALSE);
g_free (path);
if (value != NULL)
g_return_val_if_fail (key != NULL, NULL);
g_settings_get_key_info (&info, settings, key);
- value = g_settings_read_from_backend (&info);
+ value = g_settings_read_from_backend (settings, &info);
if (value == NULL)
value = g_settings_get_translated_default (&info);
return -1;
}
- value = g_settings_read_from_backend (&info);
+ value = g_settings_read_from_backend (settings, &info);
if (value == NULL)
value = g_settings_get_translated_default (&info);
return FALSE;
}
- success = g_settings_write_to_backend (&info, variant);
+ success = g_settings_write_to_backend (settings, &info, variant);
g_settings_free_key_info (&info);
return success;
return -1;
}
- value = g_settings_read_from_backend (&info);
+ value = g_settings_read_from_backend (settings, &info);
if (value == NULL)
value = g_settings_get_translated_default (&info);
return FALSE;
}
- success = g_settings_write_to_backend (&info, variant);
+ success = g_settings_write_to_backend (settings, &info, variant);
g_settings_free_key_info (&info);
return success;
g_settings_free_key_info (&info);
- return g_settings_write_to_backend (&info, value);
+ return g_settings_write_to_backend (settings, &info, value);
}
/**
g_settings_get_key_info (&info, settings, key);
- if ((value = g_settings_read_from_backend (&info)))
+ if ((value = g_settings_read_from_backend (settings, &info)))
{
okay = mapping (value, &result, user_data);
g_variant_unref (value);
typedef struct
{
GSettingsKeyInfo info;
+ GSettings *settings;
GObject *object;
GSettingsBindGetMapping get_mapping;
g_assert (!binding->running);
if (binding->writable_handler_id)
- g_signal_handler_disconnect (binding->info.settings,
+ g_signal_handler_disconnect (binding->settings,
binding->writable_handler_id);
if (binding->key_handler_id)
- g_signal_handler_disconnect (binding->info.settings,
+ g_signal_handler_disconnect (binding->settings,
binding->key_handler_id);
if (g_signal_handler_is_connected (binding->object,
if (binding->destroy)
binding->destroy (binding->user_data);
+ g_object_unref (binding->settings);
+
g_slice_free (GSettingsBinding, binding);
}
GValue value = G_VALUE_INIT;
GVariant *variant;
- g_assert (settings == binding->info.settings);
+ g_assert (settings == binding->settings);
g_assert (key == binding->info.key);
if (binding->running)
g_value_init (&value, binding->property->value_type);
- variant = g_settings_read_from_backend (&binding->info);
+ variant = g_settings_read_from_backend (binding->settings, &binding->info);
if (variant && !binding->get_mapping (&value, variant, binding->user_data))
{
/* silently ignore errors in the user's config database */
return;
}
- g_settings_write_to_backend (&binding->info, variant);
+ g_settings_write_to_backend (binding->settings, &binding->info, variant);
g_variant_unref (variant);
}
g_value_unset (&value);
binding = g_slice_new0 (GSettingsBinding);
g_settings_get_key_info (&binding->info, settings, key);
+ binding->settings = g_object_ref (settings);
binding->object = object;
binding->property = g_object_class_find_property (objectclass, property);
binding->user_data = user_data;