mirror of
https://github.com/brl/mutter.git
synced 2025-03-28 22:23:47 +00:00
animation: Check for value transformability
We should not just check for compatibility, but also for the ability to transform a GValue of type A into another of type A'. Usually compatibility is enough, especially if types can be introspected beforehand; some times, though, we also need to check for transformability as a type can provide the transformation functions necessary for the operation.
This commit is contained in:
parent
4695383281
commit
94249efff7
@ -629,6 +629,7 @@ clutter_animation_validate_bind (ClutterAnimation *animation,
|
|||||||
ClutterAnimationPrivate *priv;
|
ClutterAnimationPrivate *priv;
|
||||||
GObjectClass *klass;
|
GObjectClass *klass;
|
||||||
GParamSpec *pspec;
|
GParamSpec *pspec;
|
||||||
|
GType pspec_type;
|
||||||
|
|
||||||
priv = animation->priv;
|
priv = animation->priv;
|
||||||
|
|
||||||
@ -667,14 +668,17 @@ clutter_animation_validate_bind (ClutterAnimation *animation,
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!g_value_type_compatible (G_PARAM_SPEC_VALUE_TYPE (pspec), argtype))
|
pspec_type = G_PARAM_SPEC_VALUE_TYPE (pspec);
|
||||||
|
|
||||||
|
if (!g_value_type_compatible (argtype, pspec_type) ||
|
||||||
|
!g_value_type_transformable (argtype, pspec_type))
|
||||||
{
|
{
|
||||||
g_warning ("Cannot bind property '%s': the interval value of "
|
g_warning ("Cannot bind property '%s': the interval value of "
|
||||||
"type '%s' is not compatible with the property value "
|
"type '%s' is not compatible with the property value "
|
||||||
"of type '%s'",
|
"of type '%s'",
|
||||||
property_name,
|
property_name,
|
||||||
g_type_name (argtype),
|
g_type_name (argtype),
|
||||||
g_type_name (G_PARAM_SPEC_VALUE_TYPE (pspec)));
|
g_type_name (pspec_type));
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -846,6 +850,7 @@ clutter_animation_update_interval (ClutterAnimation *animation,
|
|||||||
ClutterAnimationPrivate *priv;
|
ClutterAnimationPrivate *priv;
|
||||||
GObjectClass *klass;
|
GObjectClass *klass;
|
||||||
GParamSpec *pspec;
|
GParamSpec *pspec;
|
||||||
|
GType pspec_type, int_type;
|
||||||
|
|
||||||
g_return_if_fail (CLUTTER_IS_ANIMATION (animation));
|
g_return_if_fail (CLUTTER_IS_ANIMATION (animation));
|
||||||
g_return_if_fail (property_name != NULL);
|
g_return_if_fail (property_name != NULL);
|
||||||
@ -872,15 +877,18 @@ clutter_animation_update_interval (ClutterAnimation *animation,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!g_value_type_compatible (G_PARAM_SPEC_VALUE_TYPE (pspec),
|
pspec_type = G_PARAM_SPEC_VALUE_TYPE (pspec);
|
||||||
clutter_interval_get_value_type (interval)))
|
int_type = clutter_interval_get_value_type (interval);
|
||||||
|
|
||||||
|
if (!g_value_type_compatible (int_type, pspec_type) ||
|
||||||
|
!g_value_type_transformable (int_type, pspec_type))
|
||||||
{
|
{
|
||||||
g_warning ("Cannot update property '%s': the interval value of "
|
g_warning ("Cannot update property '%s': the interval value of "
|
||||||
"type '%s' is not compatible with the property value "
|
"type '%s' is not compatible with the property value "
|
||||||
"of type '%s'",
|
"of type '%s'",
|
||||||
property_name,
|
property_name,
|
||||||
g_type_name (clutter_interval_get_value_type (interval)),
|
g_type_name (int_type),
|
||||||
g_type_name (G_PARAM_SPEC_VALUE_TYPE (pspec)));
|
g_type_name (pspec_type));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -906,6 +914,7 @@ clutter_animation_update (ClutterAnimation *animation,
|
|||||||
{
|
{
|
||||||
ClutterAnimationPrivate *priv;
|
ClutterAnimationPrivate *priv;
|
||||||
ClutterInterval *interval;
|
ClutterInterval *interval;
|
||||||
|
GType int_type;
|
||||||
|
|
||||||
g_return_val_if_fail (CLUTTER_IS_ANIMATION (animation), NULL);
|
g_return_val_if_fail (CLUTTER_IS_ANIMATION (animation), NULL);
|
||||||
g_return_val_if_fail (property_name != NULL, NULL);
|
g_return_val_if_fail (property_name != NULL, NULL);
|
||||||
@ -923,14 +932,16 @@ clutter_animation_update (ClutterAnimation *animation,
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!g_value_type_compatible (G_VALUE_TYPE (final),
|
int_type = clutter_interval_get_value_type (interval);
|
||||||
clutter_interval_get_value_type (interval)))
|
|
||||||
|
if (!g_value_type_compatible (G_VALUE_TYPE (final), int_type) ||
|
||||||
|
!g_value_type_transformable (G_VALUE_TYPE (final), int_type))
|
||||||
{
|
{
|
||||||
g_warning ("Cannot update property '%s': the interval value of "
|
g_warning ("Cannot update property '%s': the interval value of "
|
||||||
"type '%s' is not compatible with the property value "
|
"type '%s' is not compatible with the property value "
|
||||||
"of type '%s'",
|
"of type '%s'",
|
||||||
property_name,
|
property_name,
|
||||||
g_type_name (clutter_interval_get_value_type (interval)),
|
g_type_name (int_type),
|
||||||
g_type_name (G_VALUE_TYPE (final)));
|
g_type_name (G_VALUE_TYPE (final)));
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user