}
if (label->single_line_mode)
- required_rect.height = get_single_line_height (GTK_WIDGET (label), label->layout);
+ required_rect.height = get_single_line_height (GTK_WIDGET (label), label->layout);
if (label->have_transform)
{
required_rect.width = PANGO_PIXELS_CEIL (required_rect.width);
required_rect.height = PANGO_PIXELS_CEIL (required_rect.height);
+
+ /* if a width-request is set, use that as the requested label width */
if ((label->wrap || label->ellipsize ||
priv->width_chars > 0 || priv->max_width_chars > 0) &&
aux_info && aux_info->width > 0)
required_rect.width = aux_info->width;
- minimum_size->width = required_rect.width + label->misc.xpad * 2;
+ /* XXX TODO: Ideally for wrapping labels, the width should be one char or the length
+ * of the longest word in the text depending on wrap mode.
+ */
+
+ minimum_size->width = required_rect.width + label->misc.xpad * 2;
minimum_size->height = required_rect.height + label->misc.ypad * 2;
/* Natural size */
static void
get_size_for_allocation (GtkLabel *label,
GtkOrientation orientation,
- gint allocation,
- gint *minimum_size,
- gint *natural_size)
+ gint allocation,
+ gint *minimum_size,
+ gint *natural_size)
{
PangoLayout *layout;
GtkWidgetAuxInfo *aux_info =
if (natural_size)
{
-// pango_layout_set_ellipsize (layout, PANGO_ELLIPSIZE_NONE);
+ //pango_layout_set_ellipsize (layout, PANGO_ELLIPSIZE_NONE);
pango_layout_get_pixel_size (layout, NULL, natural_size);
}
GTK_WIDGET_CLASS (gtk_label_parent_class)->size_allocate (widget, allocation);
- /* The layout may have been recently cleared in get_size_for_allocation(), but the
+ /* The layout may have been recently cleared in get_size_for_orientation(), but the
* width at that point may not be the same as the allocated width
*/
if (label->wrap)
pango_extents_to_pixels (&logical, NULL);
- if (label->ellipsize || priv->width_chars > 0 || priv->full_size)
+ if (label->wrap || label->ellipsize || priv->width_chars > 0 || priv->full_size)
{
int width;
req_width += 2 * misc->xpad;
req_height += 2 * misc->ypad;
}
- else if (label->wrap)
- {
- GtkWidgetAuxInfo *aux_info = _gtk_widget_get_aux_info (widget, FALSE);
-
- if (aux_info->width > 0)
- req_width = aux_info->width;
- else
- req_width = widget->allocation.width;
-
- if (aux_info->height > 0)
- req_height = aux_info->height;
- else
- req_height = widget->allocation.height;
-
- req_width -= 2 * misc->xpad;
- req_height -= 2 * misc->ypad;
- }
else
{
req_width = widget->requisition.width;