From 9cf02bfdb9a65500688fde1c4485f6cc968c385f Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Mon, 2 Feb 2009 23:55:30 +0000 Subject: [PATCH] [text] Rename :alignment to :line-alignment The :alignment property is prone to generate confusion: developers will set it thinking that the contents of a ClutterText will automagically align themselves. Instead of using the generic term :alignment, and following the GTK+ convention, we should use a more specific term, conveying the actual effect of the property: alignment of the lines with respect to each other, and not to the overall allocated area. See bug 1428: http://bugzilla.openedhand.com/show_bug.cgi?id=1428 --- clutter/clutter-text.c | 40 ++++++++++++++++-------------- clutter/clutter-text.h | 4 +-- doc/reference/clutter/clutter-sections.txt | 4 +-- tests/conform/test-text-cache.c | 3 ++- tests/interactive/test-rotate.c | 7 ++++-- 5 files changed, 32 insertions(+), 26 deletions(-) diff --git a/clutter/clutter-text.c b/clutter/clutter-text.c index 37784ed..e35151e 100644 --- a/clutter/clutter-text.c +++ b/clutter/clutter-text.c @@ -169,7 +169,7 @@ enum PROP_COLOR, PROP_USE_MARKUP, PROP_ATTRIBUTES, - PROP_ALIGNMENT, + PROP_LINE_ALIGNMENT, PROP_LINE_WRAP, PROP_LINE_WRAP_MODE, PROP_JUSTIFY, @@ -568,8 +568,8 @@ clutter_text_set_property (GObject *gobject, clutter_text_set_attributes (self, g_value_get_boxed (value)); break; - case PROP_ALIGNMENT: - clutter_text_set_alignment (self, g_value_get_enum (value)); + case PROP_LINE_ALIGNMENT: + clutter_text_set_line_alignment (self, g_value_get_enum (value)); break; case PROP_LINE_WRAP: @@ -719,7 +719,7 @@ clutter_text_get_property (GObject *gobject, g_value_set_enum (value, priv->wrap_mode); break; - case PROP_ALIGNMENT: + case PROP_LINE_ALIGNMENT: g_value_set_enum (value, priv->alignment); break; @@ -1841,21 +1841,21 @@ clutter_text_class_init (ClutterTextClass *klass) g_object_class_install_property (gobject_class, PROP_ELLIPSIZE, pspec); /** - * ClutterText:alignment: + * ClutterText:line-alignment: * * The preferred alignment for the text. This property controls * the alignment of multi-line paragraphs. * * Since: 1.0 */ - pspec = g_param_spec_enum ("alignment", - "Alignment", + pspec = g_param_spec_enum ("line-alignment", + "Line Alignment", "The preferred alignment for the string, " "for multi-line text", PANGO_TYPE_ALIGNMENT, PANGO_ALIGN_LEFT, CLUTTER_PARAM_READWRITE); - g_object_class_install_property (gobject_class, PROP_ALIGNMENT, pspec); + g_object_class_install_property (gobject_class, PROP_LINE_ALIGNMENT, pspec); /** * ClutterText:justify: @@ -3251,21 +3251,22 @@ clutter_text_get_attributes (ClutterText *self) } /** - * clutter_text_set_alignment: + * clutter_text_set_line_alignment: * @self: a #ClutterText * @alignment: A #PangoAlignment * - * Sets text alignment of the #ClutterText actor. + * Sets the way that the lines of a wrapped label are aligned with + * respect to each other. This does not affect the overall alignment + * of the label within its allocated or specified width. * - * The alignment will only be used when the contents of the - * #ClutterText actor are enough to wrap, and the #ClutterText:line-wrap - * property is set to %TRUE. + * To align a #ClutterText actor you should add it to a container + * that supports alignment, or use the anchor point. * * Since: 1.0 */ void -clutter_text_set_alignment (ClutterText *self, - PangoAlignment alignment) +clutter_text_set_line_alignment (ClutterText *self, + PangoAlignment alignment) { ClutterTextPrivate *priv; @@ -3281,22 +3282,23 @@ clutter_text_set_alignment (ClutterText *self, clutter_actor_queue_relayout (CLUTTER_ACTOR (self)); - g_object_notify (G_OBJECT (self), "alignment"); + g_object_notify (G_OBJECT (self), "line-alignment"); } } /** - * clutter_text_get_alignment: + * clutter_text_get_line_alignment: * @self: a #ClutterText * - * Retrieves the alignment of @self. + * Retrieves the alignment of a #ClutterText, as set by + * clutter_text_set_line_alignment(). * * Return value: a #PangoAlignment * * Since 1.0 */ PangoAlignment -clutter_text_get_alignment (ClutterText *self) +clutter_text_get_line_alignment (ClutterText *self) { g_return_val_if_fail (CLUTTER_IS_TEXT (self), PANGO_ALIGN_LEFT); diff --git a/clutter/clutter-text.h b/clutter/clutter-text.h index 63b1830..50c9ca6 100644 --- a/clutter/clutter-text.h +++ b/clutter/clutter-text.h @@ -133,9 +133,9 @@ PangoAttrList * clutter_text_get_attributes (ClutterText *sel void clutter_text_set_use_markup (ClutterText *self, gboolean setting); gboolean clutter_text_get_use_markup (ClutterText *self); -void clutter_text_set_alignment (ClutterText *self, +void clutter_text_set_line_alignment (ClutterText *self, PangoAlignment alignment); -PangoAlignment clutter_text_get_alignment (ClutterText *self); +PangoAlignment clutter_text_get_line_alignment (ClutterText *self); void clutter_text_set_justify (ClutterText *self, gboolean justify); gboolean clutter_text_get_justify (ClutterText *self); diff --git a/doc/reference/clutter/clutter-sections.txt b/doc/reference/clutter/clutter-sections.txt index b851efb..28d115f 100644 --- a/doc/reference/clutter/clutter-sections.txt +++ b/doc/reference/clutter/clutter-sections.txt @@ -1601,8 +1601,6 @@ clutter_text_set_markup clutter_text_get_text clutter_text_set_activatable clutter_text_get_activatable -clutter_text_set_alignment -clutter_text_get_alignment clutter_text_set_attributes clutter_text_get_attributes clutter_text_set_color @@ -1616,6 +1614,8 @@ clutter_text_get_password_char clutter_text_set_justify clutter_text_get_justify clutter_text_get_layout +clutter_text_set_line_alignment +clutter_text_get_line_alignment clutter_text_set_line_wrap clutter_text_get_line_wrap clutter_text_set_line_wrap_mode diff --git a/tests/conform/test-text-cache.c b/tests/conform/test-text-cache.c index d3a2cf5..bf503ef 100644 --- a/tests/conform/test-text-cache.c +++ b/tests/conform/test-text-cache.c @@ -218,7 +218,8 @@ do_tests (CallbackData *data) g_assert (check_result (data, "Enable justify", TRUE) == FALSE); /* TEST 13: change alignment */ - clutter_text_set_alignment (CLUTTER_TEXT (data->label), PANGO_ALIGN_RIGHT); + clutter_text_set_line_alignment (CLUTTER_TEXT (data->label), + PANGO_ALIGN_RIGHT); pango_layout_set_alignment (data->test_layout, PANGO_ALIGN_RIGHT); g_assert (check_result (data, "Change alignment", TRUE) == FALSE); diff --git a/tests/interactive/test-rotate.c b/tests/interactive/test-rotate.c index 8b37b76..0c23471 100644 --- a/tests/interactive/test-rotate.c +++ b/tests/interactive/test-rotate.c @@ -33,8 +33,11 @@ test_rotate_main (int argc, char *argv[]) clutter_actor_show (hand); clutter_container_add_actor (CLUTTER_CONTAINER (stage), hand); - label = clutter_text_new_with_text ("Mono 16", "The Wonder of the Spinning Hand"); - clutter_text_set_alignment (CLUTTER_TEXT (label), PANGO_ALIGN_CENTER); + label = clutter_text_new_with_text ("Mono 16", + "The Wonder\n" + "of the\n" + "Spinning Hand"); + clutter_text_set_line_alignment (CLUTTER_TEXT (label), PANGO_ALIGN_CENTER); clutter_actor_set_position (label, 150, 150); clutter_actor_set_size (label, 500, 100); clutter_actor_show (label); -- 2.7.4