[pitivi] ui.prefs: set adjustment parameters on numeric widgets when value changes



commit 7104752c05a582241ccf3d9bf8eed9a3cd37978c
Author: Brandon Lewis <brandon_lewis berkeley edu>
Date:   Thu Apr 16 12:45:39 2009 -0700

    ui.prefs: set adjustment parameters on numeric widgets when value changes
---
 pitivi/ui/dynamic.py |   20 +++++++++++++++++++-
 1 files changed, 19 insertions(+), 1 deletions(-)

diff --git a/pitivi/ui/dynamic.py b/pitivi/ui/dynamic.py
index 4c470eb..4e386af 100644
--- a/pitivi/ui/dynamic.py
+++ b/pitivi/ui/dynamic.py
@@ -26,6 +26,7 @@ interfaces
 import gobject
 import gtk
 import re
+import sys
 from gettext import gettext as _
 
 class DynamicWidget(object):
@@ -125,6 +126,8 @@ class NumericWidget(gtk.HBox):
         gtk.HBox.__init__(self)
 
         self.adjustment = gtk.Adjustment()
+        self.upper = upper
+        self.lower = lower
         if (upper != None) and (lower != None):
             self.slider = gtk.HScale(self.adjustment)
             self.pack_end(self.slider)
@@ -148,7 +151,22 @@ class NumericWidget(gtk.HBox):
         return self.adjustment.get_value()
 
     def setWidgetValue(self, value):
-        return self.adjustment.set_value(value)
+        type_ = type(value)
+        if type_ == int:
+            minimum, maximum = (-sys.maxint, sys.maxint)
+            step = 1.0
+            page = 10.0
+        elif type_ == float:
+            minimum, maximum = (float("-Infinity"), float("Infinity"))
+            step = 0.00001
+            page = 0.01
+        if self.lower:
+            minimum = self.lower
+        if self.upper:
+            maximum = self.upper
+        self.adjustment.set_all(value, minimum, maximum, step, page, 0)
+        self.spinner.props.climb_rate = 0.01 * abs(min(maximum, 1000) -
+            max(minimum, -1000))
 
 class ToggleWidget(gtk.CheckButton):
 



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