[pitivi] Add a show keyframes button which calls a show Keyframes method on the relevant timeline element



commit 5b68d2aef0999188e6fb44da60ac2204cefe1365
Author: Mathieu Duponchelle <mathieu duponchelle epitech eu>
Date:   Mon Apr 22 18:05:15 2013 +0200

    Add a show keyframes button which calls a show Keyframes method on the relevant timeline element

 pitivi/clipproperties.py    |   18 ++++++++++++++++++
 pitivi/timeline/elements.py |   17 ++++++++++++++++-
 pitivi/utils/widgets.py     |   24 ++++++++++++++++++++++--
 3 files changed, 56 insertions(+), 3 deletions(-)
---
diff --git a/pitivi/clipproperties.py b/pitivi/clipproperties.py
index 1cf400c..d8f7b2a 100644
--- a/pitivi/clipproperties.py
+++ b/pitivi/clipproperties.py
@@ -167,6 +167,12 @@ class EffectProperties(Gtk.Expander, Loggable):
         removeEffectButton.set_is_important(True)
         self._toolbar.insert(removeEffectButton, 0)
 
+        showKeyframesButton = Gtk.ToolButton()
+        showKeyframesButton.set_icon_name("document-properties-symbolic")
+        showKeyframesButton.set_label(_("Show keyframes"))
+        showKeyframesButton.set_is_important(True)
+        self._toolbar.insert(showKeyframesButton, 0)
+
         # Treeview to display a list of effects (checkbox, effect type and name)
         self.treeview_scrollwin = Gtk.ScrolledWindow()
         self.treeview_scrollwin.set_policy(Gtk.PolicyType.NEVER,
@@ -238,6 +244,7 @@ class EffectProperties(Gtk.Expander, Loggable):
         self.treeview.connect("query-tooltip", self._treeViewQueryTooltipCb)
         self._vcontent.connect("notify", self._vcontentNotifyCb)
         removeEffectButton.connect("clicked", self._removeEffectClicked)
+        showKeyframesButton.connect("clicked", self._showKeyframesClicked)
         self.app.connect("new-project-loaded", self._newProjectLoadedCb)
         self.connect('notify::expanded', self._expandedCb)
         self.connected = False
@@ -310,6 +317,17 @@ class EffectProperties(Gtk.Expander, Loggable):
                                                COL_TRACK_EFFECT)
             self._removeEffect(effect)
 
+    def _showKeyframesClicked(self, event):
+        if not self.clips:
+            return
+        effect = self.storemodel.get_value(self.selection.get_selected()[1],
+                                           COL_TRACK_EFFECT)
+        track_type = effect.get_track_type()
+        for track_element in effect.get_parent().get_children():
+            print track_element
+            if hasattr(track_element, "ui_element") and track_type == track_element.get_track_type():
+                track_element.ui_element.showKeyframes()
+
     def _removeEffect(self, effect):
         self.app.action_log.begin("remove effect")
         self._cleanCache(effect)
diff --git a/pitivi/timeline/elements.py b/pitivi/timeline/elements.py
index dcb2f8d..7a3621c 100644
--- a/pitivi/timeline/elements.py
+++ b/pitivi/timeline/elements.py
@@ -29,7 +29,7 @@ is prefixed with a little b, example : bTimeline
 import os
 import cairo
 
-from gi.repository import Clutter, Cogl, GES, Gdk
+from gi.repository import Clutter, Cogl, GES, Gdk, GstController
 from pitivi.utils.timeline import Zoomable, EditingContext, Selection, SELECT, UNSELECT, Selected
 from previewers import VideoPreviewer, BORDER_WIDTH
 
@@ -341,6 +341,7 @@ class TimelineElement(Clutter.Actor, Zoomable):
         self.timeline = timeline
         self.bElement = bElement
         self.bElement.selected = Selected()
+        self.bElement.ui_element = self
         self.track_type = self.bElement.get_track_type()  # This won't change
         self.isDragged = False
         size = self.bElement.get_duration()
