From 9fdc9ca583e1b3e0dd81d7322732156d3eb121b7 Mon Sep 17 00:00:00 2001 From: Neil Roberts Date: Tue, 21 Apr 2009 14:15:19 +0100 Subject: [PATCH] [ClutterText] Fix actors with a width but no wrapping and the wrap modes Setting the wrap mode on the PangoLayout seems to have disappeared during the text-actor-layout-height branch merge so this brings it back. The test for this in test-text-cache no longer needs to be disabled. We also shouldn't set the width on the layout if there is no wrapping or ellipsizing because otherwise it implicitly enables wrapping. This only matters if the actor gets allocated smaller than its natural size. --- clutter/clutter-text.c | 10 +++++++--- tests/conform/test-text-cache.c | 2 -- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/clutter/clutter-text.c b/clutter/clutter-text.c index 9ece4b8d7..c57559560 100644 --- a/clutter/clutter-text.c +++ b/clutter/clutter-text.c @@ -284,6 +284,7 @@ clutter_text_create_layout_no_cache (ClutterText *text, pango_layout_set_alignment (layout, priv->alignment); pango_layout_set_single_paragraph_mode (layout, priv->single_line_mode); pango_layout_set_justify (layout, priv->justify); + pango_layout_set_wrap (layout, priv->wrap_mode); /* Cases, assuming ellipsize != NONE on actor: * @@ -309,11 +310,14 @@ clutter_text_create_layout_no_cache (ClutterText *text, } } - /* we do not limit the layout width on editable, single-line - * text actors, since those can scroll the layout + /* We do not limit the layout width on editable, single-line text + * actors, since those can scroll the layout. For non-editable + * actors we only want to set the width if wrapping or ellipsizing + * is enabled. */ if (allocation_width > 0 && - !(priv->editable && priv->single_line_mode)) + (priv->editable ? !priv->single_line_mode + : (priv->ellipsize != PANGO_ELLIPSIZE_NONE || priv->wrap))) { gint width; diff --git a/tests/conform/test-text-cache.c b/tests/conform/test-text-cache.c index f7237b1d6..ac650528d 100644 --- a/tests/conform/test-text-cache.c +++ b/tests/conform/test-text-cache.c @@ -202,7 +202,6 @@ do_tests (CallbackData *data) pango_layout_set_wrap (data->test_layout, PANGO_WRAP_WORD); g_assert (check_result (data, "Enable line wrap", TRUE) == FALSE); -#if 0 /* TEST 11: change wrap mode * FIXME - broken */ @@ -210,7 +209,6 @@ do_tests (CallbackData *data) PANGO_WRAP_CHAR); pango_layout_set_wrap (data->test_layout, PANGO_WRAP_CHAR); g_assert (check_result (data, "Change wrap mode", TRUE) == FALSE); -#endif /* TEST 12: enable justify */ clutter_text_set_justify (CLUTTER_TEXT (data->label), TRUE);