From a74287c5cc66b0b2e13eb14d08dee22339304842 Mon Sep 17 00:00:00 2001 From: Alx Sa Date: Sat, 1 Mar 2025 03:45:13 +0000 Subject: [PATCH] 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. --- libgimpwidgets/gimppropwidgets.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/libgimpwidgets/gimppropwidgets.c b/libgimpwidgets/gimppropwidgets.c index 085785192b..d4ad63e037 100644 --- a/libgimpwidgets/gimppropwidgets.c +++ b/libgimpwidgets/gimppropwidgets.c @@ -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),