[pitivi] elements: Create method out of duplicated code
- From: Alexandru Băluț <alexbalut src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pitivi] elements: Create method out of duplicated code
- Date: Sun, 21 Feb 2016 23:18:54 +0000 (UTC)
commit c8e245988a217fc73ab3867079464427af49c854
Author: Alexandru Băluț <alexandru balut gmail com>
Date: Thu Feb 11 16:56:10 2016 +0100
elements: Create method out of duplicated code
Differential Revision: https://phabricator.freedesktop.org/D766
pitivi/timeline/elements.py | 35 +++++++++++++++++++----------------
pitivi/utils/widgets.py | 2 +-
2 files changed, 20 insertions(+), 17 deletions(-)
---
diff --git a/pitivi/timeline/elements.py b/pitivi/timeline/elements.py
index 64e200c..1622289 100644
--- a/pitivi/timeline/elements.py
+++ b/pitivi/timeline/elements.py
@@ -373,9 +373,7 @@ class TimelineElement(Gtk.Layout, timelineUtils.Zoomable, Loggable):
# We set up the default mixing property right here, if a binding was
# already set (when loading a project), it will be added later
# and override that one.
- self.__controlledProperty = self._getDefaultMixingProperty()
- if self.__controlledProperty:
- self.__createControlBinding(self._ges_elem)
+ self.showDefaultKeyframes()
def release(self):
if self.__previewer:
@@ -398,15 +396,17 @@ class TimelineElement(Gtk.Layout, timelineUtils.Zoomable, Loggable):
self.__width = width
self.__height = height
- def showKeyframes(self, effect, prop):
- self.__controlledProperty = prop
- self.__createControlBinding(effect)
+ def showKeyframes(self, ges_elem, prop):
+ self.__setKeyframes(ges_elem, prop)
- def hideKeyframes(self):
+ def showDefaultKeyframes(self):
+ self.__setKeyframes(self._ges_elem, self._getDefaultMixingProperty())
+
+ def __setKeyframes(self, ges_elem, prop):
self.__removeKeyframes()
- self.__controlledProperty = self._getDefaultMixingProperty()
+ self.__controlledProperty = prop
if self.__controlledProperty:
- self.__createControlBinding(self._ges_elem)
+ self.__createControlBinding(ges_elem)
def __curveEnterCb(self, unused_keyframe_curve):
self.emit("curve-enter")
@@ -415,14 +415,17 @@ class TimelineElement(Gtk.Layout, timelineUtils.Zoomable, Loggable):
self.emit("curve-leave")
def __removeKeyframes(self):
- if self.__keyframeCurve:
- self.__keyframeCurve.disconnect_by_func(
- self.__keyframePlotChangedCb)
- self.__keyframeCurve.disconnect_by_func(self.__curveEnterCb)
- self.__keyframeCurve.disconnect_by_func(self.__curveLeaveCb)
- self.remove(self.__keyframeCurve)
+ if not self.__keyframeCurve:
+ # Nothing to remove.
+ return
+
+ self.__keyframeCurve.disconnect_by_func(
+ self.__keyframePlotChangedCb)
+ self.__keyframeCurve.disconnect_by_func(self.__curveEnterCb)
+ self.__keyframeCurve.disconnect_by_func(self.__curveLeaveCb)
+ self.remove(self.__keyframeCurve)
- self.__keyframeCurve.release()
+ self.__keyframeCurve.release()
self.__keyframeCurve = None
# Private methods
diff --git a/pitivi/utils/widgets.py b/pitivi/utils/widgets.py
index 23e8b15..761e302 100644
--- a/pitivi/utils/widgets.py
+++ b/pitivi/utils/widgets.py
@@ -807,7 +807,7 @@ class GstElementSettingsWidget(Gtk.Box, Loggable):
binding = self.element.get_control_binding(prop.name)
self.bindings[widget] = binding
elif hasattr(track_element, "ui_element") and track_type == track_element.get_track_type():
- track_element.ui_element.hideKeyframes()
+ track_element.ui_element.showDefaultKeyframes()
def _defaultBtnClickedCb(self, unused_button, widget):
try:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]