pitivi r1127 - in branches/SOC_2008_BLEWIS: . pitivi/ui
- From: blewis svn gnome org
- To: svn-commits-list gnome org
- Subject: pitivi r1127 - in branches/SOC_2008_BLEWIS: . pitivi/ui
- Date: Sun, 1 Jun 2008 22:25:25 +0000 (UTC)
Author: blewis
Date: Sun Jun 1 22:25:25 2008
New Revision: 1127
URL: http://svn.gnome.org/viewvc/pitivi?rev=1127&view=rev
Log:
reviewed by: <delete if not using a buddy>
* pitivi/ui/timelineobjects.py:
merged new code into exiting SimpleTimeline class. PiTiVi doesn't crash when
you run it, but most of the functionality is disabled.
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 Sun Jun 1 22:25:25 2008
@@ -29,18 +29,18 @@
import gtk
import gst
import pango
-#import pitivi.instance as instance
-#from pitivi.timeline.source import TimelineFileSource, TimelineSource, TimelineBlankSource
-#from pitivi.timeline.effects import TimelineTransition
-#from pitivi.timeline.objects import MEDIA_TYPE_AUDIO, MEDIA_TYPE_VIDEO
-#from pitivi.configure import get_pixmap_dir
-#import pitivi.dnd as dnd
-#from pitivi.bin import SmartFileBin
-#from pitivi.signalgroup import SignalGroup
-#from pitivi.thumbnailer import Thumbnailer
-#from pitivi.ui.slider import PipelineSlider
-#from sourcefactories import beautify_length
-#from gettext import gettext as _
+import pitivi.instance as instance
+from pitivi.timeline.source import TimelineFileSource, TimelineSource, TimelineBlankSource
+from pitivi.timeline.effects import TimelineTransition
+from pitivi.timeline.objects import MEDIA_TYPE_AUDIO, MEDIA_TYPE_VIDEO
+from pitivi.configure import get_pixmap_dir
+import pitivi.dnd as dnd
+from pitivi.bin import SmartFileBin
+from pitivi.signalgroup import SignalGroup
+from pitivi.thumbnailer import Thumbnailer
+from pitivi.ui.slider import PipelineSlider
+from sourcefactories import beautify_length
+from gettext import gettext as _
import goocanvas
from util import *
@@ -75,7 +75,7 @@
class SimpleTimeline(goocanvas.Canvas):
__gtype_name__ = 'SimpleTimeline'
- def __init__(self, *args, **kwargs):
+ def __init__(self, hadjustment=None, vadjustment=None, *args, **kwargs):
goocanvas.Canvas.__init__(self, *args, **kwargs)
self.props.automatic_bounds = False
@@ -95,6 +95,58 @@
self.scale = 1.0
+ # 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
+ self.editingWidget = SimpleEditingWidget()
+ 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()
+ # 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)
+# instance.PiTiVi.connect("new-project-loading",
+# self._newProjectLoadingCb)
+# instance.PiTiVi.connect("new-project-failed",
+# self._newProjectFailedCb)
+#
+# # size
+# self.width = int(DEFAULT_WIDTH)
+# self.height = int(DEFAULT_HEIGHT)
+# self.realWidth = 0 # displayed width of the layout
+# self.childheight = int(DEFAULT_SIMPLE_ELEMENT_HEIGHT)
+# self.childwidth = int(DEFAULT_SIMPLE_ELEMENT_WIDTH)
+# self.set_size_request(int(MINIMUM_WIDTH), int(MINIMUM_HEIGHT))
+# self.set_property("width", int(DEFAULT_WIDTH))
+# self.set_property("height", int(DEFAULT_HEIGHT))
+#
+# # drag and drop
+# self.drag_dest_set(gtk.DEST_DEFAULT_DROP | gtk.DEST_DEFAULT_MOTION,
+# [dnd.FILESOURCE_TUPLE],
+# gtk.gdk.ACTION_COPY)
+# self.connect("drag-data-received", self._dragDataReceivedCb)
+# self.connect("drag-leave", self._dragLeaveCb)
+# self.connect("drag-motion", self._dragMotionCb)
+# self.slotposition = -1
+#
+# self.draggedelement = None
+#
+
def _request_size(self, item, prop):
self.set_size_request(int(self.items.width), int(
self.items.height))
@@ -186,112 +238,45 @@
self.items.remove(child)
unmake_dragable(self, child)
-#class SimpleTimeline(gtk.Layout):
-# """ Simple Timeline representation """
-#
-# def __init__(self, **kw):
-# gobject.GObject.__init__(self, **kw)
-#
-# self.hadjustment = self.get_property("hadjustment")
-#
-# # timeline and top level compositions
-# self.timeline = instance.PiTiVi.current.timeline
-# self.condensed = self.timeline.videocomp.condensed
-#
-# # TODO : connect signals for when the timeline changes
-#
-# # widgets correspondance dictionnary
-# # MAPPING timelineobject => widget
-# self.widgets = {}
-#
-# # edit-mode
-# # True when in editing mode
-# self._editingMode = False
-# self.editingWidget = SimpleEditingWidget()
-# self.editingWidget.connect("hide-me", self._editingWidgetHideMeCb)
-#
-# # Connect to timeline. We must remove and reset the callbacks when
-# # changing project.
-# self.project_signals = SignalGroup()
-# # 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)
-# instance.PiTiVi.connect("new-project-loading",
-# self._newProjectLoadingCb)
-# instance.PiTiVi.connect("new-project-failed",
-# self._newProjectFailedCb)
-#
-# # size
-# self.width = int(DEFAULT_WIDTH)
-# self.height = int(DEFAULT_HEIGHT)
-# self.realWidth = 0 # displayed width of the layout
-# self.childheight = int(DEFAULT_SIMPLE_ELEMENT_HEIGHT)
-# self.childwidth = int(DEFAULT_SIMPLE_ELEMENT_WIDTH)
-# self.set_size_request(int(MINIMUM_WIDTH), int(MINIMUM_HEIGHT))
-# self.set_property("width", int(DEFAULT_WIDTH))
-# self.set_property("height", int(DEFAULT_HEIGHT))
-#
-# # event callbacks
-# self.connect("expose-event", self._exposeEventCb)
-# self.connect("notify::width", self._widthChangedCb)
-# self.connect("size-allocate", self._sizeAllocateCb)
-# self.connect("realize", self._realizeCb)
-#
-# # drag and drop
-# self.drag_dest_set(gtk.DEST_DEFAULT_DROP | gtk.DEST_DEFAULT_MOTION,
-# [dnd.FILESOURCE_TUPLE],
-# gtk.gdk.ACTION_COPY)
-# self.connect("drag-data-received", self._dragDataReceivedCb)
-# self.connect("drag-leave", self._dragLeaveCb)
-# self.connect("drag-motion", self._dragMotionCb)
-# self.slotposition = -1
-#
-# self.draggedelement = None
-#
-# self.show_all()
-#
-#
-# ## 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("...")
-#
-# def _newProjectLoadedCb(self, unused_inst, project):
-# gst.log("...")
-# assert(instance.PiTiVi.current == project)
-# # now we connect to the new project, so we can receive any
-# # signals that might be emitted while the project is loading
-# self._connectToTimeline(project.timeline)
-# # TODO: display final state of project now that loading has
-# # completed. this callback doesn't do do much else
-#
-# # LOAD THE TIMELINE !!!
-# self._condensedListChangedCb(None, self.timeline.videocomp.condensed)
-#
-# def _newProjectFailedCb(self, unused_inst, unused_reason, unused_uri):
-# # oops the project failed to load
-# self._clearTimeline()
-#
-# def _clearTimeline(self):
-# self.switchToNormalMode()
-# self.project_signals.disconnectAll()
-# for widget in self.widgets.itervalues():
-# self.remove(widget)
-# self.widgets = {}
-#
-# def _projectClosedCb(self, unused_pitivi, unused_project):
-# self._clearTimeline()
-#
+
+ ## 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("...")
+
+ def _newProjectLoadedCb(self, unused_inst, project):
+ gst.log("...")
+ assert(instance.PiTiVi.current == project)
+ # now we connect to the new project, so we can receive any
+ # signals that might be emitted while the project is loading
+ self._connectToTimeline(project.timeline)
+ # TODO: display final state of project now that loading has
+ # completed. this callback doesn't do do much else
+
+ # LOAD THE TIMELINE !!!
+ self._condensedListChangedCb(None, self.timeline.videocomp.condensed)
+
+ def _newProjectFailedCb(self, unused_inst, unused_reason, unused_uri):
+ # oops the project failed to load
+ self._clearTimeline()
+
+ def _clearTimeline(self):
+ self.switchToNormalMode()
+ self.project_signals.disconnectAll()
+ for widget in self.widgets.itervalues():
+ self.remove(widget)
+ self.widgets = {}
+
+ def _projectClosedCb(self, unused_pitivi, unused_project):
+ self._clearTimeline()
+
# ## Timeline callbacks
#
# def _condensedListChangedCb(self, unused_videocomp, clist):
@@ -442,16 +427,7 @@
# pos = self._getNearestSourceSlot(x)
#
# self.timeline.videocomp.moveSource(element, pos)
-#
-# def _widthChangedCb(self, unused_layout, property):
-# if not property.name == "width":
-# return
-# self.width = self.get_property("width")
-#
-# def _motionNotifyEventCb(self, layout, event):
-# pass
-#
-#
+
# ## Drag and Drop callbacks
#
# def _dragMotionCb(self, unused_layout, unused_context, x, unused_y,
@@ -530,114 +506,65 @@
# self.editingWidget.set_size_request(self.realWidth - 20,
# self.height - 20)
#
-# def _resizeChildrens(self):
-# # resize the childrens to self.height
-# # also need to move them to their correct position
-# # TODO : check if there already at the given position
-# # TODO : check if they already have the good size
-# if self._editingMode:
-# return
-# pos = 2 * DEFAULT_SIMPLE_SPACING
-# for source in self.condensed:
-# widget = self.widgets[source]
-# if isinstance(source, TimelineFileSource):
-# widget.set_size_request(self.childwidth, self.childheight)
-# self.move(widget, pos, DEFAULT_SIMPLE_SPACING)
-# pos = pos + self.childwidth + DEFAULT_SIMPLE_SPACING
-# elif isinstance(source, SimpleTransitionWidget):
-# widget.set_size_request(self.childheight / 2, self.childheight)
-# self.move(widget, pos, DEFAULT_SIMPLE_SPACING)
-# pos = pos + self.childwidth + DEFAULT_SIMPLE_SPACING
-# newwidth = pos + DEFAULT_SIMPLE_SPACING
-# self.set_property("width", newwidth)
-#
+
# ## 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)
-#
-# def _sourceDragBeginCb(self, unused_widget, unused_context, element):
-# gst.log("Timeline drag beginning on %s" % element)
-# if self.draggedelement:
-# gst.error("We were already doing a DnD ???")
-# self.draggedelement = element
-# # this element is starting to be dragged
-#
-# def _sourceDragEndCb(self, unused_widget, unused_context, element):
-# gst.log("Timeline drag ending on %s" % element)
-# if not self.draggedelement == element:
-# gst.error("The DnD that ended is not the one that started before ???")
-# self.draggedelement = None
-# # this element is no longer dragged
-#
-# 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))
-#
-# if self._editingMode == mode:
-# gst.warning("We were already in the correct editing mode : %s" % mode)
-# return
-#
-# if mode and not source:
-# gst.warning("You need to specify a valid TimelineSource")
-# return
-#
-# if mode:
-# # switching TO editing mode
-# gst.log("Switching TO editing mode")
-#
-# # 1. Hide all sources
-# for widget in self.widgets.itervalues():
-# widget.hide()
-# self.remove(widget)
-#
-# self._editingMode = mode
-#
-# # 2. Show editing widget
-# self.editingWidget.setSource(source)
-# self.put(self.editingWidget, 10, 10)
-# self.props.width = self.realWidth
-# self.editingWidget.set_size_request(self.realWidth - 20, self.height - 20)
-# self.editingWidget.show()
-#
-# else:
-# gst.log("Switching back to normal mode")
-# # switching FROM editing mode
-#
-# # 1. Hide editing widget
-# self.editingWidget.hide()
-# self.remove(self.editingWidget)
-#
-# self._editingMode = mode
-#
-# # 2. Show all sources
-# for widget in self.widgets.itervalues():
-# self.put(widget, 0, 0)
-# widget.show()
-# self._resizeChildrens()
-#
-# def switchToEditingMode(self, source):
-# """ Switch to Editing mode for the given TimelineSource """
-# self._switchEditingMode(source)
-#
-# def switchToNormalMode(self):
-# """ Switch back to normal timeline mode """
-# self._switchEditingMode(None, False)
-#
-#
+ def _sourceEditMeCb(self, unused_widget, element):
+ self.switchToEditingMode(element)
+
+ 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))
+
+ if self._editingMode == mode:
+ gst.warning("We were already in the correct editing mode : %s" % mode)
+ return
+
+ if mode and not source:
+ gst.warning("You need to specify a valid TimelineSource")
+ return
+
+ if mode:
+ # switching TO editing mode
+ gst.log("Switching TO editing mode")
+
+ # 1. Hide all sources
+ self.items.remove()
+ self._editingMode = mode
+
+ # 2. Show editing widget
+ self.editingWidget.setSource(source)
+ self.add_child(self.editingCanvasItem)
+ else:
+ gst.log("Switching back to normal mode")
+ # switching FROM editing mode
+
+ # 1. Hide editing widget
+ self.editingCanvasItem.remove()
+ self._editingMode = mode
+
+ # 2. Show all sources
+ self.root.add_child(self.items)
+
+ def switchToEditingMode(self, source):
+ """ Switch to Editing mode for the given TimelineSource """
+ self._switchEditingMode(source)
+
+ def switchToNormalMode(self):
+ """ Switch back to normal timeline mode """
+ self._switchEditingMode(None, False)
+
+
class SimpleEditingWidget(gtk.EventBox):
"""
Widget for editing a source in the SimpleTimeline
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]