[pitivi] project: Update the restriction caps directly
- From: Alexandru Băluț <alexbalut src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pitivi] project: Update the restriction caps directly
- Date: Thu, 8 Feb 2018 07:29:31 +0000 (UTC)
commit c2be2a93e847c91920e42ec7b8a63be573c3fa09
Author: Alexandru Băluț <alexandru balut gmail com>
Date: Fri Jan 5 00:25:01 2018 +0100
project: Update the restriction caps directly
The project can update the restriction caps itself when its
width/height/framerate or audio rate/channels change.
Differential Revision: https://phabricator.freedesktop.org/D1932
pitivi/project.py | 39 ++++++++++++++++++++++++++-------------
pitivi/timeline/timeline.py | 3 ---
2 files changed, 26 insertions(+), 16 deletions(-)
---
diff --git a/pitivi/project.py b/pitivi/project.py
index 6713f17..2f29f9c 100644
--- a/pitivi/project.py
+++ b/pitivi/project.py
@@ -837,25 +837,38 @@ class Project(Loggable, GES.Project):
@staticmethod
def _set_restriction(profile, name, value):
- if profile.get_restriction()[0][name] != value and value:
- restriction = profile.get_restriction().copy_nth(0)
- restriction.set_value(name, value)
- profile.set_restriction(restriction)
- return True
+ """Sets a restriction on the specified profile.
- return False
+ Assumes the profile has a single restriction.
+
+ Args:
+ profile (GstPbutils.EncodingProfile): The profile to be updated.
+
+ Returns:
+ bool: Whether the profile actually changed.
+ """
+ caps = profile.get_restriction()
+ if caps[0][name] == value or not value:
+ return False
+
+ restriction = caps.copy_nth(0)
+ restriction.set_value(name, value)
+ profile.set_restriction(restriction)
+ return True
- def setVideoRestriction(self, name, value):
+ def _set_video_restriction(self, name, value):
res = Project._set_restriction(self.video_profile, name, value)
if res:
self.emit("video-size-changed")
self._has_default_video_settings = False
+ self.update_restriction_caps()
return res
- def __setAudioRestriction(self, name, value):
+ def _set_audio_restriction(self, name, value):
res = Project._set_restriction(self.audio_profile, name, value)
if res:
self._has_default_audio_settings = False
+ self.update_restriction_caps()
return res
@property
@@ -864,7 +877,7 @@ class Project(Loggable, GES.Project):
@videowidth.setter
def videowidth(self, value):
- if self.setVideoRestriction("width", int(value)):
+ if self._set_video_restriction("width", int(value)):
self._emit_change("width")
@property
@@ -873,7 +886,7 @@ class Project(Loggable, GES.Project):
@videoheight.setter
def videoheight(self, value):
- if self.setVideoRestriction("height", int(value)):
+ if self._set_video_restriction("height", int(value)):
self._emit_change("height")
@property
@@ -882,7 +895,7 @@ class Project(Loggable, GES.Project):
@videorate.setter
def videorate(self, value):
- if self.setVideoRestriction("framerate", value):
+ if self._set_video_restriction("framerate", value):
self._emit_change("videorate")
@property
@@ -891,7 +904,7 @@ class Project(Loggable, GES.Project):
@audiochannels.setter
def audiochannels(self, value):
- if self.__setAudioRestriction("channels", int(value)):
+ if self._set_audio_restriction("channels", int(value)):
self._emit_change("channels")
@property
@@ -903,7 +916,7 @@ class Project(Loggable, GES.Project):
@audiorate.setter
def audiorate(self, value):
- if self.__setAudioRestriction("rate", int(value)):
+ if self._set_audio_restriction("rate", int(value)):
self._emit_change("rate")
@property
diff --git a/pitivi/timeline/timeline.py b/pitivi/timeline/timeline.py
index a44c34b..a916413 100644
--- a/pitivi/timeline/timeline.py
+++ b/pitivi/timeline/timeline.py
@@ -1869,9 +1869,6 @@ class TimelineContainer(Gtk.Grid, Zoomable, Loggable):
if item == "videorate" or item is None:
self._update_ruler(project.videorate)
- if item in ["width", "height", "videorate", "rate", "channels"]:
- project.update_restriction_caps()
-
def _update_ruler(self, videorate):
self._framerate = videorate
self.ruler.setProjectFrameRate(self._framerate)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]