[pitivi: 21/27] TimeWidget: let user decide wether to send the value-changed signal or not



commit 6e768f73057caea01b13811a8211a52711d439b1
Author: Thibault Saunier <thibault saunier collabora co uk>
Date:   Wed Jan 19 16:30:08 2011 +0100

    TimeWidget: let user decide wether to send the value-changed signal or not
    
    Use it in the timecode_entry in the viewer

 pitivi/ui/dynamic.py |   16 +++++++++++-----
 pitivi/ui/viewer.py  |    2 +-
 2 files changed, 12 insertions(+), 6 deletions(-)
---
diff --git a/pitivi/ui/dynamic.py b/pitivi/ui/dynamic.py
index 11b7807..ec3efcd 100644
--- a/pitivi/ui/dynamic.py
+++ b/pitivi/ui/dynamic.py
@@ -116,6 +116,7 @@ class TextWidget(gtk.HBox, DynamicWidget):
         self.matches = None
         self.last_valid = None
         self.valid = False
+        self.send_signal = True
         self.text.connect("changed", self._textChanged)
         if matches:
             if type(matches) is str:
@@ -127,7 +128,8 @@ class TextWidget(gtk.HBox, DynamicWidget):
     def connectValueChanged(self, callback, *args):
         return self.connect("value-changed", callback, *args)
 
-    def setWidgetValue(self, value):
+    def setWidgetValue(self, value, send_signal = True):
+        self.send_signal = send_signal
         self.text.set_text(value)
 
     def getWidgetValue(self):
@@ -144,7 +146,8 @@ class TextWidget(gtk.HBox, DynamicWidget):
         if self.matches:
             if self._filter(text):
                 self.last_valid = text
-                self.emit("value-changed")
+                if self.send_signal:
+                    self.emit("value-changed")
                 if not self.valid:
                     self.text.set_icon_from_stock(1, None)
                 self.valid = True
@@ -152,9 +155,11 @@ class TextWidget(gtk.HBox, DynamicWidget):
                 if self.valid:
                     self.text.set_icon_from_stock(1, gtk.STOCK_DIALOG_WARNING)
                 self.valid = False
-        else:
+        elif self.send_signal:
             self.emit("value-changed")
 
+        self.send_signal = True
+
     def _filter(self, text):
         match = self.matches.match(text)
         if match is not None:
@@ -249,8 +254,9 @@ class TimeWidget(TextWidget, DynamicWidget):
 
       return nanosecs
 
-    def setWidgetValue(self, value):
-      TextWidget.setWidgetValue(self, time_to_string(value))
+    def setWidgetValue(self, value, send_signal = True):
+      TextWidget.setWidgetValue(self, time_to_string(value),
+                                send_signal = send_signal)
 
     def connectFocusEvents (self, focusInCb, focusOutCb):
         fIn = self.text.connect ("button-press-event", focusInCb)
diff --git a/pitivi/ui/viewer.py b/pitivi/ui/viewer.py
index 3b19e1f..4dc0f8b 100644
--- a/pitivi/ui/viewer.py
+++ b/pitivi/ui/viewer.py
@@ -454,7 +454,7 @@ class PitiviViewer(gtk.VBox, Loggable):
         self.info("value:%s, frame:%d", gst.TIME_ARGS(value), frame)
         self.current_time = value
         self.current_frame = frame
-        self.timecode_entry.setWidgetValue(value)
+        self.timecode_entry.setWidgetValue(value, False)
         if not self.moving_slider:
             self.posadjust.set_value(float(value))
         return False



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