[pitivi] Remove the expanded property from timeline/track.py and move the functionality to timeline/ui/*
- From: Edward Hervey <edwardrv src gnome org>
- To: svn-commits-list gnome org
- Subject: [pitivi] Remove the expanded property from timeline/track.py and move the functionality to timeline/ui/*
- Date: Wed, 18 Mar 2009 14:09:09 -0400 (EDT)
commit 591edb362755a4bf8ef2804e7fb77cb30c1b51b9
Author: Alessandro Decina <alessandro decina collabora co uk>
Date: Mon Mar 16 17:48:23 2009 +0100
Remove the expanded property from timeline/track.py and move the functionality to timeline/ui/*
---
pitivi/timeline/track.py | 13 -------------
pitivi/ui/timeline.py | 6 ++++++
pitivi/ui/timelinecanvas.py | 9 +++++++++
pitivi/ui/timelinecontrols.py | 39 +++++++++++++++++++++++++++++----------
pitivi/ui/track.py | 17 ++++++++++-------
5 files changed, 54 insertions(+), 30 deletions(-)
diff --git a/pitivi/timeline/track.py b/pitivi/timeline/track.py
index 405164e..f7664b5 100644
--- a/pitivi/timeline/track.py
+++ b/pitivi/timeline/track.py
@@ -302,7 +302,6 @@ class Track(object, Signallable):
'track-object-added': ['track_object'],
'track-object-removed': ['track_object'],
'max-priority-changed': ['track_object']
- 'expanded-changed': [],
}
def __init__(self, stream):
@@ -367,18 +366,6 @@ class Track(object, Signallable):
max_priority = property(_getMaxPriority)
- _expanded = True
-
- def setExpanded(self, expanded):
- if self._expanded != expanded:
- self._expanded = expanded
- self.emit("expanded-changed")
-
- def getExpanded(self):
- return self._expanded
-
- expanded = property(getExpanded, setExpanded)
-
_max_priority = 0
@property
diff --git a/pitivi/ui/timeline.py b/pitivi/ui/timeline.py
index 53d7628..fd391a2 100644
--- a/pitivi/ui/timeline.py
+++ b/pitivi/ui/timeline.py
@@ -118,6 +118,8 @@ class Timeline(gtk.Table, Loggable, Zoomable):
# controls for tracks and layers
self._controls = TimelineControls(self.timeline)
+ self._controls.connect('track-expanded',
+ self._timelineControlsTrackExpandedCb)
controlwindow = gtk.ScrolledWindow(None, self.vadj)
controlwindow.set_policy(gtk.POLICY_NEVER, gtk.POLICY_NEVER)
controlwindow.add_with_viewport(self._controls)
@@ -184,6 +186,10 @@ class Timeline(gtk.Table, Loggable, Zoomable):
self.connect("drag-motion", self._dragMotionCb)
+ def _timelineControlsTrackExpandedCb(self, timeline_controls,
+ track, expanded):
+ self._canvas.setExpanded(track, expanded)
+
## Drag and Drop callbacks
def _dragMotionCb(self, unused, context, x, y, timestamp):
diff --git a/pitivi/ui/timelinecanvas.py b/pitivi/ui/timelinecanvas.py
index bfd7163..f130ad7 100644
--- a/pitivi/ui/timelinecanvas.py
+++ b/pitivi/ui/timelinecanvas.py
@@ -79,6 +79,15 @@ class TimelineCanvas(goocanvas.Canvas, Zoomable):
def from_event(self, event):
return Point(*self.convert_from_pixels(event.x, event.y))
+ def setExpanded(self, track_object, expanded):
+ track_ui = None
+ for track in self._tracks:
+ if track.track == track_object:
+ track_ui = track
+ break
+
+ track_ui.setExpanded(expanded)
+
## sets the cursor as appropriate
def _mouseEnterCb(self, unused_item, unused_target, event):
diff --git a/pitivi/ui/timelinecontrols.py b/pitivi/ui/timelinecontrols.py
index 70a4c37..b4d3ac4 100644
--- a/pitivi/ui/timelinecontrols.py
+++ b/pitivi/ui/timelinecontrols.py
@@ -1,4 +1,5 @@
import gtk
+import gobject
from pitivi.receiver import receiver, handler
import pitivi.stream as stream
from gettext import gettext as _
@@ -26,13 +27,22 @@ class TrackControls(gtk.Expander):
def __init__(self, track):
gtk.Expander.__init__(self, track_name(track))
self.props.use_markup = True
- self.set_expanded(track.expanded)
+ self.set_expanded(True)
self.set_sensitive(False)
self.track = track
self.set_size_request(TRACK_CONTROL_WIDTH, LAYER_HEIGHT_EXPANDED)
+ def set_expanded(self, expanded):
+ if expanded != self.props.expanded:
+ if expanded:
+ self.set_size_request(TRACK_CONTROL_WIDTH, LAYER_HEIGHT_EXPANDED)
+ else:
+ self.set_size_request(TRACK_CONTROL_WIDTH, LAYER_HEIGHT_COLLAPSED)
+
+ gtk.Expander.set_expanded(self, expanded)
+
def do_activate(self):
- self.track.expanded = not self.track.expanded
+ self.props.expanded = not self.props.expanded
track = receiver()
@@ -42,15 +52,11 @@ class TrackControls(gtk.Expander):
self.track.max_priority) * (LAYER_HEIGHT_EXPANDED +
LAYER_SPACING))
- @handler(track, "expanded-changed")
- def _expandedChanged(self, track):
- if self.track.expanded:
- self.set_size_request(TRACK_CONTROL_WIDTH, LAYER_HEIGHT_EXPANDED)
- else:
- self.set_size_request(TRACK_CONTROL_WIDTH, LAYER_HEIGHT_COLLAPSED)
- self.set_expanded(self.track.expanded)
-
class TimelineControls(gtk.VBox):
+ __gsignals__ = {
+ "track-expanded" : (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE,
+ (gobject.TYPE_PYOBJECT, gobject.TYPE_BOOLEAN))
+ }
def __init__(self, timeline):
gtk.VBox.__init__(self)
@@ -72,11 +78,24 @@ class TimelineControls(gtk.VBox):
@handler(timeline, "track-added")
def _trackAdded(self, timeline, track):
track = TrackControls(track)
+ self._connectToTrackControls(track)
self._tracks.append(track)
self.pack_start(track, False, False)
@handler(timeline, "track-removed")
def _trackRemoved(self, unused_timeline, position):
track = self._tracks[position]
+ self._disconnectFromTrackControls(track)
del self._tracks[position]
self.remove(track)
+
+ def _connectToTrackControls(self, track_controls):
+ track_controls.connect("notify::expanded",
+ self._trackControlsExpandedCb)
+
+ def _disconnectFromTrackControls(self, track_controls):
+ track_controls.disconnect_by_func(self._trackControlsExpandedCb)
+
+ def _trackControlsExpandedCb(self, track_controls, pspec):
+ self.emit('track-expanded', track_controls.track,
+ track_controls.props.expanded)
diff --git a/pitivi/ui/track.py b/pitivi/ui/track.py
index b269483..4f2c8e5 100644
--- a/pitivi/ui/track.py
+++ b/pitivi/ui/track.py
@@ -14,11 +14,20 @@ class Track(goocanvas.Group, Zoomable):
self.track = track
self.timeline = timeline
self.max_priority = 0
+ self._expanded = True
## Properties
+ def setExpanded(self, expanded):
+ if expanded != self._expanded:
+ self._expanded = expanded
+
+ for widget in self.widgets.itervalues():
+ widget.expanded = expanded
+ self.get_canvas().regroupTracks()
+
def getHeight(self):
- if self.track.expanded:
+ if self._expanded:
return (1 + self.track.max_priority) * (LAYER_HEIGHT_EXPANDED + LAYER_SPACING)
else:
return LAYER_HEIGHT_COLLAPSED + LAYER_SPACING
@@ -44,12 +53,6 @@ class Track(goocanvas.Group, Zoomable):
del self.widgets[track_object]
Zoomable.removeInstance(w)
- @handler(track, "expanded-changed")
- def _expandedChanged(self, track):
- for widget in self.widgets.itervalues():
- widget.expanded = track.expanded
- self.get_canvas().regroupTracks()
-
@handler(track, "max-priority-changed")
def _maxPriorityChanged(self, track):
self.get_canvas().regroupTracks()
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]