[pitivi] projectsettings: Activate the first matching preset, if any
- From: Thibault Saunier <tsaunier src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pitivi] projectsettings: Activate the first matching preset, if any
- Date: Wed, 25 Nov 2015 09:55:02 +0000 (UTC)
commit f2c27534c87b17792b8c2b18d5ccea099278897c
Author: Alexandru Băluț <alexandru balut gmail com>
Date: Wed May 20 04:15:01 2015 +0200
projectsettings: Activate the first matching preset, if any
Fixes https://phabricator.freedesktop.org/T2741
Differential Revision: https://phabricator.freedesktop.org/D357
Reviewed-by: Thibault Saunier <tsaunier gnome org>
pitivi/preset.py | 27 +++++++++++++++++++++++++++
pitivi/project.py | 35 ++++++++++++++++++++++++-----------
2 files changed, 51 insertions(+), 11 deletions(-)
---
diff --git a/pitivi/preset.py b/pitivi/preset.py
index ce5d048..dc90196 100644
--- a/pitivi/preset.py
+++ b/pitivi/preset.py
@@ -303,6 +303,21 @@ class PresetManager(object):
"""
raise NotImplementedError()
+ def _projectToPreset(self, project):
+ raise NotImplementedError()
+
+ def matchingPreset(self, project):
+ query = self._projectToPreset(project)
+ for name, preset in self.presets.items():
+ matches = True
+ for key, value in query.items():
+ if not value == preset.get(key):
+ matches = False
+ break
+ if matches:
+ return name
+ return None
+
class VideoPresetManager(PresetManager):
@@ -346,6 +361,13 @@ class VideoPresetManager(PresetManager):
}, indent=4)
fout.write(data)
+ def _projectToPreset(self, project):
+ return {
+ "width": project.videowidth,
+ "height": project.videoheight,
+ "frame-rate": project.videorate,
+ "par": project.videopar}
+
class AudioPresetManager(PresetManager):
@@ -375,6 +397,11 @@ class AudioPresetManager(PresetManager):
}, indent=4)
fout.write(data)
+ def _projectToPreset(self, project):
+ return {
+ "channels": project.audiochannels,
+ "sample-rate": project.audiorate}
+
class RenderPresetManager(PresetManager):
diff --git a/pitivi/project.py b/pitivi/project.py
index a216d5c..17801ad 100644
--- a/pitivi/project.py
+++ b/pitivi/project.py
@@ -1634,6 +1634,7 @@ class ProjectSettingsDialog():
mgr.loadAll()
model = mgr.getModel()
combo.set_model(model)
+ combo.set_id_column(0)
combo.set_entry_text_column(0)
combo.connect("changed", self._presetChangedCb, mgr, button)
@@ -1692,12 +1693,15 @@ class ProjectSettingsDialog():
def _updateSar(self):
self.sar = self.getSAR()
- def _selectDarRadiobuttonToggledCb(self, button):
- state = button.props.active
- self.dar_fraction_widget.set_sensitive(state)
- self.dar_combo.set_sensitive(state)
- self.par_fraction_widget.set_sensitive(not state)
- self.par_combo.set_sensitive(not state)
+ def _selectDarRadiobuttonToggledCb(self, unused_button):
+ self._updateDarParSensitivity()
+
+ def _updateDarParSensitivity(self):
+ dar_is_selected = self.darSelected()
+ self.dar_fraction_widget.set_sensitive(dar_is_selected)
+ self.dar_combo.set_sensitive(dar_is_selected)
+ self.par_fraction_widget.set_sensitive(not dar_is_selected)
+ self.par_combo.set_sensitive(not dar_is_selected)
@staticmethod
def _getUniquePresetName(mgr):
@@ -1800,20 +1804,29 @@ class ProjectSettingsDialog():
self.par_combo, self.par_fraction_widget.getWidgetValue())
def updateUI(self):
+ # Video
self.width_spinbutton.set_value(self.project.videowidth)
self.height_spinbutton.set_value(self.project.videoheight)
-
- # video
self.frame_rate_fraction_widget.setWidgetValue(self.project.videorate)
self.par_fraction_widget.setWidgetValue(self.project.videopar)
- # audio
+ if self.project.videopar == Gst.Fraction(1, 1):
+ self.select_par_radiobutton.props.active = True
+ self._updateDarParSensitivity()
+
+ matching_video_preset = self.video_presets.matchingPreset(self.project)
+ if matching_video_preset:
+ self.video_presets_combo.set_active_id(matching_video_preset)
+
+ # Audio
set_combo_value(self.channels_combo, self.project.audiochannels)
set_combo_value(self.sample_rate_combo, self.project.audiorate)
- self._selectDarRadiobuttonToggledCb(self.select_dar_radiobutton)
+ matching_audio_preset = self.audio_presets.matchingPreset(self.project)
+ if matching_audio_preset:
+ self.audio_presets_combo.set_active_id(matching_audio_preset)
- # metadata
+ # Metadata
self.title_entry.set_text(self.project.name)
self.author_entry.set_text(self.project.author)
if self.project.year:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]