Commit 45e6e0cd authored by Nelson Benítez León's avatar Nelson Benítez León

gtkentry: set minimum-width to 0 instead of 150

and use 150 as natural-width.

Currently there's no way for a GtkEntry to be less
than 150px wide (apart from using "width-chars" property),
this is too much for a default minimum-width, an app
developer may need to have a shorter GtkEntry, for example
when the UI it's been shrunk by the user (see [1]) or when
you want to match the size of another widget (which is less
than 150px) see [2] for Evince bug on using
gtk_combo_box_new_with_model_and_entry() for PDF forms where
GtkEntry of ComboBox is too wide and doesn't match the combo
list width.

Using "width-chars" property may be a workaround to obtain
a short minimum-width for the entry, but is not a proper
solution for the mentioned cases as you may not know how
short your GtkEntry will be, or the fact that using "chars"
as a width unit is not pixel accurate.

Curious note: the commit that introduced the GtkEntry
minimum-width to be 150px is from 20 years ago, see

[1] This change was already suggested by Benjamin Otte
in a blog comment

[2] Fixes issue evince#1002
parent 1729da8a
Pipeline #37334 failed with stages
in 12 minutes and 41 seconds
......@@ -166,7 +166,7 @@
* .insertion-cursor.
#define MIN_ENTRY_WIDTH 150
#define NAT_ENTRY_WIDTH 150
#define MAX_ICONS 2
......@@ -3169,13 +3169,13 @@ gtk_entry_measure (GtkWidget *widget,
digit_width = pango_font_metrics_get_approximate_digit_width (metrics);
char_pixels = (MAX (char_width, digit_width) + PANGO_SCALE - 1) / PANGO_SCALE;
if (priv->width_chars < 0)
if (priv->width_chars >= 0)
min = char_pixels * priv->width_chars;
min = 0;
if (priv->max_width_chars < 0)
nat = min;
nat = char_pixels * priv->max_width_chars;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment