[pitivi] Integrate widgets in UI



commit 36ab357c084663bd7de17e880ae29b7ed753658b
Author: Paul Lange <palango gmx de>
Date:   Wed May 2 19:11:41 2012 -0500

    Integrate widgets in UI

 pitivi/timeline/layercontrols.py |   33 +++++++-----------
 pitivi/timeline/timeline.py      |   15 ++++----
 pitivi/timeline/track.py         |   68 +-------------------------------------
 3 files changed, 22 insertions(+), 94 deletions(-)
---
diff --git a/pitivi/timeline/layercontrols.py b/pitivi/timeline/layercontrols.py
index 369effb..0a316c7 100644
--- a/pitivi/timeline/layercontrols.py
+++ b/pitivi/timeline/layercontrols.py
@@ -21,7 +21,11 @@
 
 import gtk
 
+from gettext import gettext as _
+
 from pitivi.utils.loggable import Loggable
+from pitivi.utils.ui import LAYER_HEIGHT_EXPANDED,\
+        LAYER_HEIGHT_COLLAPSED, LAYER_SPACING
 
 
 # TODO add tooltips
@@ -33,7 +37,7 @@ class BaseLayerControl(gtk.Table, Loggable):
 
     __gtype_name__ = 'LayerControl'
 
-    def __init__(self, layer_type):
+    def __init__(self, track, layer_type):
         gtk.Table.__init__(self, rows=2, columns=2)
         Loggable.__init__(self)
 
@@ -68,7 +72,7 @@ class BaseLayerControl(gtk.Table, Loggable):
         upper = gtk.HBox()
         upper.pack_start(self.name_entry, True, True, 0)
         upper.pack_start(self.solo_button, False, False, 1)
-        upper.pack_start(self.visivle_option, False, False, 2)
+        upper.pack_start(self.visible_option, False, False, 2)
 
         # Lower bar
         self.lower_hbox = gtk.HBox()
@@ -76,12 +80,10 @@ class BaseLayerControl(gtk.Table, Loggable):
         self.attach(upper, 1, 2, 0, 1)
         self.attach(self.lower_hbox, 1, 2, 1, 2)
 
-        # Center the label horizontally.
-        self.set_alignment(0.5, 0)
         # The value below is arbitrarily chosen so the text appears
         # centered vertically when the represented track has a single layer.
-        self.set_padding(0, LAYER_SPACING * 2)
-        self.set_markup(self._getTrackName(track))
+        #self.set_padding(0, LAYER_SPACING * 2)
+        self.show_all()
         self._track = None
         self._timeline = None
         self.setTrack(track)
@@ -116,18 +118,7 @@ class BaseLayerControl(gtk.Table, Loggable):
     def _setSize(self, layers_count):
         assert layers_count >= 1
         height = layers_count * (LAYER_HEIGHT_EXPANDED + LAYER_SPACING)
-        self.set_size_request(TRACK_CONTROL_WIDTH, height)
-
-    @staticmethod
-    def _getTrackName(track):
-        track_name = ""
-        if track.props.track_type == ges.TRACK_TYPE_AUDIO:
-            track_name = _("Audio:")
-        elif track.props.track_type == ges.TRACK_TYPE_VIDEO:
-            track_name = _("Video:")
-        elif track.props.track_type == ges.TRACK_TYPE_TEXT:
-            track_name = _("Text:")
-        return "<b>%s</b>" % track_name
+        self.set_size_request(-1, height)
 
 
 class VideoLayerControl(BaseLayerControl):
