GtkEntry: Fix a few irregularities in the size request code
We don't want the size request to change as icons come and go (thinking e.g. about the caps lock warning). Just make sure that we have enough room for showing the icons.
This commit is contained in:
@ -3360,25 +3360,25 @@ gtk_entry_get_preferred_width (GtkWidget *widget,
|
||||
PangoFontMetrics *metrics;
|
||||
GtkBorder borders;
|
||||
PangoContext *context;
|
||||
gint icon_widths = 0;
|
||||
gint icon_width, i;
|
||||
gint min, nat;
|
||||
gint char_width;
|
||||
gint digit_width;
|
||||
gint char_pixels;
|
||||
|
||||
context = gtk_widget_get_pango_context (widget);
|
||||
_gtk_entry_get_borders (entry, &borders);
|
||||
|
||||
context = gtk_widget_get_pango_context (widget);
|
||||
metrics = pango_context_get_metrics (context,
|
||||
pango_context_get_font_description (context),
|
||||
pango_context_get_language (context));
|
||||
|
||||
_gtk_entry_get_borders (entry, &borders);
|
||||
|
||||
char_width = pango_font_metrics_get_approximate_char_width (metrics);
|
||||
digit_width = pango_font_metrics_get_approximate_digit_width (metrics);
|
||||
char_pixels = (MAX (char_width, digit_width) + PANGO_SCALE - 1) / PANGO_SCALE;
|
||||
|
||||
pango_font_metrics_unref (metrics);
|
||||
|
||||
if (priv->width_chars < 0)
|
||||
min = MIN_ENTRY_WIDTH + borders.left + borders.right;
|
||||
else
|
||||
@ -3389,22 +3389,12 @@ gtk_entry_get_preferred_width (GtkWidget *widget,
|
||||
else
|
||||
nat = char_pixels * priv->max_width_chars + borders.left + borders.right;
|
||||
|
||||
nat = MAX (min, nat);
|
||||
|
||||
icon_width = 0;
|
||||
for (i = 0; i < MAX_ICONS; i++)
|
||||
{
|
||||
icon_width = get_icon_width (entry, i);
|
||||
if (icon_width > 0)
|
||||
icon_widths += icon_width;
|
||||
}
|
||||
icon_width += get_icon_width (entry, i);
|
||||
|
||||
if (icon_widths > min)
|
||||
{
|
||||
min += icon_widths;
|
||||
nat += icon_width;
|
||||
}
|
||||
|
||||
pango_font_metrics_unref (metrics);
|
||||
min = MAX (min, icon_width);
|
||||
nat = MAX (min, nat);
|
||||
|
||||
*minimum = min;
|
||||
*natural = nat;
|
||||
|
||||
Reference in New Issue
Block a user