[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
This commit is contained in:
Emmanuele Bassi 2009-02-02 23:55:30 +00:00
parent e349642937
commit 9cf02bfdb9
5 changed files with 32 additions and 26 deletions

View File

@ -169,7 +169,7 @@ enum
PROP_COLOR, PROP_COLOR,
PROP_USE_MARKUP, PROP_USE_MARKUP,
PROP_ATTRIBUTES, PROP_ATTRIBUTES,
PROP_ALIGNMENT, PROP_LINE_ALIGNMENT,
PROP_LINE_WRAP, PROP_LINE_WRAP,
PROP_LINE_WRAP_MODE, PROP_LINE_WRAP_MODE,
PROP_JUSTIFY, PROP_JUSTIFY,
@ -568,8 +568,8 @@ clutter_text_set_property (GObject *gobject,
clutter_text_set_attributes (self, g_value_get_boxed (value)); clutter_text_set_attributes (self, g_value_get_boxed (value));
break; break;
case PROP_ALIGNMENT: case PROP_LINE_ALIGNMENT:
clutter_text_set_alignment (self, g_value_get_enum (value)); clutter_text_set_line_alignment (self, g_value_get_enum (value));
break; break;
case PROP_LINE_WRAP: case PROP_LINE_WRAP:
@ -719,7 +719,7 @@ clutter_text_get_property (GObject *gobject,
g_value_set_enum (value, priv->wrap_mode); g_value_set_enum (value, priv->wrap_mode);
break; break;
case PROP_ALIGNMENT: case PROP_LINE_ALIGNMENT:
g_value_set_enum (value, priv->alignment); g_value_set_enum (value, priv->alignment);
break; break;
@ -1841,21 +1841,21 @@ clutter_text_class_init (ClutterTextClass *klass)
g_object_class_install_property (gobject_class, PROP_ELLIPSIZE, pspec); 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 preferred alignment for the text. This property controls
* the alignment of multi-line paragraphs. * the alignment of multi-line paragraphs.
* *
* Since: 1.0 * Since: 1.0
*/ */
pspec = g_param_spec_enum ("alignment", pspec = g_param_spec_enum ("line-alignment",
"Alignment", "Line Alignment",
"The preferred alignment for the string, " "The preferred alignment for the string, "
"for multi-line text", "for multi-line text",
PANGO_TYPE_ALIGNMENT, PANGO_TYPE_ALIGNMENT,
PANGO_ALIGN_LEFT, PANGO_ALIGN_LEFT,
CLUTTER_PARAM_READWRITE); 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: * ClutterText:justify:
@ -3251,20 +3251,21 @@ clutter_text_get_attributes (ClutterText *self)
} }
/** /**
* clutter_text_set_alignment: * clutter_text_set_line_alignment:
* @self: a #ClutterText * @self: a #ClutterText
* @alignment: A #PangoAlignment * @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 * To align a #ClutterText actor you should add it to a container
* #ClutterText actor are enough to wrap, and the #ClutterText:line-wrap * that supports alignment, or use the anchor point.
* property is set to %TRUE.
* *
* Since: 1.0 * Since: 1.0
*/ */
void void
clutter_text_set_alignment (ClutterText *self, clutter_text_set_line_alignment (ClutterText *self,
PangoAlignment alignment) PangoAlignment alignment)
{ {
ClutterTextPrivate *priv; ClutterTextPrivate *priv;
@ -3281,22 +3282,23 @@ clutter_text_set_alignment (ClutterText *self,
clutter_actor_queue_relayout (CLUTTER_ACTOR (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 * @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 * Return value: a #PangoAlignment
* *
* Since 1.0 * Since 1.0
*/ */
PangoAlignment 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); g_return_val_if_fail (CLUTTER_IS_TEXT (self), PANGO_ALIGN_LEFT);

View File

@ -133,9 +133,9 @@ PangoAttrList * clutter_text_get_attributes (ClutterText *sel
void clutter_text_set_use_markup (ClutterText *self, void clutter_text_set_use_markup (ClutterText *self,
gboolean setting); gboolean setting);
gboolean clutter_text_get_use_markup (ClutterText *self); 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 alignment);
PangoAlignment clutter_text_get_alignment (ClutterText *self); PangoAlignment clutter_text_get_line_alignment (ClutterText *self);
void clutter_text_set_justify (ClutterText *self, void clutter_text_set_justify (ClutterText *self,
gboolean justify); gboolean justify);
gboolean clutter_text_get_justify (ClutterText *self); gboolean clutter_text_get_justify (ClutterText *self);

View File

@ -1601,8 +1601,6 @@ clutter_text_set_markup
clutter_text_get_text clutter_text_get_text
clutter_text_set_activatable clutter_text_set_activatable
clutter_text_get_activatable clutter_text_get_activatable
clutter_text_set_alignment
clutter_text_get_alignment
clutter_text_set_attributes clutter_text_set_attributes
clutter_text_get_attributes clutter_text_get_attributes
clutter_text_set_color clutter_text_set_color
@ -1616,6 +1614,8 @@ clutter_text_get_password_char
clutter_text_set_justify clutter_text_set_justify
clutter_text_get_justify clutter_text_get_justify
clutter_text_get_layout clutter_text_get_layout
clutter_text_set_line_alignment
clutter_text_get_line_alignment
clutter_text_set_line_wrap clutter_text_set_line_wrap
clutter_text_get_line_wrap clutter_text_get_line_wrap
clutter_text_set_line_wrap_mode clutter_text_set_line_wrap_mode

View File

@ -218,7 +218,8 @@ do_tests (CallbackData *data)
g_assert (check_result (data, "Enable justify", TRUE) == FALSE); g_assert (check_result (data, "Enable justify", TRUE) == FALSE);
/* TEST 13: change alignment */ /* 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); pango_layout_set_alignment (data->test_layout, PANGO_ALIGN_RIGHT);
g_assert (check_result (data, "Change alignment", TRUE) == FALSE); g_assert (check_result (data, "Change alignment", TRUE) == FALSE);

View File

@ -33,8 +33,11 @@ test_rotate_main (int argc, char *argv[])
clutter_actor_show (hand); clutter_actor_show (hand);
clutter_container_add_actor (CLUTTER_CONTAINER (stage), hand); clutter_container_add_actor (CLUTTER_CONTAINER (stage), hand);
label = clutter_text_new_with_text ("Mono 16", "The Wonder of the Spinning Hand"); label = clutter_text_new_with_text ("Mono 16",
clutter_text_set_alignment (CLUTTER_TEXT (label), PANGO_ALIGN_CENTER); "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_position (label, 150, 150);
clutter_actor_set_size (label, 500, 100); clutter_actor_set_size (label, 500, 100);
clutter_actor_show (label); clutter_actor_show (label);