@@ -135,8 +126,8 @@ class VideoLayerControl(BaseLayerControl):
     Layer control class for video layers
     """
 
-    def __init__(self):
-        BaseLayerControl.__init__(self, "video")
+    def __init__(self, track):
+        BaseLayerControl.__init__(self, track, "video")
 
         opacity = gtk.Label(_("Opacity:"))
 
@@ -148,6 +139,7 @@ class VideoLayerControl(BaseLayerControl):
 
         self.lower_hbox.pack_start(opacity, False, False, 0)
         self.lower_hbox.pack_start(self.opacity_scale, True, True, 0)
+        self.lower_hbox.show_all()
 
 
 class AudioLayerControl(BaseLayerControl):
@@ -172,3 +164,4 @@ class AudioLayerControl(BaseLayerControl):
         self.lower_hbox.pack_start(self.volume_button, False, False, 1)
         self.lower_hbox.pack_start(panning, False, False, 2)
         self.lower_hbox.pack_start(self.panning_scale, True, True, 3)
+        self.lower_hbox.show_all()
diff --git a/pitivi/timeline/timeline.py b/pitivi/timeline/timeline.py
index e2f3075..14cdcff 100644
--- a/pitivi/timeline/timeline.py
+++ b/pitivi/timeline/timeline.py
@@ -43,7 +43,8 @@ from pitivi.utils.pipeline import PipelineError
 from pitivi.settings import GlobalSettings
 
 from curve import KW_LABEL_Y_OVERFLOW
-from track import TrackControls, TRACK_CONTROL_WIDTH, Track, TrackObject
+from track import TRACK_CONTROL_WIDTH, Track, TrackObject
+from layercontrols import VideoLayerControl
 from pitivi.utils.timeline import EditingContext, SELECT, Zoomable
 
 from pitivi.dialogs.depsmanager import DepsManager
@@ -475,7 +476,7 @@ class TimelineControls(gtk.VBox, Loggable):
     def __init__(self):
         gtk.VBox.__init__(self)
         Loggable.__init__(self)
-        self._tracks = []
+        self._tracks_controls = []
         self._timeline = None
         self.set_spacing(LAYER_SPACING)
         self.set_size_request(TRACK_CONTROL_WIDTH, -1)
@@ -488,7 +489,7 @@ class TimelineControls(gtk.VBox, Loggable):
     def setTimeline(self, timeline):
         self.debug("Setting timeline %s", timeline)
 
-        while self._tracks:
+        while self._tracks_controls:
             self._trackRemovedCb(None, 0)
 
         if timeline:
@@ -508,15 +509,15 @@ class TimelineControls(gtk.VBox, Loggable):
     timeline = property(getTimeline, setTimeline, None, "The timeline property")
 
     def _trackAddedCb(self, timeline, track):
-        track_control = TrackControls(track)
-        self._tracks.append(track_control)
+        track_control = VideoLayerControl(track)
+        self._tracks_controls.append(track_control)
         self.pack_start(track_control, False, False)
         track_control.show()
 
     def _trackRemovedCb(self, unused_timeline, position):
-        track = self._tracks[position]
+        track = self._tracks_controls[position]
         track.track = None
-        del self._tracks[position]
+        del self._tracks_controls[position]
         self.remove(track)
 
 
diff --git a/pitivi/timeline/track.py b/pitivi/timeline/track.py
index 30b0a21..8b14610 100644
--- a/pitivi/timeline/track.py
+++ b/pitivi/timeline/track.py
@@ -606,7 +606,7 @@ class TrackObject(View, goocanvas.Group, Zoomable, Loggable):
         self.app.gui.timeline_ui._canvas.regroupTracks()
         self.app.gui.timeline_ui.unsureVadjHeight()
 
-TRACK_CONTROL_WIDTH = 75
+TRACK_CONTROL_WIDTH = 150
 
 
 class TrackTransition(TrackObject):
@@ -664,72 +664,6 @@ class TrackFileSource(TrackObject):
             return self.settings.videoClipBg
 
 
-class TrackControls(gtk.Label, Loggable):
-    """Contains a timeline track name.
-
-    @ivar track: The track for which to display the name.
-    @type track: An L{pitivi.timeline.track.Track} object
-    """
-
-    __gtype_name__ = 'TrackControls'
-
-    def __init__(self, track):
-        gtk.Label.__init__(self)
-        Loggable.__init__(self)
-        # Center the label horizontally.
-        self.set_alignment(0.5, 0)
-        # The value below is arbitrarily chosen so the text appears
-        # centered vertically when the represented track has a single layer.
-        self.set_padding(0, LAYER_SPACING * 2)
-        self.set_markup(self._getTrackName(track))
-        self._track = None
-        self._timeline = None
-        self.setTrack(track)
-        self._setSize(layers_count=1)
-
-    def getTrack(self):
-        return self._track
-
-    def setTrack(self, track):
-        if self._track:
-            self._timeline.disconnect_by_func(self._layerAddedCb)
-            self._timeline.disconnect_by_func(self._layerRemovedCb)
-
-        self._track = track
-        if track:
-            self._timeline = track.get_timeline()
-            self._timeline.connect("layer-added", self._layerAddedCb)
-            self._timeline.connect("layer-removed", self._layerRemovedCb)
-        else:
-            self._timeline = None
-
-    track = property(getTrack, setTrack, None, "The (GESTrack property")
-
-    def _layerAddedCb(self, timeline, unused_layer):
-        max_priority = len(timeline.get_layers())
-        self._setSize(max_priority)
-
-    def _layerRemovedCb(self, timeline, unused_layer):
-        max_priority = len(timeline.get_layers())
-        self._setSize(max_priority)
-
-    def _setSize(self, layers_count):
-        assert layers_count >= 1
-        height = layers_count * (LAYER_HEIGHT_EXPANDED + LAYER_SPACING)
-        self.set_size_request(TRACK_CONTROL_WIDTH, height)
-
-    @staticmethod
-    def _getTrackName(track):
-        track_name = ""
-        if track.props.track_type == ges.TRACK_TYPE_AUDIO:
-            track_name = _("Audio:")
-        elif track.props.track_type == ges.TRACK_TYPE_VIDEO:
-            track_name = _("Video:")
-        elif track.props.track_type == ges.TRACK_TYPE_TEXT:
-            track_name = _("Text:")
-        return "<b>%s</b>" % track_name
-
-
 class Track(goocanvas.Group, Zoomable, Loggable):
     __gtype_name__ = 'Track'
 



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