[gimp] app: make the new rounding code in GimpSpinScale less totally stupid
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: make the new rounding code in GimpSpinScale less totally stupid
- Date: Thu, 19 Jun 2014 16:59:41 +0000 (UTC)
commit 5a4e9d0e03e853caa618e465973c474685457f31
Author: Michael Natterer <mitch gimp org>
Date: Thu Jun 19 18:56:43 2014 +0200
app: make the new rounding code in GimpSpinScale less totally stupid
app/widgets/gimpspinscale.c | 22 +++++++++++++++-------
1 files changed, 15 insertions(+), 7 deletions(-)
---
diff --git a/app/widgets/gimpspinscale.c b/app/widgets/gimpspinscale.c
index 25d3e5b..c1a90ca 100644
--- a/app/widgets/gimpspinscale.c
+++ b/app/widgets/gimpspinscale.c
@@ -623,13 +623,21 @@ gimp_spin_scale_change_value (GtkWidget *widget,
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);
+ if (digits > 0)
+ {
+ gint power = 1;
+
+ while (digits--)
+ power *= 10;
+
+ /* 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 *= power;
+ value = RINT (value);
+ value /= power;
+ }
gtk_adjustment_set_value (adjustment, value);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]