diff options
-rw-r--r-- | clutter/clutter-units.c | 36 | ||||
-rw-r--r-- | clutter/clutter-units.h | 55 | ||||
-rw-r--r-- | doc/reference/clutter/clutter-sections.txt | 15 | ||||
-rw-r--r-- | tests/conform/test-clutter-units.c | 8 |
4 files changed, 63 insertions, 51 deletions
diff --git a/clutter/clutter-units.c b/clutter/clutter-units.c index 4c8ecdca4..75802b89d 100644 --- a/clutter/clutter-units.c +++ b/clutter/clutter-units.c @@ -132,7 +132,7 @@ units_em_to_pixels (const gchar *font_name, } /** - * clutter_units_mm: + * clutter_units_from_mm: * @units: a #ClutterUnits * @mm: millimeters * @@ -141,8 +141,8 @@ units_em_to_pixels (const gchar *font_name, * Since: 1.0 */ void -clutter_units_mm (ClutterUnits *units, - gfloat mm) +clutter_units_from_mm (ClutterUnits *units, + gfloat mm) { g_return_if_fail (units != NULL); @@ -153,7 +153,7 @@ clutter_units_mm (ClutterUnits *units, } /** - * clutter_units_pt: + * clutter_units_from_pt: * @units: a #ClutterUnits * @pt: typographic points * @@ -162,8 +162,8 @@ clutter_units_mm (ClutterUnits *units, * Since: 1.0 */ void -clutter_units_pt (ClutterUnits *units, - gfloat pt) +clutter_units_from_pt (ClutterUnits *units, + gfloat pt) { g_return_if_fail (units != NULL); @@ -174,7 +174,7 @@ clutter_units_pt (ClutterUnits *units, } /** - * clutter_units_em: + * clutter_units_from_em: * @units: a #ClutterUnits * @em: em * @@ -184,8 +184,8 @@ clutter_units_pt (ClutterUnits *units, * Since: 1.0 */ void -clutter_units_em (ClutterUnits *units, - gfloat em) +clutter_units_from_em (ClutterUnits *units, + gfloat em) { g_return_if_fail (units != NULL); @@ -196,7 +196,7 @@ clutter_units_em (ClutterUnits *units, } /** - * clutter_units_em_for_font: + * clutter_units_from_em_for_font: * @units: a #ClutterUnits * @font_name: the font name and size * @em: em @@ -206,9 +206,9 @@ clutter_units_em (ClutterUnits *units, * Since: 1.0 */ void -clutter_units_em_for_font (ClutterUnits *units, - const gchar *font_name, - gfloat em) +clutter_units_from_em_for_font (ClutterUnits *units, + const gchar *font_name, + gfloat em) { g_return_if_fail (units != NULL); @@ -219,7 +219,7 @@ clutter_units_em_for_font (ClutterUnits *units, } /** - * clutter_units_pixels: + * clutter_units_from_pixels: * @units: a #ClutterUnits * @px: pixels * @@ -228,8 +228,8 @@ clutter_units_em_for_font (ClutterUnits *units, * Since: 1.0 */ void -clutter_units_pixels (ClutterUnits *units, - gint px) +clutter_units_from_pixels (ClutterUnits *units, + gint px) { g_return_if_fail (units != NULL); @@ -550,7 +550,7 @@ static void clutter_value_transform_int_units (const GValue *src, GValue *dest) { - clutter_units_pixels (dest->data[0].v_pointer, src->data[0].v_int); + clutter_units_from_pixels (dest->data[0].v_pointer, src->data[0].v_int); } /* units to float */ @@ -566,7 +566,7 @@ static void clutter_value_transform_float_units (const GValue *src, GValue *dest) { - clutter_units_pixels (dest->data[0].v_pointer, src->data[0].v_float); + clutter_units_from_pixels (dest->data[0].v_pointer, src->data[0].v_float); } /* units to string */ diff --git a/clutter/clutter-units.h b/clutter/clutter-units.h index 81070b0a9..4a407787f 100644 --- a/clutter/clutter-units.h +++ b/clutter/clutter-units.h @@ -83,30 +83,37 @@ struct _ClutterUnits gint64 __padding_2; }; -GType clutter_units_get_type (void) G_GNUC_CONST; -ClutterUnitType clutter_units_get_unit_type (const ClutterUnits *units); -gfloat clutter_units_get_unit_value (const ClutterUnits *units); - -ClutterUnits * clutter_units_copy (const ClutterUnits *units); -void clutter_units_free (ClutterUnits *units); - -void clutter_units_pixels (ClutterUnits *units, - gint px); -void clutter_units_em (ClutterUnits *units, - gfloat em); -void clutter_units_em_for_font (ClutterUnits *units, - const gchar *font_name, - gfloat em); -void clutter_units_mm (ClutterUnits *units, - gfloat mm); -void clutter_units_pt (ClutterUnits *units, - gfloat pt); - -gfloat clutter_units_to_pixels (ClutterUnits *units); - -gchar * clutter_units_to_string (const ClutterUnits *units); -gboolean clutter_units_from_string (ClutterUnits *units, - const gchar *str); +GType clutter_units_get_type (void) G_GNUC_CONST; +ClutterUnitType clutter_units_get_unit_type (const ClutterUnits *units); +gfloat clutter_units_get_unit_value (const ClutterUnits *units); + +ClutterUnits * clutter_units_copy (const ClutterUnits *units); +void clutter_units_free (ClutterUnits *units); + +void clutter_units_from_pixels (ClutterUnits *units, + gint px); +void clutter_units_from_em (ClutterUnits *units, + gfloat em); +void clutter_units_from_em_for_font (ClutterUnits *units, + const gchar *font_name, + gfloat em); +void clutter_units_from_mm (ClutterUnits *units, + gfloat mm); +void clutter_units_from_pt (ClutterUnits *units, + gfloat pt); + +gfloat clutter_units_to_pixels (ClutterUnits *units); + +gboolean clutter_units_from_string (ClutterUnits *units, + const gchar *str); +gchar * clutter_units_to_string (const ClutterUnits *units); + +/* shorthands for the constructors */ +#define clutter_units_pixels clutter_units_from_pixels +#define clutter_units_em clutter_units_from_em +#define clutter_units_em_for_font clutter_units_from_em_for_font +#define clutter_units_mm clutter_units_from_mm +#define clutter_units_pt clutter_units_from_pt #define CLUTTER_TYPE_UNITS (clutter_units_get_type ()) #define CLUTTER_TYPE_PARAM_UNITS (clutter_param_units_get_type ()) diff --git a/doc/reference/clutter/clutter-sections.txt b/doc/reference/clutter/clutter-sections.txt index 7f2649e4c..a40eca6de 100644 --- a/doc/reference/clutter/clutter-sections.txt +++ b/doc/reference/clutter/clutter-sections.txt @@ -29,11 +29,11 @@ clutter_media_get_type <TITLE>Unit conversion</TITLE> ClutterUnitType ClutterUnits -clutter_units_mm -clutter_units_pt -clutter_units_em -clutter_units_em_for_font -clutter_units_pixels +clutter_units_from_mm +clutter_units_from_pt +clutter_units_from_em +clutter_units_from_em_for_font +clutter_units_from_pixels clutter_units_to_pixels clutter_units_copy clutter_units_free @@ -56,6 +56,11 @@ CLUTTER_PARAM_SPEC_UNITS CLUTTER_IS_PARAM_SPEC_UNITS clutter_units_get_type clutter_param_units_get_type +clutter_units_em +clutter_units_em_for_font +clutter_units_mm +clutter_units_pixels +clutter_units_pt </SECTION> <SECTION> diff --git a/tests/conform/test-clutter-units.c b/tests/conform/test-clutter-units.c index 2a590c68f..b809e88d9 100644 --- a/tests/conform/test-clutter-units.c +++ b/tests/conform/test-clutter-units.c @@ -9,12 +9,12 @@ test_units_constructors (TestConformSimpleFixture *fixture, { ClutterUnits units; - clutter_units_pixels (&units, 100); + clutter_units_from_pixels (&units, 100); g_assert (clutter_units_get_unit_type (&units) == CLUTTER_UNIT_PIXEL); g_assert_cmpfloat (clutter_units_get_unit_value (&units), ==, 100.0); g_assert_cmpfloat (clutter_units_to_pixels (&units), ==, 100.0); - clutter_units_em (&units, 5.0); + clutter_units_from_em (&units, 5.0); g_assert (clutter_units_get_unit_type (&units) == CLUTTER_UNIT_EM); g_assert_cmpfloat (clutter_units_get_unit_value (&units), ==, 5.0); g_assert_cmpfloat (clutter_units_to_pixels (&units), !=, 5.0); @@ -37,12 +37,12 @@ test_units_string (TestConformSimpleFixture *fixture, g_assert (clutter_units_from_string (&units, "1 pony") == FALSE); - clutter_units_pt (&units, 24.0); + clutter_units_from_pt (&units, 24.0); string = clutter_units_to_string (&units); g_assert_cmpstr (string, ==, "24.0 pt"); g_free (string); - clutter_units_em (&units, 3.0); + clutter_units_from_em (&units, 3.0); string = clutter_units_to_string (&units); g_assert_cmpstr (string, ==, "3.00 em"); |