gimp r27731 - in branches/gimp-2-6: . plug-ins/pygimp
- From: neo svn gnome org
- To: svn-commits-list gnome org
- Subject: gimp r27731 - in branches/gimp-2-6: . plug-ins/pygimp
- Date: Thu, 27 Nov 2008 12:58:17 +0000 (UTC)
Author: neo
Date: Thu Nov 27 12:58:16 2008
New Revision: 27731
URL: http://svn.gnome.org/viewvc/gimp?rev=27731&view=rev
Log:
2008-11-27  Sven Neumann  <sven gimp org>
	Merged from trunk:
	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:
   branches/gimp-2-6/ChangeLog
   branches/gimp-2-6/plug-ins/pygimp/gimpfu.py
Modified: branches/gimp-2-6/plug-ins/pygimp/gimpfu.py
==============================================================================
--- branches/gimp-2-6/plug-ins/pygimp/gimpfu.py	(original)
+++ branches/gimp-2-6/plug-ins/pygimp/gimpfu.py	Thu Nov 27 12:58:16 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]