[pitivi: 91/94] Fix the state of Save and Remove buttons when renaming presets
- From: Thibault Saunier <tsaunier src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pitivi: 91/94] Fix the state of Save and Remove buttons when renaming presets
- Date: Sun, 11 Sep 2011 16:20:05 +0000 (UTC)
commit 280a0b02e76f4341969217f618f2c4ace4a4e2b3
Author: Jean-FranÃois Fortin Tam <nekohayo gmail com>
Date: Sat Sep 10 18:44:49 2011 -0400
Fix the state of Save and Remove buttons when renaming presets
pitivi/ui/encodingdialog.py | 1 +
pitivi/ui/preset.py | 17 ++++++++++++++---
2 files changed, 15 insertions(+), 3 deletions(-)
---
diff --git a/pitivi/ui/encodingdialog.py b/pitivi/ui/encodingdialog.py
index da8c66e..1a2b3fa 100644
--- a/pitivi/ui/encodingdialog.py
+++ b/pitivi/ui/encodingdialog.py
@@ -369,6 +369,7 @@ class EncodingDialog(Renderer, Loggable):
"""Handle the renaming of a preset."""
try:
mgr.renamePreset(path, new_text)
+ self._updateRenderPresetButtons()
except DuplicatePresetNameException:
error_markup = _('"%s" already exists.') % new_text
self._showPresetManagerError(mgr, error_markup)
diff --git a/pitivi/ui/preset.py b/pitivi/ui/preset.py
index a892722..5d61c80 100644
--- a/pitivi/ui/preset.py
+++ b/pitivi/ui/preset.py
@@ -149,9 +149,18 @@ class PresetManager(object):
self.hasPreset(new_name)):
raise DuplicatePresetNameException()
self.ordered[path][0] = new_name
- self.presets[new_name] = self.presets.pop(old_name)
- if self.cur_preset == old_name:
- self.cur_preset = new_name
+ self.presets[new_name] = self.presets[old_name]
+ if "filepath" in self.presets[old_name]:
+ # If the previous preset had already been saved,
+ # delete the file and pop it from the list
+ self.removePreset(old_name)
+ else:
+ # We're renaming an unsaved preset, so just pop it from the list
+ self.presets.pop(old_name)
+ new_filepath = os.path.join(self.user_path, new_name + ".json")
+ self.presets[new_name]["filepath"] = new_filepath
+ self.cur_preset = new_name
+ self.savePreset()
def hasPreset(self, name):
name = name.lower()
@@ -272,6 +281,8 @@ class PresetManager(object):
def isRemoveButtonSensitive(self):
"""Check if Remove buttons should be sensitive"""
if not self.cur_preset or self.cur_preset == "No preset":
+ return False
+ else:
try:
full_path = self.presets[self.cur_preset]["filepath"]
(dir, name) = os.path.split(full_path)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]