[pitivi/gtktimeline] project: Fix w/h UI update when a preset is selected and link is checked
- From: Thibault Saunier <tsaunier src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pitivi/gtktimeline] project: Fix w/h UI update when a preset is selected and link is checked
- Date: Fri, 5 Jun 2015 03:59:54 +0000 (UTC)
commit 7713c2d1db13734728e5d64d47b6af4dd07e919f
Author: Alexandru Băluț <alexandru balut gmail com>
Date: Thu May 7 08:27:00 2015 +0200
project: Fix w/h UI update when a preset is selected and link is checked
The bug manifests when the width and height are linked and you select
a different preset, then right away the height is updated based on the
preset's width and the *old* w/h fraction.
pitivi/preset.py | 26 ++++++++++++++------------
pitivi/project.py | 16 +++++++++-------
2 files changed, 23 insertions(+), 19 deletions(-)
---
diff --git a/pitivi/preset.py b/pitivi/preset.py
index f1ff147..306bd43 100644
--- a/pitivi/preset.py
+++ b/pitivi/preset.py
@@ -67,7 +67,7 @@ class PresetManager(object):
self.ordered = Gtk.ListStore(str, object)
self.cur_preset = None
# Whether to ignore the updateValue calls.
- self._ignore_update_requests = False
+ self.ignore_update_requests = False
self.system = system.getSystem()
def loadAll(self):
@@ -180,7 +180,7 @@ class PresetManager(object):
def updateValue(self, name, value):
"""Update a value in the current preset, if any."""
- if self._ignore_update_requests:
+ if self.ignore_update_requests:
# This is caused by restorePreset, nothing to do.
return
if self.cur_preset:
@@ -196,20 +196,22 @@ class PresetManager(object):
@param preset: The name of the preset to be selected.
@type preset: str
"""
- self._ignore_update_requests = True
if preset is None:
self.cur_preset = None
return
- elif preset not in self.presets:
+ if preset not in self.presets:
return
- values = self.presets[preset]
- self.cur_preset = preset
- for field, (setter, getter) in self.widget_map.items():
- if values[field] != 0:
- setter(values[field])
- else:
- setter(self.presets[_("No preset")][field])
- self._ignore_update_requests = False
+ self.ignore_update_requests = True
+ try:
+ values = self.presets[preset]
+ self.cur_preset = preset
+ for field, (setter, getter) in self.widget_map.items():
+ if values[field] != 0:
+ setter(values[field])
+ else:
+ setter(self.presets[_("No preset")][field])
+ finally:
+ self.ignore_update_requests = False
def saveCurrentPreset(self):
"""Update the current preset values from the widgets and save it."""
diff --git a/pitivi/project.py b/pitivi/project.py
index 3cb29be..aa9ecc4 100644
--- a/pitivi/project.py
+++ b/pitivi/project.py
@@ -1631,6 +1631,7 @@ class ProjectSettingsDialog():
else:
preset = None
mgr.restorePreset(preset)
+ self._updateSar()
update_preset_buttons_func()
self._hidePresetManagerError(mgr)
@@ -1660,7 +1661,7 @@ class ProjectSettingsDialog():
infobar.hide()
def constrained(self):
- return self.constrain_sar_button.props.active
+ return self.constrain_sar_button.props.active and not self.video_presets.ignore_update_requests
def _updateFraction(self, unused, fraction, combo):
fraction.setWidgetValue(get_combo_value(combo))
@@ -1673,9 +1674,11 @@ class ProjectSettingsDialog():
height = int(self.height_spinbutton.get_value())
return Gst.Fraction(width, height)
- def _constrainSarButtonToggledCb(self, button):
- if button.props.active:
- self.sar = self.getSAR()
+ def _constrainSarButtonToggledCb(self, unused_button):
+ self._updateSar()
+
+ def _updateSar(self):
+ self.sar = self.getSAR()
def _selectDarRadiobuttonToggledCb(self, button):
state = button.props.active
@@ -1768,7 +1771,7 @@ class ProjectSettingsDialog():
def updateHeight(self):
width = int(self.width_spinbutton.get_value())
- self.height_spinbutton.set_value(width * (1 / self.sar))
+ self.height_spinbutton.set_value(width / self.sar)
def updateDarFromPar(self):
par = self.par_fraction_widget.getWidgetValue()
@@ -1778,7 +1781,7 @@ class ProjectSettingsDialog():
def updateParFromDar(self):
dar = self.dar_fraction_widget.getWidgetValue()
sar = self.getSAR()
- self.par_fraction_widget.setWidgetValue(dar * (1 / sar))
+ self.par_fraction_widget.setWidgetValue(dar / sar)
def updateDarFromCombo(self):
self.dar_fraction_widget.setWidgetValue(
@@ -1797,7 +1800,6 @@ class ProjectSettingsDialog():
self.par_combo, self.par_fraction_widget.getWidgetValue())
def updateUI(self):
-
self.width_spinbutton.set_value(self.project.videowidth)
self.height_spinbutton.set_value(self.project.videoheight)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]