mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-01-24 13:06:14 +01:00
Handle non-readable/-writable properties when binding
And document readability/writability requirements for binding flags.
This commit is contained in:
parent
8a988e8e88
commit
ccf9361490
@ -1326,6 +1326,19 @@ g_settings_bind_with_mapping (GSettings *settings,
|
||||
return;
|
||||
}
|
||||
|
||||
if ((flags & G_SETTINGS_BIND_GET) && (binding->property->flags & G_PARAM_WRITABLE) == 0)
|
||||
{
|
||||
g_critical ("g_settings_bind: property '%s' on class '%s' is not writable",
|
||||
property, G_OBJECT_TYPE_NAME (object));
|
||||
return;
|
||||
}
|
||||
if ((flags & G_SETTINGS_BIND_SET) && (binding->property->flags & G_PARAM_READABLE) == 0)
|
||||
{
|
||||
g_critical ("g_settings_bind: property '%s' on class '%s' is not readable",
|
||||
property, G_OBJECT_TYPE_NAME (object));
|
||||
return;
|
||||
}
|
||||
|
||||
{
|
||||
GVariant *value;
|
||||
|
||||
@ -1363,7 +1376,8 @@ g_settings_bind_with_mapping (GSettings *settings,
|
||||
|
||||
sensitive = g_object_class_find_property (objectclass, "sensitive");
|
||||
|
||||
if (sensitive && sensitive->value_type == G_TYPE_BOOLEAN)
|
||||
if (sensitive && sensitive->value_type == G_TYPE_BOOLEAN &&
|
||||
(sensitive->flags & G_PARAM_WRITABLE))
|
||||
g_settings_bind_writable (settings, binding->key,
|
||||
object, "sensitive", FALSE);
|
||||
}
|
||||
@ -1479,6 +1493,21 @@ g_settings_bind_writable (GSettings *settings,
|
||||
{
|
||||
GSettingsWritableBinding *binding;
|
||||
gchar *detailed_signal;
|
||||
GParamSpec *pspec;
|
||||
|
||||
pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (object), property);
|
||||
if (pspec == NULL)
|
||||
{
|
||||
g_critical ("g_settings_bind_writable: no property '%s' on class '%s'",
|
||||
property, G_OBJECT_TYPE_NAME (object));
|
||||
return;
|
||||
}
|
||||
if ((pspec->flags & G_PARAM_WRITABLE) == 0)
|
||||
{
|
||||
g_critical ("g_settings_bind_writable: property '%s' on class '%s' is not writable",
|
||||
property, G_OBJECT_TYPE_NAME (object));
|
||||
return;
|
||||
}
|
||||
|
||||
binding = g_slice_new (GSettingsWritableBinding);
|
||||
binding->settings = g_object_ref (settings);
|
||||
|
@ -164,8 +164,10 @@ typedef gboolean (*GSettingsBindGetMapping) (GValue
|
||||
/**
|
||||
* GSettingsBindFlags:
|
||||
* @G_SETTINGS_BIND_DEFAULT: Equivalent to <literal>G_SETTINGS_BIND_GET|G_SETTINGS_BIND_SET</literal>
|
||||
* @G_SETTINGS_BIND_GET: Update the #GObject property when the setting changes
|
||||
* @G_SETTINGS_BIND_SET: Update the setting when the #GObject property changes
|
||||
* @G_SETTINGS_BIND_GET: Update the #GObject property when the setting changes.
|
||||
* It is an error to use this flag if the property is not writable.
|
||||
* @G_SETTINGS_BIND_SET: Update the setting when the #GObject property changes.
|
||||
* It is an error to use this flag if the property is not readable.
|
||||
* @G_SETTINGS_BIND_NO_SENSITIVITY: Do not try to bind a "sensitivity" property to the writability of the setting
|
||||
* @G_SETTINGS_BIND_GET_NO_CHANGES: When set in addition to #G_SETTINGS_BIND_GET, set the #GObject property
|
||||
* value initially from the setting, but do not listen for changes of the setting
|
||||
|
Loading…
Reference in New Issue
Block a user