libgimpwidgets: Shrink width of GimpSizeEntry

In 2baa518a, to avoid a critical we use
the resolution as the width of GimpScaleEntry
when the unit is set to pixels.
This had the side-effect of making the
width of the GimpSizeEntry very long when
the unit is initially set to pixels.
Since GimpUnit is now an object, the original
critical no longer displays. Therefore, we
partially revert 2baa518a and refer to the
value as entry_width instead for clarity.
The minimum width is set to 7 to match
the minimum width of GimpSpinButton.
This commit is contained in:
Alx Sa 2025-03-01 03:45:13 +00:00
parent 9e03e45f8f
commit a74287c5cc

View file

@ -3550,7 +3550,7 @@ gimp_prop_size_entry_new (GObject *config,
gdouble lower;
gdouble upper;
GimpUnit *unit_value;
gint scaled_resolution;
gint entry_width;
param_spec = find_param_spec (config, property_name, G_STRFUNC);
if (! param_spec)
@ -3593,15 +3593,13 @@ gimp_prop_size_entry_new (GObject *config,
show_percent = FALSE;
}
if (unit_value != gimp_unit_pixel ())
scaled_resolution = gimp_unit_get_scaled_digits (unit_value, resolution);
else
scaled_resolution = (gint) resolution;
entry_width = gimp_prop_size_entry_num_chars (lower, upper) + 1 +
gimp_unit_get_scaled_digits (unit_value, resolution);
entry_width = MAX (entry_width, 7);
entry = gimp_size_entry_new (1, unit_value, unit_format,
show_pixels, show_percent, FALSE,
gimp_prop_size_entry_num_chars (lower, upper) + 1 +
scaled_resolution, update_policy);
entry_width, update_policy);
set_param_spec (NULL,
gimp_size_entry_get_help_widget (GIMP_SIZE_ENTRY (entry), 0),