[pitivi] Pass the proper arguments to the audio/video layer controls



commit 406362694b61261b74f6b82d805e6dae79c2b3ba
Author: Jean-François Fortin Tam <nekohayo gmail com>
Date:   Tue Sep 10 21:44:01 2013 -0400

    Pass the proper arguments to the audio/video layer controls
    
    Passing self (the ControlContainer instance) as if it was "app" is a lie.
    Lying is bad, and causes things to go wrong.
    
    This fixes some tracebacks when trying to access other parts of the UI, which
    lays the groundwork to allow handling timeline actions sensitivity properly.

 pitivi/timeline/controls.py |    7 ++++---
 pitivi/timeline/layer.py    |   13 +++++++------
 pitivi/timeline/timeline.py |    2 +-
 3 files changed, 12 insertions(+), 10 deletions(-)
---
diff --git a/pitivi/timeline/controls.py b/pitivi/timeline/controls.py
index f75dbc4..368f176 100644
--- a/pitivi/timeline/controls.py
+++ b/pitivi/timeline/controls.py
@@ -94,9 +94,10 @@ class ControlContainer(Clutter.ScrollActor):
         "selection-changed": (GObject.SignalFlags.RUN_LAST, None, (GObject.TYPE_PYOBJECT,),)
     }
 
-    def __init__(self, timeline):
+    def __init__(self, app, timeline):
         Clutter.ScrollActor.__init__(self)
 
+        self._app = app
         self.timeline = timeline
         self.controlActors = []
         self.trackControls = []
@@ -144,9 +145,9 @@ class ControlContainer(Clutter.ScrollActor):
 
     def addTrackControl(self, layer, isAudio):
         if isAudio:
-            control = AudioLayerControl(self, layer)
+            control = AudioLayerControl(self, layer, self._app)
         else:
-            control = VideoLayerControl(self, layer)
+            control = VideoLayerControl(self, layer, self._app)
 
         controlActor = ControlActor(self, control, layer)
         controlActor.isAudio = isAudio
diff --git a/pitivi/timeline/layer.py b/pitivi/timeline/layer.py
index 2adee84..6726193 100644
--- a/pitivi/timeline/layer.py
+++ b/pitivi/timeline/layer.py
@@ -39,11 +39,12 @@ class BaseLayerControl(Gtk.VBox, Loggable):
 
     __gtype_name__ = 'LayerControl'
 
-    def __init__(self, app, layer, layer_type):
+    def __init__(self, control_container, layer, layer_type, app):
         Gtk.VBox.__init__(self, spacing=0)
         Loggable.__init__(self)
 
         self._app = app
+        self._control_container = control_container
         self.layer = layer
         self._selected = False
 
@@ -197,7 +198,7 @@ class BaseLayerControl(Gtk.VBox, Loggable):
         """
         Look if user selected layer or wants popup menu
         """
-        self._app.selectLayerControl(self)
+        self._control_container.selectLayerControl(self)
         if event.button == 3:
             self.popup.popup(None, None, None, None, event.button, event.time)
 
@@ -288,8 +289,8 @@ class VideoLayerControl(BaseLayerControl):
 
     __gtype_name__ = 'VideoLayerControl'
 
-    def __init__(self, app, layer):
-        BaseLayerControl.__init__(self, app, layer, GES.TrackType.VIDEO)
+    def __init__(self, control_container, layer, app):
+        BaseLayerControl.__init__(self, control_container, layer, GES.TrackType.VIDEO, app)
 
         opacity = Gtk.Label(label=_("Opacity:"))
 
@@ -312,8 +313,8 @@ class AudioLayerControl(BaseLayerControl):
 
     __gtype_name__ = 'AudioLayerControl'
 
-    def __init__(self, app, layer):
-        BaseLayerControl.__init__(self, app, layer, GES.TrackType.AUDIO)
+    def __init__(self, control_container, layer, app):
+        BaseLayerControl.__init__(self, control_container, layer, GES.TrackType.AUDIO, app)
 
         volume = Gtk.Label(label=_("Vol:"))
         volume_button = Gtk.VolumeButton(size=Gtk.IconSize.MENU)
diff --git a/pitivi/timeline/timeline.py b/pitivi/timeline/timeline.py
index a563e64..e49b03b 100644
--- a/pitivi/timeline/timeline.py
+++ b/pitivi/timeline/timeline.py
@@ -851,7 +851,7 @@ class Timeline(Gtk.VBox, Zoomable, Loggable):
         perspective = self.stage.get_perspective()
 
         self.timeline = TimelineStage(self)
-        self.controls = ControlContainer(self.timeline)
+        self.controls = ControlContainer(self.app, self.timeline)
         self.zoomBox = ZoomBox(self)
         self.shiftMask = False
         self.controlMask = False


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