@@ -408,6 +409,9 @@ class TimelineElement(Clutter.Actor, Zoomable):
             brother.isDragged = dragged
         self.isDragged = dragged
 
+    def showKeyframes(self, propname):
+        pass
+
     # Internal API
 
     def _createGhostclip(self):
@@ -521,6 +525,17 @@ class URISourceElement(TimelineElement):
         self.rightHandle.hide()
         self.leftHandle.hide()
 
+    def showKeyframes(self, effect, propname):
+        binding = self.bElement.get_control_binding(propname.name)
+        if not binding:
+            source = GstController.InterpolationControlSource()
+            if not (effect.set_control_source(source, propname.name, "direct")):
+                print "There was something like a problem captain"
+                return
+            binding = effect.get_control_binding(propname.name)
+        print binding
+        print propname.default_value
+
     # private API
 
     def _createGhostclip(self):
diff --git a/pitivi/utils/widgets.py b/pitivi/utils/widgets.py
index e1488c5..793104e 100644
--- a/pitivi/utils/widgets.py
+++ b/pitivi/utils/widgets.py
@@ -855,9 +855,9 @@ class GstElementSettingsWidget(Gtk.VBox, Loggable):
             return
 
         if default_btn:
-            table = Gtk.Table(rows=len(props), columns=3)
+            table = Gtk.Table(rows=len(props), columns=4)
         else:
-            table = Gtk.Table(rows=len(props), columns=2)
+            table = Gtk.Table(rows=len(props), columns=3)
 
         table.set_row_spacings(SPACING)
         table.set_col_spacings(SPACING)
@@ -902,6 +902,9 @@ class GstElementSettingsWidget(Gtk.VBox, Loggable):
                 button = self._getResetToDefaultValueButton(prop, widget)
                 table.attach(button, 2, 3, y, y + 1, xoptions=Gtk.AttachOptions.FILL, 
yoptions=Gtk.AttachOptions.FILL)
                 self.buttons[button] = widget
+            button = self._getShowKeyframesButton(prop)
+            table.attach(button, 3, 4, y, y + 1, xoptions=Gtk.AttachOptions.FILL, 
yoptions=Gtk.AttachOptions.FILL)
+
             self.element.connect('notify::' + prop.name, self._propertyChangedCb, widget)
 
             y += 1
@@ -912,6 +915,16 @@ class GstElementSettingsWidget(Gtk.VBox, Loggable):
     def _propertyChangedCb(self, element, pspec, widget):
         widget.setWidgetValue(self.element.get_property(pspec.name))
 
+    def _getShowKeyframesButton(self, prop):
+        icon = Gtk.Image()
+        icon.set_from_icon_name("document-properties-symbolic", Gtk.IconSize.MENU)
+        button = Gtk.Button()
+        button.add(icon)
+        button.set_tooltip_text(_("Show keyframes for this value"))
+        button.set_relief(Gtk.ReliefStyle.NONE)
+        button.connect('clicked', self._showKeyframesClickedCb, prop)
+        return button
+
     def _getResetToDefaultValueButton(self, prop, widget):
         icon = Gtk.Image()
         icon.set_from_icon_name("edit-clear-all-symbolic", Gtk.IconSize.MENU)
@@ -922,6 +935,13 @@ class GstElementSettingsWidget(Gtk.VBox, Loggable):
         button.connect('clicked', self._defaultBtnClickedCb, widget)
         return button
 
+    def _showKeyframesClickedCb(self, button, prop):
+        effect = self.element
+        track_type = effect.get_track_type()
+        for track_element in effect.get_parent().get_children():
+            if hasattr(track_element, "ui_element") and track_type == track_element.get_track_type():
+                track_element.ui_element.showKeyframes(effect, prop)
+
     def _defaultBtnClickedCb(self, button, widget):
         widget.setWidgetToDefault()
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]