Commit cbdb5f78 authored by Edward Hervey's avatar Edward Hervey

* pitivi/Makefile.am:

* pitivi/instance.py:
* pitivi/check.py:
Added global application instance (instance.PiTiVi) to avoid having to
do some crack like passing pitivi's self down all the objects for the
one single object that needs it.
* pitivi/effects.py:
* pitivi/pitivi.py:
Files fixed to use instance.PiTiVi
* pitivi/timeline.py:
wrong comment
* pitivi/ui/complextimeline.py:
Connect to composition duration update to inform ruler.
* pitivi/ui/layerwidgets.py:
cleanup
* pitivi/ui/mainwindow.py:
* pitivi/ui/timeline.py:
* pitivi/ui/timelineobjects.py:
* pitivi/ui/plumber.py:
* pitivi/ui/viewer.py:
switch to instance.PiTiVi
* pitivi/ui/sourcefactories.py:
First try at showing audio/video FX in the UI
* pitivi/ui/tracklayer.py:
First go at complex timeline source drag/drop


git-svn-id: svn+ssh://svn.gnome.org/svn/pitivi/trunk@698 d3729300-e425-0410-8a4c-d956edccc248
parent 1bf81bcd
2006-02-27 Edward Hervey <edward@fluendo.com>
* pitivi/Makefile.am:
* pitivi/instance.py:
* pitivi/check.py:
Added global application instance (instance.PiTiVi) to avoid having to
do some crack like passing pitivi's self down all the objects for the
one single object that needs it.
* pitivi/effects.py:
* pitivi/pitivi.py:
Files fixed to use instance.PiTiVi
* pitivi/timeline.py:
wrong comment
* pitivi/ui/complextimeline.py:
Connect to composition duration update to inform ruler.
* pitivi/ui/layerwidgets.py:
cleanup
* pitivi/ui/mainwindow.py:
* pitivi/ui/timeline.py:
* pitivi/ui/timelineobjects.py:
* pitivi/ui/plumber.py:
* pitivi/ui/viewer.py:
switch to instance.PiTiVi
* pitivi/ui/sourcefactories.py:
First try at showing audio/video FX in the UI
* pitivi/ui/tracklayer.py:
First go at complex timeline source drag/drop
2006-02-22 Edward Hervey <edward@fluendo.com>
* pitivi/bin.py:
......
......@@ -7,6 +7,7 @@ pitividir = $(libdir)/pitivi/python/pitivi
pitivi_PYTHON = \
__init__.py \
configure.py \
instance.py \
bin.py \
check.py \
discoverer.py \
......
......@@ -22,6 +22,7 @@
import gtk
import gst
import sys
import instance
def initial_checks():
"""
......@@ -43,6 +44,9 @@ def initial_checks():
def _checks():
reg = gst.registry_get_default()
if instance.PiTiVi:
return ("PiTiVi is already running",
"An instance of PiTiVi is already running in this script")
if not reg.find_plugin("gnonlin"):
return ("Could not find the GNonLin plugins!",
"Make sure the plugins were installed and are available in the GStreamer plugins path")
......
......@@ -38,9 +38,8 @@ class Magician:
Handles all the effects
"""
def __init__(self, pitivi):
def __init__(self):
gst.log("New Magician")
self.pitivi = pitivi
self.simple_video = []
self.simple_audio = []
self.transitions = []
......
# PiTiVi , Non-linear video editor
#
# pitivi/instance.py
#
# Copyright (c) 2005, Edward Hervey <bilboed@bilboed.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this program; if not, write to the
# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
# Boston, MA 02111-1307, USA.
"""
PiTiVi is the current instance of pitivi top-level class
"""
PiTiVi = None
......@@ -29,6 +29,7 @@ from discoverer import Discoverer
from playground import PlayGround
from project import Project, file_is_project
from effects import Magician
import instance
class Pitivi(gobject.GObject):
"""
......@@ -61,14 +62,18 @@ class Pitivi(gobject.GObject):
"""
gst.log("starting up pitivi...")
gobject.GObject.__init__(self)
# store ourself in the instance global
instance.PiTiVi = self
# TODO parse cmd line arguments
self.playground = PlayGround()
self.current = Project("New Project")
self.effects = Magician(self)
self.effects = Magician()
# we're starting a GUI for the time being
self.gui = mainwindow.PitiviMainWindow(self)
self.gui = mainwindow.PitiviMainWindow()
self.gui.show()
def load_project(self, uri=None, filepath=None):
......
......@@ -454,7 +454,6 @@ class TimelineComposition(TimelineSource):
def _make_gnl_object(self):
self.gnlobject = gst.element_factory_make("gnlcomposition", "composition-" + self.name)
# connect to start/duration notify time
# global effects
......
......@@ -22,6 +22,8 @@
import gtk
import gst
import pitivi.instance as instance
from complexlayer import LayerInfoList
from layerwidgets import TopLayer, CompositionLayer
from complexinterface import ZoomableWidgetInterface
......@@ -53,7 +55,6 @@ class CompositionLayers(gtk.VBox, ZoomableWidgetInterface):
## ZoomableWidgetInterface overrides
def get_duration(self):
gst.debug("CompositionLayers get_duration")
return max([layer.get_duration() for layer in self.layers])
def get_start_time(self):
......@@ -111,12 +112,14 @@ class ComplexTimelineWidget(gtk.VBox, ZoomableWidgetInterface):
gst.log("Creating ComplexTimelineWidget")
gtk.VBox.__init__(self)
self.pitivi = topwidget.pitivi
self.hadj = topwidget.hadjustment
self.vadj = topwidget.vadjustment
# common LayerInfoList
self.layerInfoList = LayerInfoList(self.pitivi.current.timeline)
self.layerInfoList = LayerInfoList(instance.PiTiVi.current.timeline)
for layer in self.layerInfoList:
layer.composition.connect('start-duration-changed',
self._layerStartDurationChangedCb)
self._createUI()
......@@ -143,6 +146,10 @@ class ComplexTimelineWidget(gtk.VBox, ZoomableWidgetInterface):
self.scrolledWindow.add_with_viewport(self.compositionLayers)
self.pack_start(self.scrolledWindow, expand=True)
def _layerStartDurationChangedCb(self, composition, start, duration):
# Force resize of ruler
self.topLayer.start_duration_changed()
## ZoomableWidgetInterface overrides
## * we send everything to self.compositionLayers
......
......@@ -30,8 +30,7 @@ class TopLeftTimelineWidget(gtk.Label):
# TODO : We should replace this by a minimalist toolbar maybe...
def __init__(self):
gtk.Label.__init__(self, "pouet")
self.modify_bg(gtk.STATE_NORMAL, gtk.gdk.Color(1,0,0))
gtk.Label.__init__(self, "Tracks")
class TimelineLayer(gtk.HBox):
......@@ -88,6 +87,9 @@ class TopLayer(TimelineLayer, ZoomableWidgetInterface):
def timelinePositionChanged(self, value, frame):
self.rightWidget.timelinePositionChanged(value, frame)
def start_duration_changed(self):
self.rightWidget.start_duration_changed()
class CompositionLayer(TimelineLayer, ZoomableWidgetInterface):
def __init__(self, leftSizeGroup, hadj, layerInfo):
......
......@@ -24,6 +24,8 @@ import gobject
import gtk
import gst
import pitivi.instance as instance
from timeline import TimelineWidget
from sourcefactories import SourceFactoriesWidget
from viewer import PitiviViewer
......@@ -35,16 +37,17 @@ class PitiviMainWindow(gtk.Window):
Pitivi's main window
"""
def __init__(self, pitivi):
def __init__(self):
""" initialize with the Pitivi object """
gst.log("Creating MainWindow")
self.pitivi = pitivi
gtk.Window.__init__(self)
self._set_actions()
self._create_gui()
self.pitivi.connect("new-project", self._new_project_cb)
self.pitivi.connect("closing-project", self._closing_project_cb)
self.pitivi.connect("not-project", self._not_project_cb)
instance.PiTiVi.connect("new-project", self._new_project_cb)
instance.PiTiVi.connect("closing-project", self._closing_project_cb)
instance.PiTiVi.connect("not-project", self._not_project_cb)
self.show_all()
def destroy(self, widget, data=None):
......@@ -94,7 +97,7 @@ class PitiviMainWindow(gtk.Window):
vpaned = gtk.VPaned()
vbox.pack_start(vpaned)
self.timeline = TimelineWidget(self.pitivi)
self.timeline = TimelineWidget()
timelineframe = gtk.Frame()
timelineframe.add(self.timeline)
vpaned.pack2(timelineframe, resize=False, shrink=False)
......@@ -103,10 +106,10 @@ class PitiviMainWindow(gtk.Window):
vpaned.pack1(hpaned, resize=True, shrink=False)
# source-and-effects list
self.sourcefactories = SourceFactoriesWidget(self.pitivi)
self.sourcefactories = SourceFactoriesWidget()
# Viewer
self.viewer = PitiviViewer(self.pitivi)
self.viewer = PitiviViewer()
viewerframe = gtk.Frame()
viewerframe.add(self.viewer)
......@@ -118,7 +121,7 @@ class PitiviMainWindow(gtk.Window):
def new_project_cb(self, action):
print "new project"
self.pitivi.new_blank_project()
instance.PiTiVi.new_blank_project()
def open_project_cb(self, action):
print "open project"
......@@ -131,7 +134,7 @@ class PitiviMainWindow(gtk.Window):
def project_settings_cb(self, action):
print "project settings"
l = ProjectSettingsDialog(self, self.pitivi.current)
l = ProjectSettingsDialog(self, instance.PiTiVi.current)
l.show()
def quit_cb(self, action):
......
......@@ -31,7 +31,7 @@ import gobject
import gst
import gst.interfaces
def get_video_sink(pitivi):
def get_video_sink():
""" Returns a video sink bin that can be used in the Discoverer """
try:
gconfsink = gst.element_factory_make("gconfvideosink")
......@@ -59,7 +59,7 @@ def get_video_sink(pitivi):
gconfsink.realsink.set_property("force-aspect-ratio", True)
return gconfsink
def get_audio_sink(pitivi):
def get_audio_sink():
""" Returns an audio sink bin that can be used in the Discoverer """
try:
gconfsink = gst.element_factory_make("gconfaudiosink")
......
......@@ -26,7 +26,10 @@ import string
import gobject
import gtk
import gst
import pango
from urllib import unquote
import pitivi.instance as instance
import pitivi.dnd as dnd
from pitivi.configure import get_pixmap_dir
......@@ -41,24 +44,23 @@ class SourceFactoriesWidget(gtk.Notebook):
Widget for the various source factories (files, effects, live,...)
"""
def __init__(self, pitivi):
def __init__(self):
""" initialize """
gtk.Notebook.__init__(self)
self.pitivi = pitivi
self._create_gui()
def _create_gui(self):
""" set up the gui """
self.set_tab_pos(gtk.POS_BOTTOM)
self.sourcelist = SourceListWidget(self.pitivi)
self.sourcelist = SourceListWidget()
self.append_page(self.sourcelist, gtk.Label("Sources"))
self.audiofxlist = AudioFxListWidget(self.pitivi)
self.audiofxlist.set_sensitive(False)
self.audiofxlist = AudioFxListWidget()
#self.audiofxlist.set_sensitive(False)
self.append_page(self.audiofxlist, gtk.Label("Audio FX"))
self.videofxlist = VideoFxListWidget(self.pitivi)
self.videofxlist.set_sensitive(False)
self.videofxlist = VideoFxListWidget()
#self.videofxlist.set_sensitive(False)
self.append_page(self.videofxlist, gtk.Label("Video FX"))
self.transitionlist = TransitionListWidget(self.pitivi)
self.transitionlist = TransitionListWidget()
self.transitionlist.set_sensitive(False)
self.append_page(self.transitionlist, gtk.Label("Transitions"))
......@@ -67,9 +69,8 @@ class SourceFactoriesWidget(gtk.Notebook):
class SourceListWidget(gtk.VBox):
""" Widget for listing sources """
def __init__(self, pitivi):
def __init__(self):
gtk.VBox.__init__(self)
self.pitivi = pitivi
# Store
# icon, name, type(audio/video), length, objectfactory, uri
......@@ -158,10 +159,10 @@ class SourceListWidget(gtk.VBox):
# callbacks from discoverer
# TODO : we must remove and reset the callbacks when changing project
self.pitivi.current.sources.connect("file_added", self._file_added_cb)
self.pitivi.current.sources.connect("file_removed", self._file_removed_cb)
instance.PiTiVi.current.sources.connect("file_added", self._file_added_cb)
instance.PiTiVi.current.sources.connect("file_removed", self._file_removed_cb)
self.pitivi.connect("new-project", self._new_project_cb)
instance.PiTiVi.connect("new-project", self._new_project_cb)
# default pixbufs
pixdir = get_pixmap_dir()
......@@ -179,12 +180,16 @@ class SourceListWidget(gtk.VBox):
[dnd.DND_URI_TUPLE, dnd.DND_FILESOURCE_TUPLE],
gtk.gdk.ACTION_COPY)
self.iconview.connect("drag_begin", self._dnd_icon_begin)
self.iconview.connect("drag_data_get", self._dnd_icon_data_get)
self.iconview.connect("drag_data_get", self._dnd_data_get)
self.treeview.drag_source_set(gtk.gdk.BUTTON1_MASK,
[dnd.DND_URI_TUPLE, dnd.DND_FILESOURCE_TUPLE],
gtk.gdk.ACTION_COPY)
self.treeview.connect("drag_begin", self._dnd_tree_begin)
self.treeview.connect("drag_data_get", self._dnd_tree_data_get)
self.treeview.connect("drag_data_get", self._dnd_data_get)
# Hack so that the views have the same method as self
self.iconview.getSelectedItems = self.getSelectedItems
self.treeview.getSelectedItems = self.getSelectedItems
def use_treeview(self):
""" use the treeview """
......@@ -258,7 +263,7 @@ class SourceListWidget(gtk.VBox):
def add_files(self, list):
""" Add files to the list """
self.pitivi.current.sources.add_uris(list)
instance.PiTiVi.current.sources.add_uris(list)
def add_button_clicked_cb(self, widget):
""" called when a user clicks on the add button """
......@@ -288,7 +293,7 @@ class SourceListWidget(gtk.VBox):
store, selected = tsel.get_selected_rows()
uris = [self.storemodel.get_value(self.storemodel.get_iter(path), 5) for path in selected]
for uri in uris:
del self.pitivi.current.sources[uri]
del instance.PiTiVi.current.sources[uri]
def play_button_clicked_cb(self, widget):
""" Called when a user clicks on the play button """
......@@ -301,7 +306,7 @@ class SourceListWidget(gtk.VBox):
return
factory = self.storemodel.get_value(self.storemodel.get_iter(paths[0]), 4)
gst.debug("Let's play %s" % factory.name)
self.pitivi.playground.play_temporary_filesourcefactory(factory)
instance.PiTiVi.playground.play_temporary_filesourcefactory(factory)
def treeview_button_press_event_cb(self, treeview, event):
if event.button == 3:
......@@ -337,9 +342,9 @@ class SourceListWidget(gtk.VBox):
thumbnail = self.audiofilepixbuf
self.storemodel.append([thumbnail, name, desc, length, factory, factory.name])
self.pitivi.current.sources.connect("file_added", self._file_added_cb)
self.pitivi.current.sources.connect("file_removed", self._file_removed_cb)
self.pitivi.current.sources.connect("file_is_valid", self._file_is_valid_cb)
instance.PiTiVi.current.sources.connect("file_added", self._file_added_cb)
instance.PiTiVi.current.sources.connect("file_removed", self._file_removed_cb)
instance.PiTiVi.current.sources.connect("file_is_valid", self._file_is_valid_cb)
def _dnd_data_received(self, widget, context, x, y, selection, targetType,
time):
......@@ -364,26 +369,18 @@ class SourceListWidget(gtk.VBox):
if len(rows) < 1:
context.drag_abort(int(time.time()))
def _dnd_icon_data_get(self, widget, context, selection, targetType, eventTime):
# calls context.drag_abort(time) if not in a valide place
gst.info("icon list data_get, type: %d" % targetType)
# get the list of selected uris
uris = [self.storemodel.get_value(self.storemodel.get_iter(x), 5) for x in self.iconview.get_selected_items()]
if len(uris) < 1:
return
if targetType == dnd.DND_TYPE_PITIVI_FILESOURCE:
selection.set(selection.target, 8,
uris[0])
elif targetType == dnd.DND_TYPE_URI_LIST:
selection.set(selection.target, 8,
string.join(uris, "\n"))
def getSelectedItems(self):
""" returns a list of selected items uri """
if self.iconviewmode:
uris = [self.storemodel.get_value(self.storemodel.get_iter(x), 5) for x in self.iconview.get_selected_items()]
else:
model, rows = self.treeview.get_selection().get_selected_rows()
uris = [self.storemodel.get_value(self.storemodel.get_iter(x), 5) for x in rows]
return uris
def _dnd_tree_data_get(self, widget, context, selection, targetType, eventTime):
# calls context.drag_abort(time) if not in a valide place
gst.info("tree list data_get, type: %d" % targetType)
# get the list of selected uris
model, rows = self.treeview.get_selection().get_selected_rows()
uris = [self.storemodel.get_value(self.storemodel.get_iter(x), 5) for x in rows]
def _dnd_data_get(self, widget, context, selection, targetType, eventTime):
gst.info("data get, type:%d" % targetType)
uris = self.getSelectedItems()
if len(uris) < 1:
return
if targetType == dnd.DND_TYPE_PITIVI_FILESOURCE:
......@@ -392,35 +389,95 @@ class SourceListWidget(gtk.VBox):
elif targetType == dnd.DND_TYPE_URI_LIST:
selection.set(selection.target, 8,
string.join(uris, "\n"))
class AudioFxListWidget(gtk.VBox):
""" Widget for listing audio effects """
""" Widget for listing video effects """
def __init__(self, pitivi):
self.pitivi = pitivi
def __init__(self):
gtk.VBox.__init__(self)
self.iconview = gtk.IconView()
self.treeview = gtk.TreeView()
self.pack_start(self.iconview)
self.set_border_width(5)
# model
self.storemodel = gtk.ListStore(str, str, object)
self.scrollwin = gtk.ScrolledWindow()
self.scrollwin.set_policy(gtk.POLICY_NEVER,
gtk.POLICY_AUTOMATIC)
self.pack_start(self.scrollwin)
self.iconview = gtk.IconView(self.storemodel)
self.treeview = gtk.TreeView(self.storemodel)
namecol = gtk.TreeViewColumn("Name")
self.treeview.append_column(namecol)
namecell = gtk.CellRendererText()
namecol.pack_start(namecell)
namecol.add_attribute(namecell, "text", 0)
namecol = gtk.TreeViewColumn("Description")
self.treeview.append_column(namecol)
namecell = gtk.CellRendererText()
namecell.set_property("ellipsize", pango.ELLIPSIZE_END)
namecol.pack_start(namecell)
namecol.add_attribute(namecell, "text", 1)
self.scrollwin.add(self.treeview)
self._fillUpModel()
def _fillUpModel(self):
for factory in instance.PiTiVi.effects.simple_audio:
self.storemodel.append([factory.get_longname(),
factory.get_description(),
factory])
class VideoFxListWidget(gtk.VBox):
""" Widget for listing video effects """
def __init__(self, pitivi):
self.pitivi = pitivi
def __init__(self):
gtk.VBox.__init__(self)
self.iconview = gtk.IconView()
self.treeview = gtk.TreeView()
self.pack_start(self.iconview)
self.set_border_width(5)
# model
self.storemodel = gtk.ListStore(str, str, object)
self.scrollwin = gtk.ScrolledWindow()
self.scrollwin.set_policy(gtk.POLICY_NEVER,
gtk.POLICY_AUTOMATIC)
self.pack_start(self.scrollwin)
self.iconview = gtk.IconView(self.storemodel)
self.treeview = gtk.TreeView(self.storemodel)
namecol = gtk.TreeViewColumn("Name")
self.treeview.append_column(namecol)
namecell = gtk.CellRendererText()
namecol.pack_start(namecell)
namecol.add_attribute(namecell, "text", 0)
namecol = gtk.TreeViewColumn("Description")
self.treeview.append_column(namecol)
namecell = gtk.CellRendererText()
namecell.set_property("ellipsize", pango.ELLIPSIZE_END)
namecol.pack_start(namecell)
namecol.add_attribute(namecell, "text", 1)
self.scrollwin.add(self.treeview)
self._fillUpModel()
def _fillUpModel(self):
for factory in instance.PiTiVi.effects.simple_video:
self.storemodel.append([factory.get_longname(),
factory.get_description(),
factory])
class TransitionListWidget(gtk.VBox):
""" Widget for listing transitions """
def __init__(self, pitivi):
self.pitivi = pitivi
def __init__(self):
gtk.VBox.__init__(self)
self.iconview = gtk.IconView()
self.treeview = gtk.TreeView()
......
......@@ -23,15 +23,15 @@
import gtk
import gobject
import gst
from timelineobjects import SimpleSourceWidget, SimpleTimeline
from complextimeline import ComplexTimelineWidget
class TimelineWidget(gtk.VBox):
""" Widget for reprensenting Pitivi's Timeline """
def __init__(self, pitivi):
def __init__(self):
gst.log("New Timeline Widget")
self.pitivi = pitivi
gtk.VBox.__init__(self)
self._create_gui()
......@@ -112,8 +112,7 @@ class SimpleTimelineContentWidget(gtk.HBox):
self.twidget.leftsizegroup.add_widget(self.header)
self.pack_start(self.header, expand=False)
self.timeline = SimpleTimeline(self.twidget, self.twidget.pitivi,
hadjustment = self.twidget.hadjustment)
self.timeline = SimpleTimeline(hadjustment = self.twidget.hadjustment)
layoutframe = gtk.Frame()
layoutframe.add(self.timeline)
......
......@@ -25,6 +25,8 @@ import gobject
import gtk
import gst
from gtk import gdk
import pitivi.instance as instance
from pitivi.timeline import Timeline, TimelineComposition, TimelineFileSource, TimelineSource, MEDIA_TYPE_AUDIO, MEDIA_TYPE_VIDEO
import pitivi.dnd as dnd
from sourcefactories import beautify_length
......@@ -48,15 +50,13 @@ MINIMUM_WIDTH = 3 * DEFAULT_HEIGHT
class SimpleTimeline(gtk.Layout):
""" Simple Timeline representation """
def __init__(self, twidget, pitivi, **kw):
def __init__(self, **kw):
gobject.GObject.__init__(self, **kw)
self.twidget = twidget
self.pitivi = pitivi
self.hadjustment = self.get_property("hadjustment")
# timeline and top level compositions
self.timeline = self.pitivi.current.timeline
self.timeline = instance.PiTiVi.current.timeline
self.condensed = self.timeline.videocomp.condensed
# TODO : connect signals for when the timeline changes
......@@ -245,7 +245,7 @@ class SimpleTimeline(gtk.Layout):
else:
context.finish(False, False, timestamp)
x = x + int(self.hadjustment.get_value())
self._got_filefactory(self.pitivi.current.sources[uri], x, y)
self._got_filefactory(instance.PiTiVi.current.sources[uri], x, y)
context.finish(True, False, timestamp)
def _realize_cb(self, layout):
......
......@@ -24,6 +24,10 @@ import gtk
import gst
import cairo
import pitivi.dnd as dnd
import pitivi.instance as instance
from pitivi.timeline import TimelineFileSource
from complexinterface import ZoomableWidgetInterface
from complexsource import ComplexTimelineSource
......@@ -49,6 +53,7 @@ class TrackLayer(gtk.Layout, ZoomableWidgetInterface):
gst.log("new TrackLayer for composition %r" % layerInfo.composition)
gtk.Layout.__init__(self)
self.hadjustment = hadj
self.set_hadjustment(hadj)
self.sources = {}
self.layerInfo = layerInfo
......@@ -58,6 +63,15 @@ class TrackLayer(gtk.Layout, ZoomableWidgetInterface):
self.pixmap = None
# drag and drop
self.drag_dest_set(gtk.DEST_DEFAULT_DROP | gtk.DEST_DEFAULT_MOTION,
[dnd.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)
# object being currently dragged
self.dragObject = None
## composition signal callbacks
......@@ -87,6 +101,7 @@ class TrackLayer(gtk.Layout, ZoomableWidgetInterface):
self.effectgutter + self.layergutter,
widget.get_pixel_width(),
height))
widget.show()
# we need to keep track of the child's position
source.connect_after('start-duration-changed', self.__childStartDurationChangedCb)
......@@ -180,3 +195,37 @@ class TrackLayer(gtk.Layout, ZoomableWidgetInterface):
height = self.effectgutter + 2 * self.layergutter + 100
return height
return 0
## Drag and Drop
def dragDataReceivedCb(self, layout, context, x, y, selection,
targetType, timestamp):
# something was dropped
gst.debug("%s" % type(selection))
self.dragObject = None
if targetType == dnd.DND_TYPE_PITIVI_FILESOURCE:
# a source was dropped
source = instance.PiTiVi.current.sources[selection.data]
else:
context.finish(False, False, timestamp)
return
x += int(self.hadjustment.get_value())
gst.debug("got source %s x:%d" % (source, x))
# do something with source
self.layerInfo.composition.prepend_source(TimelineFileSource(factory=source,
media_type=self.layerInfo.composition.media_type,
name = source.name))
context.finish(True, False, timestamp)
def dragLeaveCb(self, layout, context, timestamp):
gst.debug("something left")
self.dragObject = None
def dragMotionCb(self, layout, context, x, y, timestamp):
gst.debug("something entered x:%d, y:%d" % (x,y))
if not self.dragObject:
source = context.get_source_widget().getSelectedItems()[0]
self.dragObject = instance.PiTiVi.current.sources[source]
gst.debug("we have %s" % self.dragObject)
......@@ -27,7 +27,9 @@ import gst
import pango
import gst.interfaces
from glade import GladeWindow
import plumber
import pitivi.instance as instance
from pitivi.bin import SmartTimelineBin, SmartDefaultBin
from pitivi.objectfactory import FileSourceFactory
import pitivi.dnd as dnd
......@@ -45,9 +47,8 @@ def time_to_string(value):
class PitiviViewer(gtk.VBox):
""" Pitivi's graphical viewer """
def __init__(self, pitivi):
def __init__(self):
gst.log("New PitiviViewer")
self.pitivi = pitivi
gtk.VBox.__init__(self)
self.current_time = long(0)
self.current_frame = -1
......@@ -56,17 +57,17 @@ class PitiviViewer(gtk.VBox):
# connect to the sourcelist for temp factories