[pitivi] preset: Reuse the update preset values from widgets logic when creating a new preset
- From: Thibault Saunier <tsaunier src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pitivi] preset: Reuse the update preset values from widgets logic when creating a new preset
- Date: Wed, 25 Nov 2015 09:56:08 +0000 (UTC)
commit f1cd762bd7fada5741b9d1143c3bb2db2da3f2e7
Author: Alexandru Băluț <alexandru balut gmail com>
Date: Sun Oct 11 00:43:01 2015 +0200
preset: Reuse the update preset values from widgets logic when creating a new preset
Differential Revision: https://phabricator.freedesktop.org/D370
Reviewed-by: Thibault Saunier <tsaunier gnome org>
pitivi/preset.py | 14 +++++++++-----
pitivi/project.py | 14 ++------------
2 files changed, 11 insertions(+), 17 deletions(-)
---
diff --git a/pitivi/preset.py b/pitivi/preset.py
index 7bceed6..bc21c3e 100644
--- a/pitivi/preset.py
+++ b/pitivi/preset.py
@@ -146,7 +146,7 @@ class PresetManager(Loggable):
"""Get a unique name for a new preset."""
return self.getUniqueName(_("New preset"), _("New preset %d"))
- def createPreset(self, name, values, volatile=False):
+ def createPreset(self, name, values=None, volatile=False):
"""Create a new preset.
@param name: The name of the new preset, must be unique.
@@ -158,9 +158,13 @@ class PresetManager(Loggable):
"""
if self.hasPreset(name):
raise DuplicatePresetNameException(name)
+ if not values:
+ values = {}
+ self._updatePresetValues(values)
if volatile:
values["volatile"] = True
self._addPreset(name, values)
+ self.cur_preset = name
def _addPreset(self, name, values):
"""Add a preset, overwriting the preset with the same name if it exists.
@@ -254,12 +258,12 @@ class PresetManager(Loggable):
"""Update the current preset values from the widgets and save it."""
if new_name:
self._renameCurrentPreset(new_name)
- self._updatePreset()
+ values = self.presets[self.cur_preset]
+ self._updatePresetValues(values)
self.savePreset(self.cur_preset)
- def _updatePreset(self):
- """Copy the values from the widgets to the preset."""
- values = self.presets[self.cur_preset]
+ def _updatePresetValues(self, values):
+ """Copy the values from the widgets to the specified values dict."""
for field, (setter, getter) in self.widget_map.items():
values[field] = getter()
diff --git a/pitivi/project.py b/pitivi/project.py
index cfc00e6..88d30cb 100644
--- a/pitivi/project.py
+++ b/pitivi/project.py
@@ -1708,23 +1708,13 @@ class ProjectSettingsDialog():
def _addAudioPresetCb(self, unused_action, unused_param):
preset_name = self.audio_presets.getNewPresetName()
- preset = {
- "channels": get_combo_value(self.channels_combo),
- "sample-rate": get_combo_value(self.sample_rate_combo),
- }
- self.audio_presets.createPreset(preset_name, preset)
+ self.audio_presets.createPreset(preset_name)
self.audio_presets_combo.set_active_id(preset_name)
self._updateAudioPresetMenu()
def _addVideoPresetCb(self, unused_action, unused_param):
preset_name = self.video_presets.getNewPresetName()
- preset = {
- "width": int(self.width_spinbutton.get_value()),
- "height": int(self.height_spinbutton.get_value()),
- "frame-rate": self.frame_rate_fraction_widget.getWidgetValue(),
- "par": self.par_fraction_widget.getWidgetValue(),
- }
- self.video_presets.createPreset(preset_name, preset)
+ self.video_presets.createPreset(preset_name)
self.video_presets_combo.set_active_id(preset_name)
self._updateVideoPresetMenu()
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]