[gimp] Bug 694477 - GimpSizeEntry input validation doesn't snap to min/max values
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] Bug 694477 - GimpSizeEntry input validation doesn't snap to min/max values
- Date: Fri, 22 Feb 2013 20:22:55 +0000 (UTC)
commit d1503ead83580eaf1961d22a1234cfa99cd71e14
Author: Michael Natterer <mitch gimp org>
Date: Fri Feb 22 21:19:59 2013 +0100
Bug 694477 - GimpSizeEntry input validation doesn't snap to min/max values
gimp_size_entry_eevl_input_callback(): CLAMP() the input value before
passing it back to GtkSpinButton, or it will revert too large/small
inputs back to the old value, instead of using the field's max/min
values.
libgimpwidgets/gimpsizeentry.c | 20 +++++++++++++++++++-
1 files changed, 19 insertions(+), 1 deletions(-)
---
diff --git a/libgimpwidgets/gimpsizeentry.c b/libgimpwidgets/gimpsizeentry.c
index 04dc333..3b83635 100644
--- a/libgimpwidgets/gimpsizeentry.c
+++ b/libgimpwidgets/gimpsizeentry.c
@@ -1310,7 +1310,9 @@ gimp_size_entry_eevl_input_callback (GtkSpinButton *spinner,
else
{
/* transform back to UI-unit */
- GimpEevlQuantity ui_unit;
+ GimpEevlQuantity ui_unit;
+ GtkAdjustment *adj;
+ gdouble val;
switch (gsef->gse->unit)
{
@@ -1330,6 +1332,22 @@ gimp_size_entry_eevl_input_callback (GtkSpinButton *spinner,
*return_val = result.value * ui_unit.value;
+ /* CLAMP() to adjustment bounds, or too large/small values
+ * will make the validation machinery revert to the old value.
+ * See bug #694477.
+ */
+ adj = gtk_spin_button_get_adjustment (spinner);
+
+ val = CLAMP (*return_val,
+ gtk_adjustment_get_lower (adj),
+ gtk_adjustment_get_upper (adj));
+
+ if (val != *return_val)
+ {
+ gtk_widget_error_bell (GTK_WIDGET (spinner));
+ *return_val = val;
+ }
+
return TRUE;
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]