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)
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
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)
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
/**
* GBindingTransformFunc:
* @binding: a #GBinding
- * @source_value: the value of the source property
- * @target_value: the value of the target property
+ * @from_value: the #GValue containing the value to transform
+ * @to_value: the #GValue in which to store the transformed value
* @user_data: data passed to the transform function
*
- * A function to be called to transform the source property of @source
- * from @source_value into the target property of @target
- * using @target_value.
+ * A function to be called to transform @from_value to @to_value. If
+ * this is the @transform_to function of a binding, then @from_value
+ * is the @source_property on the @source object, and @to_value is the
+ * @target_property on the @target object. If this is the
+ * @transform_from function of a %G_BINDING_BIDIRECTIONAL binding,
+ * then those roles are reversed.
*
* Return value: %TRUE if the transformation was successful, and %FALSE
* otherwise
* Since: 2.26
*/
typedef gboolean (* GBindingTransformFunc) (GBinding *binding,
- const GValue *source_value,
- GValue *target_value,
+ const GValue *from_value,
+ GValue *to_value,
gpointer user_data);
/**
static gboolean
celsius_to_fahrenheit (GBinding *binding,
- const GValue *source_value,
- GValue *target_value,
+ const GValue *from_value,
+ GValue *to_value,
gpointer user_data G_GNUC_UNUSED)
{
gdouble celsius, fahrenheit;
- g_assert (G_VALUE_HOLDS (source_value, G_TYPE_DOUBLE));
- g_assert (G_VALUE_HOLDS (target_value, G_TYPE_DOUBLE));
+ g_assert (G_VALUE_HOLDS (from_value, G_TYPE_DOUBLE));
+ g_assert (G_VALUE_HOLDS (to_value, G_TYPE_DOUBLE));
- celsius = g_value_get_double (source_value);
+ celsius = g_value_get_double (from_value);
fahrenheit = (9 * celsius / 5) + 32.0;
if (g_test_verbose ())
g_print ("Converting %.2fC to %.2fF\n", celsius, fahrenheit);
- g_value_set_double (target_value, fahrenheit);
+ g_value_set_double (to_value, fahrenheit);
return TRUE;
}
static gboolean
fahrenheit_to_celsius (GBinding *binding,
- const GValue *source_value,
- GValue *target_value,
+ const GValue *from_value,
+ GValue *to_value,
gpointer user_data G_GNUC_UNUSED)
{
gdouble celsius, fahrenheit;
- g_assert (G_VALUE_HOLDS (source_value, G_TYPE_DOUBLE));
- g_assert (G_VALUE_HOLDS (target_value, G_TYPE_DOUBLE));
+ g_assert (G_VALUE_HOLDS (from_value, G_TYPE_DOUBLE));
+ g_assert (G_VALUE_HOLDS (to_value, G_TYPE_DOUBLE));
- fahrenheit = g_value_get_double (source_value);
+ fahrenheit = g_value_get_double (from_value);
celsius = 5 * (fahrenheit - 32.0) / 9;
if (g_test_verbose ())
g_print ("Converting %.2fF to %.2fC\n", fahrenheit, celsius);
- g_value_set_double (target_value, celsius);
+ g_value_set_double (to_value, celsius);
return TRUE;
}