Make sure not to base the minimum size on "max-width-chars", only the natural size.

This commit is contained in:
Tristan Van Berkom
2010-04-20 20:30:10 -04:00
parent 630357beb3
commit 680d7762ba

View File

@ -3062,7 +3062,7 @@ get_label_wrap_width (GtkLabel *label)
if (priv->wrap_width < 0) if (priv->wrap_width < 0)
{ {
if (priv->width_chars > 0 || priv->max_width_chars > 0) if (priv->width_chars > 0)
{ {
PangoLayout *layout; PangoLayout *layout;
PangoContext *context; PangoContext *context;
@ -3086,21 +3086,14 @@ get_label_wrap_width (GtkLabel *label)
text_width = rect.width; text_width = rect.width;
if (priv->max_width_chars < 0)
{
priv->wrap_width = PANGO_PIXELS (MAX (text_width, char_pixels * priv->width_chars)); priv->wrap_width = PANGO_PIXELS (MAX (text_width, char_pixels * priv->width_chars));
} }
else
{
priv->wrap_width = PANGO_PIXELS (MIN (text_width, char_pixels * priv->max_width_chars));
}
}
else else
{ {
PangoLayout *layout; PangoLayout *layout;
layout = gtk_widget_create_pango_layout (GTK_WIDGET (label), layout = gtk_widget_create_pango_layout (GTK_WIDGET (label),
"This long string gives a good enough length for any line to have."); "This string is just about long enough.");
pango_layout_get_size (layout, &priv->wrap_width, NULL); pango_layout_get_size (layout, &priv->wrap_width, NULL);
g_object_unref (layout); g_object_unref (layout);
} }
@ -3195,7 +3188,7 @@ gtk_label_ensure_layout (GtkLabel *label, gboolean guess_wrap_width)
if (aux_width > 0) if (aux_width > 0)
pango_layout_set_width (label->layout, aux_width * PANGO_SCALE); pango_layout_set_width (label->layout, aux_width * PANGO_SCALE);
else if (guess_wrap_width == FALSE && else if (guess_wrap_width == FALSE &&
widget->allocation.width > 1) widget->allocation.width > 1 && widget->allocation.height > 1)
{ {
if (angle == 90 || angle == 270) if (angle == 90 || angle == 270)
width = widget->allocation.height - label->misc.ypad * 2; width = widget->allocation.height - label->misc.ypad * 2;