[gimp] app: round mouse-entered GimpSpinScale values to the spinbutton's precision
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: round mouse-entered GimpSpinScale values to the spinbutton's precision
- Date: Thu, 19 Jun 2014 13:57:24 +0000 (UTC)
commit be80f49018d46a0a5fb2d7427a99cd54bd131d86
Author: Michael Natterer <mitch gimp org>
Date: Thu Jun 19 15:49:27 2014 +0200
app: round mouse-entered GimpSpinScale values to the spinbutton's precision
So the adjustment's value is always what is shown (and can be entered
manually) in the widget. This way a GimpSpinScale will never change
its adjustment on focus-out, and not cause whatever unexpected updates
of its model and whatever is connected to it (like changing the
properties and thus unvalidating the caches of a Gegl graph).
app/widgets/gimpspinscale.c | 11 +++++++++++
1 files changed, 11 insertions(+), 0 deletions(-)
---
diff --git a/app/widgets/gimpspinscale.c b/app/widgets/gimpspinscale.c
index b913821..25d3e5b 100644
--- a/app/widgets/gimpspinscale.c
+++ b/app/widgets/gimpspinscale.c
@@ -587,6 +587,7 @@ gimp_spin_scale_change_value (GtkWidget *widget,
gdouble upper;
gint width;
gdouble value;
+ gint digits;
gimp_spin_scale_get_limits (GIMP_SPIN_SCALE (widget), &lower, &upper);
@@ -620,6 +621,16 @@ gimp_spin_scale_change_value (GtkWidget *widget,
value = fraction * (upper - lower) + lower;
}
+ digits = gtk_spin_button_get_digits (spin_button);
+
+ /* round the value to the possible precision of the spinbutton, so
+ * a focus-out will not change the value again, causing inadvertend
+ * adjustment signals.
+ */
+ value *= powl (10, digits);
+ value = RINT (value);
+ value /= powl (10, digits);
+
gtk_adjustment_set_value (adjustment, value);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]