[gtk+/native-layout] Make sure not to base the minimum size on "max-width-chars", only the natural size.



commit 680d7762baabb71aa77aeec793e3c70a2013d3b8
Author: Tristan Van Berkom <tristan van berkom gmail com>
Date:   Tue Apr 20 20:30:10 2010 -0400

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

 gtk/gtklabel.c |   15 ++++-----------
 1 files changed, 4 insertions(+), 11 deletions(-)
---
diff --git a/gtk/gtklabel.c b/gtk/gtklabel.c
index 3a60938..05c3e31 100644
--- a/gtk/gtklabel.c
+++ b/gtk/gtklabel.c
@@ -3062,7 +3062,7 @@ get_label_wrap_width (GtkLabel *label)
   
   if (priv->wrap_width < 0)
     {
-      if (priv->width_chars > 0 || priv->max_width_chars > 0)
+      if (priv->width_chars > 0)
 	{
 	  PangoLayout      *layout;
 	  PangoContext     *context;
@@ -3086,21 +3086,14 @@ get_label_wrap_width (GtkLabel *label)
 
 	  text_width = rect.width;
 
-	  if (priv->max_width_chars < 0)
-	    {
-	      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));
-	    }
+	  priv->wrap_width = PANGO_PIXELS (MAX (text_width, char_pixels * priv->width_chars));
 	}
       else
 	{
 	  PangoLayout *layout;
   
 	  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);
 	  g_object_unref (layout);
 	}
@@ -3195,7 +3188,7 @@ gtk_label_ensure_layout (GtkLabel *label, gboolean guess_wrap_width)
  	  if (aux_width > 0)
 	    pango_layout_set_width (label->layout, aux_width * PANGO_SCALE);
 	  else if (guess_wrap_width == FALSE &&
-		   widget->allocation.width > 1)
+		   widget->allocation.width > 1 && widget->allocation.height > 1)
  	    {
 	      if (angle == 90 || angle == 270)
 		width = widget->allocation.height - label->misc.ypad * 2;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]