gimp r27730 - in trunk: . plug-ins/pygimp



Author: neo
Date: Thu Nov 27 11:57:07 2008
New Revision: 27730
URL: http://svn.gnome.org/viewvc/gimp?rev=27730&view=rev

Log:
2008-11-27  Sven Neumann  <sven gimp org>

	Bug 562386 â PF_SLIDER and PF_SPINNER 'Step' values do not 
change
	consistently...

	* plug-ins/pygimp/gimpfu.py (SliderEntry): set the precision on
	the slider just as we do it for the spin-button.



Modified:
   trunk/ChangeLog
   trunk/plug-ins/pygimp/gimpfu.py

Modified: trunk/plug-ins/pygimp/gimpfu.py
==============================================================================
--- trunk/plug-ins/pygimp/gimpfu.py	(original)
+++ trunk/plug-ins/pygimp/gimpfu.py	Thu Nov 27 11:57:07 2008
@@ -480,13 +480,25 @@
 #            def get_value(self):
 #                return eval(self.get_text(), {}, {})
 
+
+    def precision(step):
+        # calculate a reasonable precision from a given step size
+        if math.fabs(step) >= 1.0 or step == 0.0:
+            digits = 0
+        else:
+            digits = abs(math.floor(math.log10(math.fabs(step))));
+        if digits > 20:
+            digits = 20
+        return int(digits)
+
     class SliderEntry(gtk.HScale):
         # bounds is (upper, lower, step)
         def __init__(self, default=0, bounds=(0, 100, 5)):
-            self.adj = gtk.Adjustment(default, bounds[0],
-                                      bounds[1], bounds[2],
-                                      bounds[2], 0)
+            step = bounds[2]
+            self.adj = gtk.Adjustment(default, bounds[0], bounds[1],
+                                      step, 10 * step, 0)
             gtk.HScale.__init__(self, self.adj)
+            self.set_digits(precision(step))
 
         def get_value(self):
             return self.adj.value
@@ -497,14 +509,7 @@
             step = bounds[2]
             self.adj = gtk.Adjustment(default, bounds[0], bounds[1],
                                       step, 10 * step, 0)
-            step = bounds[2]
-            if math.fabs(step) >= 1.0 or step == 0.0:
-                digits = 0
-            else:
-                digits = abs(math.floor(math.log10(math.fabs(step))));
-            if digits > 20:
-                digits = 20
-            gtk.SpinButton.__init__(self, self.adj, step, int(digits))
+            gtk.SpinButton.__init__(self, self.adj, step, precision(step))
 
     class ToggleEntry(gtk.ToggleButton):
         def __init__(self, default=0):



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]