summaryrefslogtreecommitdiff
path: root/gtk/gtklabel.c
diff options
context:
space:
mode:
authorTristan Van Berkom <tristan.van.berkom@gmail.com>2010-04-17 01:49:35 -0400
committerTristan Van Berkom <tristan.van.berkom@gmail.com>2010-04-17 01:49:35 -0400
commit46fe9c3f00a1cd7f175d726bbe521233d2e86018 (patch)
treebc5f52f33ac2cb2f34387eb70c23cfdb3ddb4b5e /gtk/gtklabel.c
parentcaba7992b87690cc0e27dccd782986c8893ec9fd (diff)
downloadgtk+-46fe9c3f00a1cd7f175d726bbe521233d2e86018.tar.gz
Disabling natural sizes of labels.
Since GtkLabel is returning invalid natural sizes for now, in order to test regressions well with the new width-for-height api, I've temporarily disabled the natural values.
Diffstat (limited to 'gtk/gtklabel.c')
-rw-r--r--gtk/gtklabel.c28
1 files changed, 19 insertions, 9 deletions
diff --git a/gtk/gtklabel.c b/gtk/gtklabel.c
index c730e311dc..865d8f4af9 100644
--- a/gtk/gtklabel.c
+++ b/gtk/gtklabel.c
@@ -3253,7 +3253,7 @@ gtk_label_get_desired_size (GtkExtendedLayout *layout,
label->layout = backup;
}
- if (label->single_line_mode || label->wrap)
+ if (label->single_line_mode)
required_rect.height = get_single_line_height (GTK_WIDGET (label), label->layout);
if (label->have_transform)
@@ -3283,6 +3283,10 @@ gtk_label_get_desired_size (GtkExtendedLayout *layout,
minimum = required_rect.height + label->misc.ypad * 2;
}
+
+ natural = minimum;
+
+#if 0
/* Natural size */
natural_layout = pango_layout_copy (label->layout);
pango_layout_set_width (natural_layout, -1);
@@ -3310,6 +3314,7 @@ gtk_label_get_desired_size (GtkExtendedLayout *layout,
natural = required_rect.height + label->misc.ypad * 2;
g_object_unref (natural_layout);
+#endif
if (minimum_size)
*minimum_size = minimum;
@@ -3347,6 +3352,7 @@ get_size_for_allocation (GtkLabel *label,
GtkWidgetAuxInfo *aux_info =
_gtk_widget_get_aux_info (GTK_WIDGET (label), FALSE);
gint aux_size;
+ gint text_height;
if (label->wrap)
gtk_label_clear_layout (label);
@@ -3354,24 +3360,28 @@ get_size_for_allocation (GtkLabel *label,
gtk_label_ensure_layout (label);
layout = pango_layout_copy (label->layout);
- if (orientation == GTK_ORIENTATION_HORIZONTAL)
- aux_size = aux_info->width;
+ if (aux_info)
+ {
+ if (orientation == GTK_ORIENTATION_HORIZONTAL)
+ aux_size = aux_info->width;
+ else
+ aux_size = aux_info->height;
+ }
else
- aux_size = aux_info->height;
+ aux_size = 0;
if (aux_size > 0)
pango_layout_set_width (layout, aux_size * PANGO_SCALE);
else
pango_layout_set_width (layout, allocation * PANGO_SCALE);
+ pango_layout_get_pixel_size (layout, NULL, &text_height);
+
if (minimum_size)
- pango_layout_get_pixel_size (layout, NULL, minimum_size);
+ *minimum_size = text_height;
if (natural_size)
- {
- //pango_layout_set_ellipsize (layout, PANGO_ELLIPSIZE_NONE);
- pango_layout_get_pixel_size (layout, NULL, natural_size);
- }
+ *natural_size = text_height;
g_object_unref (layout);
}