]> Pileus Git - ~andy/gtk/commitdiff
Merge fix for bgo#315462 - Make GtkLabel deal with too-small height allocations grace...
authorFederico Mena Quintero <federico@novell.com>
Wed, 13 May 2009 00:13:33 +0000 (19:13 -0500)
committerFederico Mena Quintero <federico@novell.com>
Wed, 13 May 2009 00:13:33 +0000 (19:13 -0500)
Merge branch 'gtk-2-16'

gtk/gtklabel.c

index 73a772f6738e6150e0cee92f61b97732e0e186ae..ea963b185379f16c69eb1d453f78b6020535f95a 100644 (file)
@@ -3236,9 +3236,26 @@ get_layout_location (GtkLabel  *label,
     x = MIN (x, widget->allocation.x + widget->allocation.width - misc->xpad);
   x -= logical.x;
 
-  y = floor (widget->allocation.y + (gint)misc->ypad 
-             + MAX (((widget->allocation.height - widget->requisition.height) * misc->yalign),
-            0));
+  /* bgo#315462 - For single-line labels, *do* align the requisition with
+   * respect to the allocation, even if we are under-allocated.  For multi-line
+   * labels, always show the top of the text when they are under-allocated.  The
+   * rationale is this:
+   *
+   * - Single-line labels appear in GtkButtons, and it is very easy to get them
+   *   to be smaller than their requisition.  The button may clip the label, but
+   *   the label will still be able to show most of itself and the focus
+   *   rectangle.  Also, it is fairly easy to read a single line of clipped text.
+   *
+   * - Multi-line labels should not be clipped to showing "something in the
+   *   middle".  You want to read the first line, at least, to get some context.
+   */
+  if (pango_layout_get_line_count (label->layout) == 1)
+    y = floor (widget->allocation.y + (gint)misc->ypad 
+              + (widget->allocation.height - widget->requisition.height) * misc->yalign);
+  else
+    y = floor (widget->allocation.y + (gint)misc->ypad 
+              + MAX (((widget->allocation.height - widget->requisition.height) * misc->yalign),
+                     0));
 
   if (xp)
     *xp = x;