[pitivi/ges: 82/287] Restore effects after GES port + cleanup
- From: Jean-FranÃois Fortin Tam <jfft src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pitivi/ges: 82/287] Restore effects after GES port + cleanup
- Date: Thu, 15 Mar 2012 16:32:43 +0000 (UTC)
commit 76b278beaf1dda7d871396896618088db96b4689
Author: Thibault Saunier <thibault saunier collabora com>
Date: Thu Dec 8 18:07:05 2011 -0300
Restore effects after GES port + cleanup
pitivi/effects.py | 14 ++--
pitivi/timeline/timeline.py | 6 +-
pitivi/ui/clipproperties.py | 148 +++++++++++++++++++++++--------------
pitivi/ui/effectsconfiguration.py | 3 +
pitivi/ui/mainwindow.py | 15 +++-
pitivi/ui/timeline.py | 74 ++++++++++++------
pitivi/ui/track.py | 7 ++
7 files changed, 176 insertions(+), 91 deletions(-)
---
diff --git a/pitivi/effects.py b/pitivi/effects.py
index c776ec4..7a2ac0d 100644
--- a/pitivi/effects.py
+++ b/pitivi/effects.py
@@ -61,9 +61,10 @@ class Effect():
"""
Factories that applies an effect on a stream
"""
- def __init__(self, effect, name='', categories=[_("Uncategorized")],
+ def __init__(self, effect, media_type, categories=[_("Uncategorized")],
human_name="", description="", icon=None):
self.effectname = effect
+ self.media_type = media_type
self.categories = categories
self.description = description
self.human_name = human_name
@@ -155,14 +156,16 @@ class EffectsHandler(object):
name = element_factory.get_name()
if "Effect" in klass and name not in BLACKLISTED_EFFECTS and not\
[bplug for bplug in BLACKLISTED_PLUGINS if bplug in name]:
- effect = Effect(name, name,
- self._getEffectCategories(name),
- self._getEffectName(element_factory),
- self._getEffectDescripton(element_factory))
if 'Audio' in klass:
self.audio_effects.append(element_factory)
+ media_type = AUDIO_EFFECT
elif 'Video' in klass:
self.video_effects.append(element_factory)
+ media_type = VIDEO_EFFECT
+ effect = Effect(name, media_type,
+ self._getEffectCategories(name),
+ self._getEffectName(element_factory),
+ self._getEffectDescripton(element_factory))
self._addEffectToDic(name, effect)
def getAllAudioEffects(self):
@@ -375,5 +378,4 @@ class EffectGstElementPropertyChangeTracker:
action = EffectPropertyChanged(gst_element, pspec.name, old_value,
new_value)
self._tracked_effects[gst_element][pspec.name] = new_value
- self.pipeline.flushSeekVideo()
self.action_log.push(action)
diff --git a/pitivi/timeline/timeline.py b/pitivi/timeline/timeline.py
index 50a0895..e8235cb 100644
--- a/pitivi/timeline/timeline.py
+++ b/pitivi/timeline/timeline.py
@@ -708,11 +708,13 @@ class Selection(Signallable):
for obj in self.selected - old_selection:
for tckobj in obj.get_track_objects():
- tckobj.selected.selected = True
+ if not isinstance(tckobj, ges.TrackEffect):
+ tckobj.selected.selected = True
for obj in old_selection - self.selected:
for tckobj in obj.get_track_objects():
- tckobj.selected.selected = False
+ if not isinstance(tckobj, ges.TrackEffect):
+ tckobj.selected.selected = False
# FIXME : shouldn't we ONLY emit this IFF the selection has changed ?
self.emit("selection-changed")
diff --git a/pitivi/ui/clipproperties.py b/pitivi/ui/clipproperties.py
index a02f4e6..2566055 100644
--- a/pitivi/ui/clipproperties.py
+++ b/pitivi/ui/clipproperties.py
@@ -26,20 +26,23 @@ import gtk
import pango
import dnd
import os
+import ges
from gettext import gettext as _
+from pitivi.utils import Seeker
+from pitivi.check import soft_deps
+from pitivi.configure import get_ui_dir
from pitivi.log.loggable import Loggable
+from pitivi.effects import AUDIO_EFFECT, VIDEO_EFFECT
-from pitivi.ui.gstwidget import GstElementSettingsWidget
-from pitivi.ui.effectsconfiguration import EffectsPropertiesHandling
+
+from pitivi.ui.track import track_is_type
from pitivi.ui.depsmanager import DepsManager
from pitivi.ui.common import PADDING, SPACING
-from pitivi.configure import get_ui_dir
-from pitivi.check import soft_deps
from pitivi.ui.effectlist import HIDDEN_EFFECTS
-
-import ges
+from pitivi.ui.gstwidget import GstElementSettingsWidget
+from pitivi.ui.effectsconfiguration import EffectsPropertiesHandling
(COL_ACTIVATED,
COL_TYPE,
@@ -53,6 +56,17 @@ class ClipPropertiesError(Exception):
pass
+def compare_type(track, effect_type):
+
+ if track_is_type(track, 'GES_TRACK_TYPE_AUDIO') and \
+ effect_type == AUDIO_EFFECT:
+ return True
+ elif track_is_type(track, 'GES_TRACK_TYPE_VIDEO') and \
+ effect_type == VIDEO_EFFECT:
+ return True
+ return False
+
+
class ClipProperties(gtk.ScrolledWindow, Loggable):
"""
Widget for configuring clips properties
@@ -82,8 +96,7 @@ class ClipProperties(gtk.ScrolledWindow, Loggable):
self.effect_properties_handling = EffectsPropertiesHandling(instance.action_log)
self.effect_expander = EffectProperties(instance,
- self.effect_properties_handling,
- self)
+ self.effect_properties_handling, self)
vbox.pack_start(self.info_bar_box, expand=False, fill=True)
@@ -153,6 +166,8 @@ class EffectProperties(gtk.Expander, gtk.HBox):
self._info_bar = None
self._config_ui_h_pos = None
self._timeline = None
+ # We use the seeker to flush the pipeline when needed
+ self._seeker = Seeker(80)
self._vcontent = gtk.VPaned()
self.add(self._vcontent)
@@ -168,7 +183,7 @@ class EffectProperties(gtk.Expander, gtk.HBox):
self._toolbar.insert(self._removeEffectBt, 0)
self._table.attach(self._toolbar, 0, 1, 0, 1, yoptions=gtk.FILL)
- self.storemodel = gtk.ListStore(bool, str, str, object)
+ self.storemodel = gtk.ListStore(bool, str, str, str, object)
#Treeview
self.treeview_scrollwin = gtk.ScrolledWindow()
@@ -246,8 +261,7 @@ class EffectProperties(gtk.Expander, gtk.HBox):
def _newProjectLoadedCb(self, app, project):
self.clip_properties.project = project
- #GES break, reimplement me
- #self.selected_effects = self.timeline.selection.getSelectedTrackEffects()
+ self.selected_effects = self.timeline.selection.getSelectedTrackEffects()
self._updateAll()
def _vcontentNotifyCb(self, paned, gparamspec):
@@ -260,29 +274,38 @@ class EffectProperties(gtk.Expander, gtk.HBox):
def _setTimeline(self, timeline):
self._timeline = timeline
- if not self.connected:
- self.app.projectManager.current.connect("selected-changed", self._selectionChangedCb)
- self.connected = True
+ #if not self.connected:
+ self._timeline.selection.connect("selection-changed", self._selectionChangedCb)
+ self.connected = True
timeline = property(_getTimeline, _setTimeline)
- def _selectionChangedCb(self, project, element):
- self.timeline_objects = []
- if isinstance(element, set):
- for elem in element:
- self.timeline_objects.append(elem)
+ def _selectionChangedCb(self, selection,):
+ for timeline_object in self.timeline_objects:
+ timeline_object.disconnect_by_func(self._trackObjectAddedCb)
+ timeline_object.disconnect_by_func(self._trackRemovedRemovedCb)
+
+ self.selected_effects = selection.getSelectedTrackEffects()
+
+ if selection.selected:
+ self.timeline_objects = list(selection.selected)
+ for timeline_object in self.timeline_objects:
+ timeline_object.connect("track-object-added", self._trackObjectAddedCb)
+ timeline_object.connect("track-object-removed", self._trackRemovedRemovedCb)
+ self.set_sensitive(True)
else:
- self.timeline_objects.append(element)
+ self.timeline_objects = []
+ self.set_sensitive(False)
self._updateAll()
def _trackObjectAddedCb(self, unused_timeline_object, track_object):
- if isinstance(track_object, TrackEffect):
+ if isinstance(track_object, ges.TrackEffect):
selec = self.timeline.selection.getSelectedTrackEffects()
self.selected_effects = selec
self._updateAll()
def _trackRemovedRemovedCb(self, unused_timeline_object, track_object):
- if isinstance(track_object, TrackEffect):
+ if isinstance(track_object, ges.TrackEffect):
selec = self.timeline.selection.getSelectedTrackEffects()
self.selected_effects = selec
self._updateAll()
@@ -309,26 +332,40 @@ class EffectProperties(gtk.Expander, gtk.HBox):
def _cleanCache(self, effect):
config_ui = self.effect_props_handling.cleanCache(effect)
- def addEffectToCurrentSelection(self, factory_name):
+ def addEffectToCurrentSelection(self, bin_desc):
if self.timeline_objects:
- factory = self.app.effects.getFactoryFromName(factory_name)
- self.app.action_log.begin("add effect")
- effect = ges.TrackParseLaunchEffect(factory_name)
- self.timeline_objects[0].get_timeline_object().add_track_object(effect)
- self.timeline_objects[1].get_track().add_object(effect)
- self._updateAll()
- self.app.action_log.commit()
+ media_type = self.app.effects.getFactoryFromName(bin_desc).media_type
+
+ # Trying to apply effect only on the first object of the selection
+ tlobj = self.timeline_objects[0]
+
+ # Checking that this effect can be applied on this track object
+ # Which means, it has the corresponding media_type
+ for tckobj in tlobj.get_track_objects():
+ track = tckobj.get_track()
+ if track_is_type(track, 'GES_TRACK_TYPE_AUDIO') and \
+ media_type == AUDIO_EFFECT or \
+ track_is_type(track, 'GES_TRACK_TYPE_VIDEO') and \
+ media_type == VIDEO_EFFECT:
+ #Actually add the effect
+ self.app.action_log.begin("add effect")
+ effect = ges.TrackParseLaunchEffect(bin_desc)
+ tlobj.add_track_object(effect)
+ track.add_object(effect)
+ self._updateAll()
+ self.app.action_log.commit()
+ self._seeker.flush()
+
+ break
def _dragDataReceivedCb(self, unused_layout, context, unused_x, unused_y,
- selection, unused_targetType, unused_timestamp):
+ selection, unused_targetType, unused_timestamp):
self._factory = self.app.effects.getFactoryFromName(selection.data)
- def _dragDropCb(self, unused, context, unused_x, unused_y, unused_timestamp):
+ def _dragDropCb(self, unused, context, unused_x, unused_y,
+ unused_timestamp):
if self._factory:
- self.app.action_log.begin("add effect")
- self.timeline.addEffectFactoryOnObject(self._factory,
- self.timeline_objects)
- self.app.action_log.commit()
+ self.addEffectToCurrentSelection(self._factory.effectname)
self._factory = None
def _dragLeaveCb(self, unused_layout, unused_context, unused_tstamp):
@@ -343,10 +380,10 @@ class EffectProperties(gtk.Expander, gtk.HBox):
def _effectActiveToggleCb(self, cellrenderertoggle, path):
iter = self.storemodel.get_iter(path)
- track_effect = self.storemodel.get_value(iter, COL_TRACK_EFFECT)
+ tck_effect = self.storemodel.get_value(iter, COL_TRACK_EFFECT)
self.app.action_log.begin("change active state")
- track_effect.set_active(not track_effect.is_active())
- cellrenderertoggle.set_active(track_effect.is_active())
+ tck_effect.set_active(not tck_effect.is_active())
+ cellrenderertoggle.set_active(tck_effect.is_active())
self._updateTreeview()
self.app.action_log.commit()
@@ -375,28 +412,26 @@ class EffectProperties(gtk.Expander, gtk.HBox):
self.storemodel.clear()
self._showInfoBar()
self._vcontent.show()
- self._removeEffectBt.set_sensitive(False)
- if len(self.timeline_objects) >= 1:
- self._setEffectDragable()
- self._updateTreeview()
- self._updateEffectConfigUi()
else:
self._vcontent.hide()
def _updateTreeview(self):
self.storemodel.clear()
- obj = self.timeline_objects[0].get_timeline_object()
+ obj = self.timeline_objects[0]
for track_effect in obj.get_top_effects():
- if not track_effect.factory.effectname in HIDDEN_EFFECTS:
- to_append = [track_effect.get_property("active")]
- #FIXME ugly GES -> use TrackType
- if track_effect.get_track().get_caps().to_string() == "audio/x-raw-int; audio/x-raw-float":
+ if not track_effect.props.bin_description in HIDDEN_EFFECTS:
+ material = self.app.effects.getFactoryFromName(
+ track_effect.props.bin_description)
+ to_append = [track_effect.props.active]
+ track = track_effect.get_track()
+ if track_is_type(track, 'GES_TRACK_TYPE_AUDIO'):
to_append.append("Audio")
- else:
+ elif track_is_type(track, 'GES_TRACK_TYPE_VIDEO'):
to_append.append("Video")
- to_append.append(track_effect.get_property("bin-description"))
+ to_append.append(track_effect.props.bin_description)
+ to_append.append(material.description)
to_append.append(track_effect)
self.storemodel.append(to_append)
@@ -596,11 +631,11 @@ class TransformationProperties(gtk.Expander):
effect.freeze_notify()
return self.effect
- def _selectionChangedCb(self, project, selection):
- self.timeline_objects = list(selection)
+ def _selectionChangedCb(self, timeline):
+ if self.timeline and len(self.timeline.selection.selected) > 0:
+ for tl_obj in self.timeline.selection.selected:
+ pass
- if len(self.timeline_objects) == 1:
- tl_obj = self.timeline_objects[0]
if tl_obj != self._current_tl_obj:
self._current_tl_obj = tl_obj
self.effect = None
@@ -613,6 +648,7 @@ class TransformationProperties(gtk.Expander):
if self._current_tl_obj:
self._current_tl_obj = None
self.zoom_scale.set_value(1.0)
+ self.app.gui.viewer.pipeline.flushSeekVideo()
self.effect = None
self.set_sensitive(False)
self._updateBoxVisibility()
@@ -629,6 +665,6 @@ class TransformationProperties(gtk.Expander):
def _setTimeline(self, timeline):
self._timeline = timeline
if timeline:
- self.app.projectManager.current.connect('selected-changed', self._selectionChangedCb)
+ self._timeline.selection.connect('selection-changed', self._selectionChangedCb)
timeline = property(_getTimeline, _setTimeline)
diff --git a/pitivi/ui/effectsconfiguration.py b/pitivi/ui/effectsconfiguration.py
index b9ecb3b..3a6f095 100644
--- a/pitivi/ui/effectsconfiguration.py
+++ b/pitivi/ui/effectsconfiguration.py
@@ -22,6 +22,7 @@ import gst
import gtk
import gobject
+from pitivi.utils import Seeker
from pitivi.ui.gstwidget import GstElementSettingsWidget
from pitivi.ui.dynamic import FractionWidget
@@ -34,6 +35,7 @@ class EffectsPropertiesHandling:
self._current_effect_setting_ui = None
self._current_element_values = {}
self.action_log = action_log
+ self._seeker = Seeker(80)
def getEffectConfigurationUI(self, effect):
"""
@@ -104,4 +106,5 @@ class EffectsPropertiesHandling:
self.action_log.begin("Effect property change")
self._current_effect_setting_ui.element.set_child_property(prop.name, value)
self.action_log.commit()
+ self._seeker.flush()
self._current_element_values[prop.name] = value
diff --git a/pitivi/ui/mainwindow.py b/pitivi/ui/mainwindow.py
index 533b61e..5669f81 100644
--- a/pitivi/ui/mainwindow.py
+++ b/pitivi/ui/mainwindow.py
@@ -699,6 +699,7 @@ class PitiviMainWindow(gtk.Window, Loggable):
self._zoom_duration_changed = True
self.project.seeker.connect("seek", self._timelineSeekCb)
+ self.project.seeker.connect("flush", self._timelineSeekFlushCb)
# preliminary seek to ensure the project pipeline is configured
self.project.seeker.seek(0)
@@ -1073,6 +1074,16 @@ class PitiviMainWindow(gtk.Window, Loggable):
#GES crazyness... Implement
pass
+ def _timelineSeekFlushCb(self, unused_seeker):
+ try:
+ position = self.project_pipeline.query_position(gst.FORMAT_TIME)[0]
+ self.project_pipeline.seek(1.0, gst.FORMAT_TIME, gst.SEEK_FLAG_FLUSH,
+ gst.SEEK_TYPE_SET, position, gst.SEEK_TYPE_NONE, -1)
+ self.timeline.timelinePositionChanged(position)
+
+ except Exception, e:
+ self.error("seek failed %s %s %s", gst.TIME_ARGS(position), format, e)
+
def _timelineSeekCb(self, ruler, position, format):
try:
if position < 0:
@@ -1081,8 +1092,8 @@ class PitiviMainWindow(gtk.Window, Loggable):
position = self.timeline.getDuration()
self.project_pipeline.seek(1.0, format, gst.SEEK_FLAG_FLUSH,
- gst.SEEK_TYPE_SET, position,
- gst.SEEK_TYPE_NONE, -1)
+ gst.SEEK_TYPE_SET, position, gst.SEEK_TYPE_NONE, -1)
+
self.timeline.timelinePositionChanged(position)
except Exception, e:
diff --git a/pitivi/ui/timeline.py b/pitivi/ui/timeline.py
index 8e65129..cf3ee94 100644
--- a/pitivi/ui/timeline.py
+++ b/pitivi/ui/timeline.py
@@ -25,7 +25,6 @@ Timeline widgets for the complex view
import gtk
-from pitivi.log.loggable import Loggable
import ruler
import dnd
import gst
@@ -33,17 +32,24 @@ import gobject
import ges
from gettext import gettext as _
+
+from zoominterface import Zoomable
+from pitivi.check import soft_deps
+from pitivi.log.loggable import Loggable
from timelinecanvas import TimelineCanvas
from timelinecontrols import TimelineControls
-from zoominterface import Zoomable
-from pitivi.ui.common import TRACK_SPACING, LAYER_HEIGHT_EXPANDED, LAYER_SPACING
+from pitivi.effects import AUDIO_EFFECT, VIDEO_EFFECT
from pitivi.timeline.timeline import MoveContext, SELECT
-from pitivi.ui.filelisterrordialog import FileListErrorDialog
+
from pitivi.ui.common import SPACING
-from pitivi.ui.alignmentprogress import AlignmentProgressDialog
+from pitivi.ui.track import track_is_type
from pitivi.ui.depsmanager import DepsManager
-#from pitivi.timeline.align import AutoAligner
-from pitivi.check import soft_deps
+from pitivi.ui.filelisterrordialog import FileListErrorDialog
+from pitivi.ui.alignmentprogress import AlignmentProgressDialog
+from pitivi.ui.common import TRACK_SPACING, LAYER_HEIGHT_EXPANDED, LAYER_SPACING
+
+# FIXME GES Port regression
+# from pitivi.timeline.align import AutoAligner
DND_EFFECT_LIST = [[dnd.VIDEO_EFFECT_TUPLE[0], dnd.EFFECT_TUPLE[0]],\
[dnd.AUDIO_EFFECT_TUPLE[0], dnd.EFFECT_TUPLE[0]]]
@@ -440,20 +446,40 @@ class Timeline(gtk.Table, Loggable, Zoomable):
return True
elif context.targets in DND_EFFECT_LIST:
- if not self.timeline.timeline_objects:
+ if self._duration == 0:
return False
+
factory = self._factories[0]
- timeline_objs = self._getTimelineObjectUnderMouse(x, y, factory.getInputStreams()[0])
+ timeline_objs = self._getTimelineObjectUnderMouse(x, y)
if timeline_objs:
- self.app.action_log.begin("add effect")
- self.timeline.addEffectFactoryOnObject(factory,
- timeline_objects=timeline_objs)
- self.app.action_log.commit()
- self._factories = None
- self.app.current.seeker.seek(self._position)
- context.drop_finish(True, timestamp)
+ # FIXME make a util function to add effects instead of copy/pasting it
+ # from cliproperties
+ bin_desc = factory.effectname
+ media_type = self.app.effects.getFactoryFromName(bin_desc).media_type
+
+ # Trying to apply effect only on the first object of the selection
+ tlobj = timeline_objs[0]
+
+ # Checking that this effect can be applied on this track object
+ # Which means, it has the corresponding media_type
+ for tckobj in tlobj.get_track_objects():
+ track = tckobj.get_track()
+ if track_is_type(track, 'GES_TRACK_TYPE_AUDIO') and \
+ media_type == AUDIO_EFFECT or \
+ track_is_type(track, 'GES_TRACK_TYPE_VIDEO') and \
+ media_type == VIDEO_EFFECT:
+ #Actually add the effect
+ self.app.action_log.begin("add effect")
+ effect = ges.TrackParseLaunchEffect(bin_desc)
+ tlobj.add_track_object(effect)
+ track.add_object(effect)
+ self.app.action_log.commit()
+ self._factories = None
+ self.app.current.seeker.seek(self._position)
+ context.drop_finish(True, timestamp)
- self.timeline.selection.setSelection(timeline_objs, SELECT)
+ self.timeline.selection.setSelection(timeline_objs, SELECT)
+ break
return True
@@ -479,8 +505,7 @@ class Timeline(gtk.Table, Loggable, Zoomable):
def _dragDataReceivedCb(self, unused_layout, context, x, y,
selection, targetType, timestamp):
self.app.projectManager.current.timeline.enable_update(False)
- self.log("SimpleTimeline, targetType:%d, selection.data:%s" %
- (targetType, selection.data))
+ self.log("targetType:%d, selection.data:%s" % (targetType, selection.data))
self.selection_data = selection.data
if targetType not in [dnd.TYPE_PITIVI_FILESOURCE,
@@ -492,21 +517,20 @@ class Timeline(gtk.Table, Loggable, Zoomable):
uris = selection.data.split("\n")
self._factories = [self._project.sources.getUri(uri) for uri in uris]
else:
- if not self.timeline.timeline_objects:
+ if not self._duration:
return False
self._factories = [self.app.effects.getFactoryFromName(selection.data)]
context.drag_status(gtk.gdk.ACTION_COPY, timestamp)
return True
- def _getTimelineObjectUnderMouse(self, x, y, stream):
+ def _getTimelineObjectUnderMouse(self, x, y):
timeline_objs = []
items_in_area = self._canvas.getItemsInArea(x, y - 15, x + 1, y - 30)
- tracks = [obj for obj in items_in_area[0]]
+
track_objects = [obj for obj in items_in_area[1]]
for track_object in track_objects:
- if (type(stream) == type(track_object.stream)):
- timeline_objs.append(track_object.timeline_object)
+ timeline_objs.append(track_object.get_timeline_object())
return timeline_objs
diff --git a/pitivi/ui/track.py b/pitivi/ui/track.py
index c316e6f..1c148a0 100644
--- a/pitivi/ui/track.py
+++ b/pitivi/ui/track.py
@@ -32,6 +32,13 @@ from pitivi.ui.common import LAYER_HEIGHT_EXPANDED,\
LAYER_HEIGHT_COLLAPSED, LAYER_SPACING
+def track_is_type(track, type_str):
+ """
+ Simple utility function to check the type of a ges.Track
+ """
+ return track.props.track_type.first_value_name == type_str
+
+
class Transition(goocanvas.Rect, Zoomable):
def __init__(self, transition):
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]