label: max-width-chars should be ignored sometimes

When a widget is neither wrappable nor ellipsizable, we cannot modify
the label to fit into any size. So we cannot respect max-width-chars.
This commit is contained in:
Benjamin Otte 2021-11-06 16:25:11 +01:00
parent cce6a603a6
commit 81169d18c3
4 changed files with 26 additions and 1 deletions

View File

@ -1082,7 +1082,7 @@ get_static_size (GtkLabel *self,
get_default_widths (self, &minimum_default, &natural_default); get_default_widths (self, &minimum_default, &natural_default);
layout = gtk_label_get_measuring_layout (self, NULL, natural_default); layout = gtk_label_get_measuring_layout (self, NULL, self->ellipsize ? natural_default : -1);
if (orientation == GTK_ORIENTATION_HORIZONTAL) if (orientation == GTK_ORIENTATION_HORIZONTAL)
{ {

View File

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<object class="GtkWindow" id="window1">
<property name="decorated">0</property>
<child>
<object class="GtkLabel" id="label1">
<property name="label">Hello World</property>
</object>
</child>
</object>
</interface>

View File

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<object class="GtkWindow" id="window1">
<property name="decorated">0</property>
<child>
<object class="GtkLabel" id="label1">
<property name="label">Hello World</property>
<property name="max-width-chars">2</property>
</object>
</child>
</object>
</interface>

View File

@ -359,6 +359,8 @@ testdata = [
'label-sizing.ui', 'label-sizing.ui',
'label-small-ellipsized.ref.ui', 'label-small-ellipsized.ref.ui',
'label-small-ellipsized.ui', 'label-small-ellipsized.ui',
'label-small-max-width-chars.ref.ui',
'label-small-max-width-chars.ui',
'label-text-shadow-clipping.css', 'label-text-shadow-clipping.css',
'label-text-shadow-clipping.ref.ui', 'label-text-shadow-clipping.ref.ui',
'label-text-shadow-clipping.ui', 'label-text-shadow-clipping.ui',