pitivi r1133 - in branches/SOC_2008_BLEWIS: . pitivi/ui
- From: blewis svn gnome org
- To: svn-commits-list gnome org
- Subject: pitivi r1133 - in branches/SOC_2008_BLEWIS: . pitivi/ui
- Date: Tue, 3 Jun 2008 00:58:40 +0000 (UTC)
Author: blewis
Date: Tue Jun 3 00:58:40 2008
New Revision: 1133
URL: http://svn.gnome.org/viewvc/pitivi?rev=1133&view=rev
Log:
* pitivi/ui/timelineobjects.py:
factored out all the timeline signal handlers from
SimpleTimelineWidget into a new subclass of HList()
Modified:
branches/SOC_2008_BLEWIS/ChangeLog
branches/SOC_2008_BLEWIS/pitivi/ui/timelineobjects.py
Modified: branches/SOC_2008_BLEWIS/pitivi/ui/timelineobjects.py
==============================================================================
--- branches/SOC_2008_BLEWIS/pitivi/ui/timelineobjects.py (original)
+++ branches/SOC_2008_BLEWIS/pitivi/ui/timelineobjects.py Tue Jun 3 00:58:40 2008
@@ -72,6 +72,71 @@
hours = mins / 60
return "%02d:%02d:%02d.%03d" % (hours, mins, sec, ms)
+class TimelineList(HList):
+
+ def __init__(self, timeline, *args, **kwargs):
+ HList.__init__(self, *args, **kwargs)
+ self.sig_id = None
+ self.set_timeline(timeline)
+ self.reorderable = True
+ self.widgets = {}
+
+ def set_timeline(self, timeline):
+ if self.sig_id:
+ self.timeline.videocomp.disconnect(self.sig_id)
+ self.timeline = timeline
+ if timeline:
+ self.condensed = self.timeline.videocomp.condensed
+ self.sig_id = self.timeline.videocomp.connect(
+ "condensed-list-changed", self._condensedListChangedCb)
+
+ def _condensedListChangedCb(self, unused_videocomp, clist):
+ """ add/remove the widgets """
+ gst.debug("condensed list changed in videocomp")
+ current = self.condensed
+ self.condensed = clist
+ new = [x for x in clist if not x in current]
+ removed = [x for x in current if not x in clist]
+
+ # new elements
+ for element in new:
+ # add the widget to self.widget
+ gst.debug("Adding new element to the layout")
+ if isinstance(element, TimelineFileSource):
+ widget = SimpleSourceWidget(element)
+ widget.connect("delete-me", self._sourceDeleteMeCb, element)
+ widget.connect("edit-me", self._sourceEditMeCb, element)
+ item = goocanvas.Widget(widget=widget,
+ width=DEFAULT_SIMPLE_ELEMENT_WIDTH,
+ height=DEFAULT_SIMPLE_ELEMENT_HEIGHT)
+ background = goocanvas.Rect(fill_color="gray",
+ stroke_color="gray",
+ width=DEFAULT_SIMPLE_ELEMENT_WIDTH,
+ height=DEFAULT_SIMPLE_ELEMENT_HEIGHT)
+ item = group(background, item)
+ else:
+ gst.warning("this is not implemented")
+ self.widgets[element] = item
+ self.add_child(self.widgets[element])
+
+ # removed elements
+ for element in removed:
+ self.remove_child(self.widgets[element])
+ del self.widgets[element]
+
+ order = [self.index(self.widgets[e]) for e in clist]
+ print order
+
+## Child callbacks
+
+ def _sourceDeleteMeCb(self, unused_widget, element):
+ # remove this element from the timeline
+ self.timeline.videocomp.removeSource(element,
+ collapse_neighbours=True)
+#
+ def _sourceEditMeCb(self, unused_widget, element):
+ self.switchToEditingMode(element)
+
class SimpleTimeline(goocanvas.Canvas):
__gtype_name__ = 'SimpleTimeline'
@@ -79,9 +144,11 @@
goocanvas.Canvas.__init__(self, *args, **kwargs)
self.props.automatic_bounds = False
+ # timeline and top level compositions
+ self.timeline = instance.PiTiVi.current.timeline
+
self.root = self.get_root_item()
- self.items = HList(self, spacing=10)
- self.items.reorderable = True
+ self.items = TimelineList(self.timeline, self, spacing=10)
self.root.add_child(self.items)
self.left = None
@@ -97,15 +164,6 @@
self.scale = 1.0
self.set_size_request(int(MINIMUM_WIDTH), int(MINIMUM_HEIGHT))
- # timeline and top level compositions
- self.timeline = instance.PiTiVi.current.timeline
- self.condensed = self.timeline.videocomp.condensed
-
-
- # widgets correspondance dictionnary
- # MAPPING timelineobject => widget
- self.widgets = {}
-
# edit-mode
# True when in editing mode
self._editingMode = False
@@ -113,15 +171,6 @@
self.editingCanvasItem = goocanvas.Widget(widget=self.editingWidget)
self.editingWidget.connect("hide-me", self._editingWidgetHideMeCb)
- # Connect to timeline. We must remove and reset the callbacks when
- # changing project.
-
- self.project_signals = SignalGroup()
- self._connectToTimeline(self.timeline)
-
- # FIXME: do we need this? or will the newproject sginal implicitly
- # handle this???
- self._connectToTimeline(instance.PiTiVi.current.timeline)
instance.PiTiVi.connect("new-project-loaded",
self._newProjectLoadedCb)
instance.PiTiVi.connect("project-closed", self._projectClosedCb)
@@ -155,13 +204,6 @@
## Project callbacks
- def _connectToTimeline(self, timeline):
- self.timeline = timeline
- self.condensed = self.timeline.videocomp.condensed
- self.project_signals.connect(self.timeline.videocomp,
- "condensed-list-changed",
- None, self._condensedListChangedCb)
-
def _newProjectLoadingCb(self, unused_inst, unused_project):
gst.log("...")
@@ -180,48 +222,13 @@
def _clearTimeline(self):
self.switchToNormalMode()
- self.project_signals.disconnectAll()
+ self.items.set_timeline(None)
self.items.remove_all()
def _projectClosedCb(self, unused_pitivi, unused_project):
self._clearTimeline()
- ## Timeline callbacks
-
- def _condensedListChangedCb(self, unused_videocomp, clist):
- """ add/remove the widgets """
- gst.debug("condensed list changed in videocomp")
- current = self.condensed
- self.condensed = clist
-
- new = [x for x in clist if not x in current]
- removed = [x for x in current if not x in clist]
-
- # new elements
- for element in new:
- # add the widget to self.widget
- gst.debug("Adding new element to the layout")
- if isinstance(element, TimelineFileSource):
- widget = SimpleSourceWidget(element)
- widget.connect("delete-me", self._sourceDeleteMeCb, element)
- widget.connect("edit-me", self._sourceEditMeCb, element)
- item = goocanvas.Widget(widget=widget,
- width=DEFAULT_SIMPLE_ELEMENT_WIDTH,
- height=DEFAULT_SIMPLE_ELEMENT_HEIGHT)
- background = goocanvas.Rect(fill_color="gray",
- stroke_color="gray",
- width=DEFAULT_SIMPLE_ELEMENT_WIDTH,
- height=DEFAULT_SIMPLE_ELEMENT_HEIGHT)
- item = group(background, item)
- else:
- gst.warning("this is not implemented")
- self.widgets[element] = item
- self.items.add_child(self.widgets[element])
-
- # removed elements
- for element in removed:
- self.items.remove_child(self.widgets[element])
- del self.widgets[element]
+## Timeline callbacks
def _gotFileFactory(self, filefactory, x, y):
""" got a filefactory at the given position """
@@ -234,14 +241,13 @@
# we just add it here, the drawing will be done in the condensed_list
# callback
source = TimelineFileSource(factory=filefactory,
- media_type=MEDIA_TYPE_VIDEO,
- name=filefactory.name)
+ media_type=MEDIA_TYPE_VIDEO,
+ name=filefactory.name)
# ONLY FOR SIMPLE TIMELINE : if video-only, we link a blank audio object
if not filefactory.is_audio:
audiobrother = TimelineBlankSource(factory=filefactory,
- media_type=MEDIA_TYPE_AUDIO,
- name=filefactory.name)
+ media_type=MEDIA_TYPE_AUDIO, name=filefactory.name)
source.setBrother(audiobrother)
if pos_ == -1:
@@ -272,34 +278,13 @@
context.finish(True, False, timestamp)
instance.PiTiVi.playground.switchToTimeline()
- def _areaIntersect(self, x, y, w, h, x2, y2, w2, h2):
- """ returns True if the area intersects, else False """
- # is zone to the left of zone2
- z1 = gtk.gdk.Rectangle(x, y, w, h)
- z2 = gtk.gdk.Rectangle(x2, y2, w2, h2)
- r = z1.intersect(z2)
- a, b, c, d = r
- if a or b or c or d:
- return True
- return False
-
-## Child callbacks
-
- def _sourceDeleteMeCb(self, unused_widget, element):
- # remove this element from the timeline
- self.timeline.videocomp.removeSource(element,
- collapse_neighbours=True)
-#
- def _sourceEditMeCb(self, unused_widget, element):
- self.switchToEditingMode(element)
+## Editing mode
def _editingWidgetHideMeCb(self, unused_widget):
self.switchToNormalMode()
# switch back to timeline in playground !
instance.PiTiVi.playground.switchToTimeline()
-## Editing mode
-
def _switchEditingMode(self, source, mode=True):
""" Switch editing mode for the given TimelineSource """
gst.log("source:%s , mode:%s" % (source, mode))
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]