Natural size should never ellipsize.
Tests added.
{
int min, max, mid, text_width, text_height;
+ /* Can't use a measuring layout here, because we need to force
+ * ellipsizing mode */
+ gtk_label_ensure_layout (self);
+ layout = pango_layout_copy (self->layout);
+ pango_layout_set_ellipsize (layout, PANGO_ELLIPSIZE_NONE);
+
/* binary search for the smallest width where the height doesn't
* eclipse the given height */
min = MAX (minimum_default, 0);
- layout = gtk_label_get_measuring_layout (self, NULL, -1);
+
+ pango_layout_set_width (layout, -1);
pango_layout_get_size (layout, &max, NULL);
min = PANGO_PIXELS_CEIL (min);
while (min < max)
{
mid = (min + max) / 2;
- layout = gtk_label_get_measuring_layout (self, layout, mid * PANGO_SCALE);
+ pango_layout_set_width (layout, mid * PANGO_SCALE);
pango_layout_get_size (layout, &text_width, &text_height);
text_width = PANGO_PIXELS_CEIL (text_width);
if (text_width > mid)
max = mid;
}
- *minimum_width = min * PANGO_SCALE;
*natural_width = min * PANGO_SCALE;
+
+ if (self->ellipsize != PANGO_ELLIPSIZE_NONE)
+ {
+ g_object_unref (layout);
+ layout = gtk_label_get_measuring_layout (self, NULL, MAX (minimum_default, 0));
+ pango_layout_get_size (layout, minimum_width, NULL);
+ *minimum_width = MAX (*minimum_width, minimum_default);
+ }
+ else
+ {
+ *minimum_width = *natural_width;
+ }
}
g_object_unref (layout);
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+ <object class="GtkWindow">
+ <property name="decorated">0</property>
+ <child>
+ <object class="GtkBox">
+ <child>
+ <object class="GtkLabel">
+ <property name="label">Hello World</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+</interface>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+ <object class="GtkWindow">
+ <property name="decorated">0</property>
+ <child>
+ <object class="GtkBox">
+ <child>
+ <object class="GtkLabel">
+ <property name="label">Hello World</property>
+ <property name="ellipsize">end</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+</interface>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+ <object class="GtkWindow">
+ <property name="decorated">0</property>
+ <child>
+ <object class="GtkBox">
+ <child>
+ <object class="GtkLabel">
+ <property name="label">Hello World</property>
+ <property name="wrap">True</property>
+ <property name="wrap-mode">char</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+</interface>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+ <object class="GtkWindow">
+ <property name="decorated">0</property>
+ <child>
+ <object class="GtkBox">
+ <child>
+ <object class="GtkLabel">
+ <property name="label">Hello World</property>
+ <property name="ellipsize">end</property>
+ <property name="wrap">True</property>
+ <property name="wrap-mode">char</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+</interface>
<interface>
<object class="GtkWindow" id="window1">
<property name="decorated">0</property>
- <signal name="realize" handler="reftest:set_default_direction_ltr"/>
<child>
<object class="GtkGrid" id="grid1">
<property name="row_spacing">1</property>
<interface>
<object class="GtkWindow" id="window1">
<property name="decorated">0</property>
- <signal name="realize" handler="reftest:set_default_direction_ltr"/>
<child>
<object class="GtkGrid" id="grid1">
<property name="row-spacing">1</property>
'gtk-icontheme-sizing.css',
'gtk-icontheme-sizing.ref.ui',
'gtk-icontheme-sizing.ui',
+ 'hbox-with-ellipsizing-label.ref.ui',
+ 'hbox-with-ellipsizing-label.ui',
+ 'hbox-with-ellipsizing-wrapping-label.ref.ui',
+ 'hbox-with-ellipsizing-wrapping-label.ui',
'icon-effect-missing.css',
'icon-effect-missing.ref.ui',
'icon-effect-missing.ui',