diff --git a/ChangeLog b/ChangeLog index 9872f01f6..d165360b5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,20 @@ +2008-04-17 Emmanuele Bassi + + * clutter/clutter-fixed.c: + (clutter_value_transform_fixed_int), + (clutter_value_transform_fixed_double), + (clutter_value_transform_fixed_float), + (clutter_fixed_get_type): Add GValue transformation functions + for ClutterFixed; copying a CLUTTER_TYPE_FIXED GValue into + a G_TYPE_FLOAT/G_TYPE_DOUBLE one will automatically transform + the fixed point representation into a floating point one. Also + add the G_TYPE_INT transformation function to do a plain + fixed->int copy. + + * clutter/clutter-units.c: + (clutter_value_transform_unit_int), + (clutter_unit_get_type): Add a unit->int transformation function. + 2008-04-17 Emmanuele Bassi * clutter/clutter-fixed.c (clutter_value_get_fixed): Fix typo diff --git a/clutter/clutter-fixed.c b/clutter/clutter-fixed.c index 9a35b5f5d..f89176eb7 100644 --- a/clutter/clutter-fixed.c +++ b/clutter/clutter-fixed.c @@ -1031,6 +1031,27 @@ clutter_value_lcopy_fixed (const GValue *value, return NULL; } +static void +clutter_value_transform_fixed_int (const GValue *src, + GValue *dest) +{ + dest->data[0].v_int = src->data[0].v_int; +} + +static void +clutter_value_transform_fixed_double (const GValue *src, + GValue *dest) +{ + dest->data[0].v_double = CLUTTER_FIXED_TO_DOUBLE (src->data[0].v_int); +} + +static void +clutter_value_transform_fixed_float (const GValue *src, + GValue *dest) +{ + dest->data[0].v_float = CLUTTER_FIXED_TO_FLOAT (src->data[0].v_int); +} + static const GTypeValueTable _clutter_fixed_value_table = { clutter_value_init_fixed, NULL, @@ -1054,6 +1075,13 @@ clutter_fixed_get_type (void) g_type_register_fundamental (g_type_fundamental_next (), I_("ClutterFixed"), &_info, &_finfo, 0); + + g_value_register_transform_func (_clutter_fixed_type, G_TYPE_INT, + clutter_value_transform_fixed_int); + g_value_register_transform_func (_clutter_fixed_type, G_TYPE_FLOAT, + clutter_value_transform_fixed_float); + g_value_register_transform_func (_clutter_fixed_type, G_TYPE_DOUBLE, + clutter_value_transform_fixed_double); } return _clutter_fixed_type; diff --git a/clutter/clutter-units.c b/clutter/clutter-units.c index b060376e0..9dbd4129a 100644 --- a/clutter/clutter-units.c +++ b/clutter/clutter-units.c @@ -110,6 +110,13 @@ clutter_value_lcopy_unit (const GValue *value, return NULL; } +static void +clutter_value_transform_unit_int (const GValue *src, + GValue *dest) +{ + dest->data[0].v_int = src->data[0].v_int; +} + static const GTypeValueTable _clutter_unit_value_table = { clutter_value_init_unit, NULL, @@ -133,6 +140,9 @@ clutter_unit_get_type (void) g_type_register_fundamental (g_type_fundamental_next (), I_("ClutterUnit"), &_info, &_finfo, 0); + + g_value_register_transform_func (_clutter_unit_type, G_TYPE_INT, + clutter_value_transform_unit_int); } return _clutter_unit_type;