[pitivi] DND without crashing, need to make it work properly
- From: Edward Hervey <edwardrv src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pitivi] DND without crashing, need to make it work properly
- Date: Wed, 22 Sep 2010 13:35:38 +0000 (UTC)
commit 8e77c5b949189b9587d39814f98e3e95cf33dfad
Author: Thibault Saunier <tsaunier src gnome org>
Date: Sat May 29 15:30:12 2010 -0400
DND without crashing, need to make it work properly
pitivi/effects.py | 42 ++++++++++++++++++++++++++++++++++++++----
pitivi/timeline/track.py | 2 +-
pitivi/ui/effectlist.py | 30 ++++++++++++++++++++++--------
pitivi/ui/timeline.py | 28 +++++++++++++++++++++-------
pitivi/ui/trackobject.py | 19 ++++++++++++-------
5 files changed, 94 insertions(+), 27 deletions(-)
---
diff --git a/pitivi/effects.py b/pitivi/effects.py
index 6300fc9..6eb7c26 100644
--- a/pitivi/effects.py
+++ b/pitivi/effects.py
@@ -25,6 +25,8 @@ Effects global handling
"""
import gst
+from pitivi.factories.operation import EffectFactory
+from pitivi.stream import get_stream_for_pad
# There are different types of effects available:
# _ Simple Audio/Video Effects
@@ -43,6 +45,7 @@ class Magician:
def __init__(self):
self.simple_video = []
self.simple_audio = []
+ self.effect_factories_dict = {}
self.transitions = []
self._getSimpleFilters()
self._getEffectPlugins()
@@ -53,13 +56,44 @@ class Magician:
factlist = gst.registry_get_default().get_feature_list(gst.ElementFactory)
for fact in factlist:
klass = fact.get_klass()
- if 'Audio' in klass and 'Effect' in klass:
- self.simple_audio.append(fact)
- elif 'Video' in klass and 'Effect' in klass:
- self.simple_video.append(fact)
+ if "Effect" in klass:
+ if 'Audio' in klass:
+ self.simple_audio.append(fact)
+ elif 'Video' in klass:
+ self.simple_video.append(fact)
+ factory = EffectFactory(fact.get_name(), fact.get_name())
+ self.addFactory(fact.get_name(), factory)
+ self.addStreams(fact)
def _getEffectPlugins(self):
# find all the pitivi plugins that provide effects
# TODO : implement
pass
+
+ def addFactory(self, name, factory):
+ self.effect_factories_dict[name]=factory
+
+ def getFactory(self, name):
+ return self.effect_factories_dict.get(name)
+
+ def addStreams(self, element):
+ pads = element.get_static_pad_templates()
+ factory = self.getFactory(element.get_name())
+
+ if not factory: #FIXME Should raise an exception?
+ return
+
+ for padTmp in pads:
+ pad = gst.Pad (padTmp.get())
+ if pad.get_caps() == "ANY": #FIXME, I don't understand that!
+ return
+
+ if padTmp.direction == gst.PAD_SRC:
+ stream = get_stream_for_pad(pad)
+ factory.addInputStream(stream)
+ elif padTmp.direction == gst.PAD_SINK:
+ stream = get_stream_for_pad(pad)
+ factory.addOutputStream(stream)
+ else: #FIXME
+ return
diff --git a/pitivi/timeline/track.py b/pitivi/timeline/track.py
index a5dae29..814c71c 100644
--- a/pitivi/timeline/track.py
+++ b/pitivi/timeline/track.py
@@ -712,7 +712,7 @@ class TrackEffect(TrackObject):
def _makeGnlObject(self):
effect = gst.element_factory_make('gnloperation',
"gnloperation: " + self.factory.__class__.__name__ +
- str(SourceTrackObject.numobjs))
+ str(TrackEffect.numobjs))
TrackEffect.numobjs += 1
return effect
diff --git a/pitivi/ui/effectlist.py b/pitivi/ui/effectlist.py
index 8e48648..145c944 100644
--- a/pitivi/ui/effectlist.py
+++ b/pitivi/ui/effectlist.py
@@ -31,8 +31,8 @@ from gettext import gettext as _
from gettext import ngettext
import pitivi.ui.dnd as dnd
-from pitivi.factories.operation import EffectFactory
+from pitivi.configure import get_pixmap_dir
from pitivi.settings import GlobalSettings
from pitivi.utils import beautify_length
@@ -47,6 +47,9 @@ from pitivi.log.loggable import Loggable
COL_SEARCH_TEXT,
COL_SHORT_TEXT) = range(6)
+INVISIBLE = gtk.gdk.pixbuf_new_from_file(os.path.join(get_pixmap_dir(),
+ "invisible.png"))
+
class EffectList(gtk.VBox, Loggable):
""" Widget for listing effects """
@@ -116,6 +119,7 @@ class EffectList(gtk.VBox, Loggable):
self._treeViewButtonReleaseCb)
self.treeview.connect("drag_begin",
self._dndDragBeginCb)
+ self.treeview.connect("drag_data_get", self._dndDataGetCb)
self.pack_start(self.treeview_scrollwin)
#Get all available effects
@@ -132,7 +136,7 @@ class EffectList(gtk.VBox, Loggable):
visualname = ("<b>Name: </b>" + escape(unquote(effect.get_longname())) + "\n" +
"<b>Description: </b>"+ effect.get_description())
- factory = self._getFactoryFromEffect(effect)
+ factory = self.app.effects.getFactory(effect.get_name())
self.storemodel.append ([pixbuf, pixbuf, visualname,
factory, effect.get_description(),
factory.name])
@@ -156,7 +160,6 @@ class EffectList(gtk.VBox, Loggable):
return selection.path_is_selected(path) and selection.count_selected_rows() > 0
elif isinstance(view, gtk.IconView):
selection = view.get_selected_items()
-
return view.path_is_selected(path) and len(selection)
else:
assert False
@@ -236,8 +239,22 @@ class EffectList(gtk.VBox, Loggable):
tooltip.set_text(treeview.get_model()[pos[0]][4])
return True
- def _insertEndCb(self, unused_action):
- print "T34T"
+ def getSelectedItems(self):
+ model, rows = self.treeview.get_selection().get_selected_rows()
+ return [self.storemodel[path][COL_SHORT_TEXT]
+ for path in rows]
+
+ def _dndDataGetCb(self, unused_widget, context, selection,
+ targettype, unused_eventtime):
+ self.info("data get, type:%d", targettype)
+ factory = self.getSelectedItems()
+
+ if len(factory) < 1:
+ return
+ factory = factory[0]
+
+ selection.set(selection.target, 8, factory)
+ context.set_icon_pixbuf(INVISIBLE, 0, 0)
def _nothingUnderMouse(self, view, event):
return not bool(view.get_path_at_pos(int(event.x), int(event.y)))
@@ -245,9 +262,6 @@ class EffectList(gtk.VBox, Loggable):
def _getEffects():
raise NotImplementedError()
- def _getFactoryFromEffect(self, effect):
- return EffectFactory(effect.get_name())
-
def _getDndTuple(self):
raise NotImplementedError()
diff --git a/pitivi/ui/timeline.py b/pitivi/ui/timeline.py
index 19e23e0..551afdf 100644
--- a/pitivi/ui/timeline.py
+++ b/pitivi/ui/timeline.py
@@ -43,6 +43,8 @@ from pitivi.utils import Seeker
from pitivi.ui.filelisterrordialog import FileListErrorDialog
from pitivi.ui.curve import Curve
+from pitivi.factories.operation import EffectFactory
+
# tooltip text for toolbar
DELETE = _("Delete Selected")
SPLIT = _("Split clip at playhead position")
@@ -407,9 +409,13 @@ class Timeline(gtk.Table, Loggable, Zoomable):
self.warning("self._factories:%r, self._temp_objects:%r",
not not self._factories,
not not self._temp_objects)
- print "DRAG_MOTION"
if self._factories is None:
- atom = gtk.gdk.atom_intern(dnd.FILESOURCE_TUPLE[0])
+ if context.targets in [[dnd.VIDEO_EFFECT_TUPLE[0], dnd.EFFECT_TUPLE[0]],\
+ [dnd.AUDIO_EFFECT_TUPLE[0], dnd.EFFECT_TUPLE[0]]]:
+ atom = gtk.gdk.atom_intern(dnd.EFFECT_TUPLE[0])
+ else:
+ atom = gtk.gdk.atom_intern(dnd.FILESOURCE_TUPLE[0])
+
self.drag_get_data(context, atom, timestamp)
self.drag_highlight()
else:
@@ -461,18 +467,26 @@ class Timeline(gtk.Table, Loggable, Zoomable):
# tell current project to import the uri
# wait for source-added signal, meanwhile ignore dragMotion signals
# when ready, add factories to the timeline.
- if targetType != dnd.TYPE_PITIVI_FILESOURCE:
+ if targetType not in [dnd.TYPE_PITIVI_FILESOURCE, dnd.TYPE_PITIVI_EFFECT]:
context.finish(False, False, timestamp)
return
- uris = selection.data.split("\n")
- self._factories = [self.project.sources.getUri(uri) for uri in uris]
+ if targetType == dnd.TYPE_PITIVI_FILESOURCE:
+ uris = selection.data.split("\n")
+ self._factories = [self.project.sources.getUri(uri) for uri in uris]
+ else:
+ self._factories = [self.app.effects.getFactory(selection.data)]
+
context.drag_status(gtk.gdk.ACTION_COPY, timestamp)
return True
def _add_temp_source(self):
- self._temp_objects = [self.timeline.addSourceFactory(factory)
- for factory in self._factories]
+ if isinstance (self._factories[0], EffectFactory):
+ self._temp_objects = [self.timeline.addEffectFactory(factory)
+ for factory in self._factories]
+ else:
+ self._temp_objects = [self.timeline.addSourceFactory(factory)
+ for factory in self._factories]
def _move_temp_source(self, x, y):
x1, y1, x2, y2 = self._controls.get_allocation()
diff --git a/pitivi/ui/trackobject.py b/pitivi/ui/trackobject.py
index 19b1aee..2c397f6 100644
--- a/pitivi/ui/trackobject.py
+++ b/pitivi/ui/trackobject.py
@@ -23,6 +23,7 @@ from pitivi.ui.point import Point
from pitivi.ui.prefs import PreferencesDialog
from pitivi.settings import GlobalSettings
from pitivi.stream import AudioStream, VideoStream
+from pitivi.timeline.track import TrackEffect
LEFT_SIDE = gtk.gdk.Cursor(gtk.gdk.LEFT_SIDE)
RIGHT_SIDE = gtk.gdk.Cursor(gtk.gdk.RIGHT_SIDE)
@@ -244,10 +245,13 @@ class TrackObject(View, goocanvas.Group, Zoomable):
self.nameheight = 0
self.bg = goocanvas.Rect(
- height=self.height,
+ height=self.height,
line_width=1)
- self.content = Preview(self.app, element)
+ #FIXME I should find the way we want to effects in the time (It should
+ #be shown on existing track?)
+ if not isinstance(element, TrackEffect):
+ self.content = Preview(self.app, element)
self.name = goocanvas.Text(
x= NAME_HOFFSET + NAME_PADDING,
@@ -271,12 +275,13 @@ class TrackObject(View, goocanvas.Group, Zoomable):
line_width = 0.0,
height=self.height)
- for thing in (self.bg, self.content, self.selection_indicator,
- self.start_handle, self.end_handle, self.namebg, self.name):
- self.add_child(thing)
+ if not isinstance(element, TrackEffect): #FIXME
+ for thing in (self.bg, self.content, self.selection_indicator,
+ self.start_handle, self.end_handle, self.namebg, self.name):
+ self.add_child(thing)
- for prop, interpolator in element.getInterpolators().itervalues():
- self.add_child(Curve(instance, element, interpolator))
+ for prop, interpolator in element.getInterpolators().itervalues():
+ self.add_child(Curve(instance, element, interpolator))
self.element = element
self.settings = instance.settings
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]