mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-08-01 15:03:39 +02:00
Fix overloading of "source" and "target" terminology in GBinding
GBindingTransformFunc called its arguments "source_value" and "target_value", but in the transform_from function of a bidirectional binding, "source_value" comes from the target object, and "target_value" comes from the source object, which quickly gets confusing if you need to use g_binding_get_source(), etc, in the function. Of course developers can call their transform function arguments whatever they want, but many will copy from the headers/docs to start out, so use less confusing names here ("from_value" and "to_value"). Also, fix the documentation to describe the bidirectional case correctly. https://bugzilla.gnome.org/show_bug.cgi?id=709440
This commit is contained in:
@@ -360,8 +360,8 @@ on_source_notify (GObject *gobject,
|
||||
GBinding *binding)
|
||||
{
|
||||
const gchar *p_name;
|
||||
GValue source_value = G_VALUE_INIT;
|
||||
GValue target_value = G_VALUE_INIT;
|
||||
GValue from_value = G_VALUE_INIT;
|
||||
GValue to_value = G_VALUE_INIT;
|
||||
gboolean res;
|
||||
|
||||
if (binding->is_frozen)
|
||||
@@ -372,27 +372,27 @@ on_source_notify (GObject *gobject,
|
||||
if (p_name != binding->source_property)
|
||||
return;
|
||||
|
||||
g_value_init (&source_value, G_PARAM_SPEC_VALUE_TYPE (binding->source_pspec));
|
||||
g_value_init (&target_value, G_PARAM_SPEC_VALUE_TYPE (binding->target_pspec));
|
||||
g_value_init (&from_value, G_PARAM_SPEC_VALUE_TYPE (binding->source_pspec));
|
||||
g_value_init (&to_value, G_PARAM_SPEC_VALUE_TYPE (binding->target_pspec));
|
||||
|
||||
g_object_get_property (binding->source, binding->source_pspec->name, &source_value);
|
||||
g_object_get_property (binding->source, binding->source_pspec->name, &from_value);
|
||||
|
||||
res = binding->transform_s2t (binding,
|
||||
&source_value,
|
||||
&target_value,
|
||||
&from_value,
|
||||
&to_value,
|
||||
binding->transform_data);
|
||||
if (res)
|
||||
{
|
||||
binding->is_frozen = TRUE;
|
||||
|
||||
g_param_value_validate (binding->target_pspec, &target_value);
|
||||
g_object_set_property (binding->target, binding->target_pspec->name, &target_value);
|
||||
g_param_value_validate (binding->target_pspec, &to_value);
|
||||
g_object_set_property (binding->target, binding->target_pspec->name, &to_value);
|
||||
|
||||
binding->is_frozen = FALSE;
|
||||
}
|
||||
|
||||
g_value_unset (&source_value);
|
||||
g_value_unset (&target_value);
|
||||
g_value_unset (&from_value);
|
||||
g_value_unset (&to_value);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -401,8 +401,8 @@ on_target_notify (GObject *gobject,
|
||||
GBinding *binding)
|
||||
{
|
||||
const gchar *p_name;
|
||||
GValue source_value = G_VALUE_INIT;
|
||||
GValue target_value = G_VALUE_INIT;
|
||||
GValue from_value = G_VALUE_INIT;
|
||||
GValue to_value = G_VALUE_INIT;
|
||||
gboolean res;
|
||||
|
||||
if (binding->is_frozen)
|
||||
@@ -413,27 +413,27 @@ on_target_notify (GObject *gobject,
|
||||
if (p_name != binding->target_property)
|
||||
return;
|
||||
|
||||
g_value_init (&source_value, G_PARAM_SPEC_VALUE_TYPE (binding->target_pspec));
|
||||
g_value_init (&target_value, G_PARAM_SPEC_VALUE_TYPE (binding->source_pspec));
|
||||
g_value_init (&from_value, G_PARAM_SPEC_VALUE_TYPE (binding->target_pspec));
|
||||
g_value_init (&to_value, G_PARAM_SPEC_VALUE_TYPE (binding->source_pspec));
|
||||
|
||||
g_object_get_property (binding->target, binding->target_pspec->name, &source_value);
|
||||
g_object_get_property (binding->target, binding->target_pspec->name, &from_value);
|
||||
|
||||
res = binding->transform_t2s (binding,
|
||||
&source_value,
|
||||
&target_value,
|
||||
&from_value,
|
||||
&to_value,
|
||||
binding->transform_data);
|
||||
if (res)
|
||||
{
|
||||
binding->is_frozen = TRUE;
|
||||
|
||||
g_param_value_validate (binding->source_pspec, &target_value);
|
||||
g_object_set_property (binding->source, binding->source_pspec->name, &target_value);
|
||||
g_param_value_validate (binding->source_pspec, &to_value);
|
||||
g_object_set_property (binding->source, binding->source_pspec->name, &to_value);
|
||||
|
||||
binding->is_frozen = FALSE;
|
||||
}
|
||||
|
||||
g_value_unset (&source_value);
|
||||
g_value_unset (&target_value);
|
||||
g_value_unset (&from_value);
|
||||
g_value_unset (&to_value);
|
||||
}
|
||||
|
||||
static inline void
|
||||
|
Reference in New Issue
Block a user