[pitivi] Enhance effect drop in the timeline



commit dc0fa55ffdc41ccd1c8a5ac17f323a211cf40341
Author: Thibault Saunier <tsaunier gnome org>
Date:   Fri Jul 30 13:49:44 2010 +0200

    Enhance effect drop in the timeline

 pitivi/ui/effectsconfiguration.py |    2 +-
 pitivi/ui/gstwidget.py            |   58 +++++++++++++++++++++----------------
 pitivi/ui/timelinecanvas.py       |   15 +++++++++
 3 files changed, 49 insertions(+), 26 deletions(-)
---
diff --git a/pitivi/ui/effectsconfiguration.py b/pitivi/ui/effectsconfiguration.py
index a7e864d..6680cc0 100644
--- a/pitivi/ui/effectsconfiguration.py
+++ b/pitivi/ui/effectsconfiguration.py
@@ -78,7 +78,7 @@ class EffectsPropertiesHandling:
 
     def _connectAllWidgetCbs(self, effect_configuration_ui, effect):
         for prop, widget in effect_configuration_ui.properties.iteritems():
-            if type(widget) in [gtk.SpinButton]:
+            if type(widget) in [gtk.SpinButton, gtk.HScale]:
                 widget.connect("value-changed", self._onValueChangedCb)
             elif type(widget) in [gtk.Entry, gtk.ComboBox]:
                 widget.connect("changed", self._onValueChangedCb)
diff --git a/pitivi/ui/gstwidget.py b/pitivi/ui/gstwidget.py
index 6c6f69b..82ff2f6 100644
--- a/pitivi/ui/gstwidget.py
+++ b/pitivi/ui/gstwidget.py
@@ -61,32 +61,39 @@ def make_property_widget(unused_element, prop, value=None):
         widget = gtk.Entry()
         widget.set_text(str(value))
     elif (type_name in ['guint64', 'gint64', 'guint', 'gint', 'gfloat',
-        'gdouble', 'gulong']):
-        widget = gtk.SpinButton()
-        if type_name == 'gint':
-            minimum, maximum = (-(2**31), 2**31 - 1)
-            widget.set_increments(1.0, 10.0)
-        elif type_name == 'guint':
-            minimum, maximum = (0, 2**32 - 1)
-            widget.set_increments(1.0, 10.0)
-        elif type_name == 'gint64':
-            minimum, maximum = (-(2**63), 2**63 - 1)
-            widget.set_increments(1.0, 10.0)
-        elif type_name in ['gulong', 'guint64']:
-            minimum, maximum = (0, 2**64 - 1)
-            widget.set_increments(1.0, 10.0)
-        elif type_name in ['gfloat', 'gdouble']:
-            minimum, maximum = (float("-Infinity"), float("Infinity"))
-            widget.set_increments(0.00001, 0.01)
-            widget.set_digits(5)
-        if hasattr(prop, "minimum"):
+        'gulong', 'gdouble']):
+        maximum , minimum = None, None
+        if hasattr(prop, "minimum") and hasattr(prop, "maximum"):
             minimum = prop.minimum
-        if hasattr(prop, "maximum"):
             maximum = prop.maximum
-        widget.set_range(minimum, maximum)
-        widget.props.climb_rate = 0.01 * abs(min(maximum, 1000) -
-            max(minimum, -1000))
-        widget.set_value(float(value))
+        if minimum >- 10 and maximum < 10:
+            widget = gtk.HScale()
+            widget.set_draw_value(True)
+            widget.set_range(prop.minimum, prop.maximum)
+            widget.set_value(value)
+        else:
+            widget = gtk.SpinButton()
+            if type_name == 'gint':
+                minimum, maximum = (-(2**31), 2**31 - 1)
+                widget.set_increments(1.0, 10.0)
+            elif type_name == 'guint':
+                minimum, maximum = (0, 2**32 - 1)
+                widget.set_increments(1.0, 10.0)
+            elif type_name == 'gint64':
+                minimum, maximum = (-(2**63), 2**63 - 1)
+                widget.set_increments(1.0, 10.0)
+            elif type_name in ['gulong', 'guint64']:
+                minimum, maximum = (0, 2**64 - 1)
+                widget.set_increments(1.0, 10.0)
+            elif type_name in ['gfloat','gdouble']:
+                minimum, maximum = (float("-Infinity"), float("Infinity"))
+                widget.set_increments(0.00001, 0.01)
+                widget.set_digits(5)
+            if maximum and minimum:
+                widget.set_range(minimum, maximum)
+                widget.props.climb_rate = 0.01 * abs(min(maximum, 1000) -
+                    max(minimum, -1000))
+            widget.set_value(float(value))
     elif (type_name == 'gboolean'):
         widget = gtk.CheckButton()
         if value:
@@ -158,6 +165,7 @@ class GstElementSettingsWidget(gtk.VBox, Loggable):
             self.pack_start(table)
             self.show_all()
             return
+
         if default_btn:
             table = gtk.Table(rows=len(props), columns=3)
         else:
@@ -214,7 +222,7 @@ class GstElementSettingsWidget(gtk.VBox, Loggable):
             if model.get_value(iter, 0) == str(widget_value[1].value_name):
                 widget_value[0].set_active_iter(iter)
 
-        if type(widget) in [gtk.SpinButton]:
+        if type(widget) in [gtk.SpinButton, gtk.HScale]:
             widget.set_value(float(value))
         elif type(widget) in [gtk.Entry]:
             widget.set_text(str(value))
diff --git a/pitivi/ui/timelinecanvas.py b/pitivi/ui/timelinecanvas.py
index 99179d7..451c782 100644
--- a/pitivi/ui/timelinecanvas.py
+++ b/pitivi/ui/timelinecanvas.py
@@ -202,6 +202,21 @@ class TimelineCanvas(goocanvas.Canvas, Zoomable, Loggable):
     _got_motion_notify = False
 
     def getItemsInArea(self, x1, y1, x2, y2):
+        '''
+        Permits to get the Non UI L{Track}/L{TrackObject} in a list of set
+        corresponding to the L{Track}/L{TrackObject} which are in the are
+
+        @param x1: The horizontal coordinate of the up left corner of the area
+        @type x1: An C{int}
+        @param y1: The vertical coordinate of the up left corner of the area
+        @type y1: An C{int}
+        @param x2: The horizontal coordinate of the down right corner of the area
+        @type x2: An C{int}
+        @param x2: The vertical coordinate of the down right corner of the area
+        @type x2: An C{int}
+
+        @returns: A list of L{Track}, L{TrackObject} tuples
+        '''
         items = self.get_items_in_area(goocanvas.Bounds(x1, y1, x2, y2), True, True,
             True)
         if items:



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