[gnome-subtitles] Use gconf keys to store default values for time/frames increments in the spin buttons (ex: subtitle
- From: Pedro Daniel da Rocha Melo e Castro <pcastro src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-subtitles] Use gconf keys to store default values for time/frames increments in the spin buttons (ex: subtitle
- Date: Sun, 5 Jun 2011 18:14:09 +0000 (UTC)
commit e39e0474a3ae3a2995b4a0cba1e333b194c6f222
Author: Pedro Castro <mail pedrocastro org>
Date: Sun Jun 5 19:08:21 2011 +0100
Use gconf keys to store default values for time/frames increments in the spin buttons (ex: subtitle start, end, duration)
data/gnome-subtitles.schemas | 22 ++++++++++++
src/GnomeSubtitles/Core/Config.cs | 36 ++++++++++++++++++-
src/GnomeSubtitles/Core/Util.cs | 6 ++--
.../Ui/Edit/SubtitleEditSpinButtons.cs | 8 ++---
4 files changed, 62 insertions(+), 10 deletions(-)
---
diff --git a/data/gnome-subtitles.schemas b/data/gnome-subtitles.schemas
index ee10ecf..3dd9eb0 100644
--- a/data/gnome-subtitles.schemas
+++ b/data/gnome-subtitles.schemas
@@ -244,5 +244,27 @@
<long>Time interval, in seconds, to automatically backup files. A minimum of 30 seconds is recommended.</long>
</locale>
</schema>
+ <schema>
+ <key>/schemas/apps/gnome-subtitles/preferences/timings/time_step</key>
+ <applyto>/apps/gnome-subtitles/preferences/timings/time_step</applyto>
+ <owner>gnome-subtitles</owner>
+ <type>int</type>
+ <default>100</default>
+ <locale name="C">
+ <short>Time step increment</short>
+ <long>Time, in milliseconds, to add or subtract when adjusting times in spinbutton controls (e.g., start, end and duration).</long>
+ </locale>
+ </schema>
+ <schema>
+ <key>/schemas/apps/gnome-subtitles/preferences/timings/frames_step</key>
+ <applyto>/apps/gnome-subtitles/preferences/timings/frames_step</applyto>
+ <owner>gnome-subtitles</owner>
+ <type>int</type>
+ <default>2</default>
+ <locale name="C">
+ <short>Frames step increment</short>
+ <long>Frames to add or subtract when adjusting frames in spinbutton controls (e.g., start, end and duration).</long>
+ </locale>
+ </schema>
</schemalist>
</gconfschemafile>
diff --git a/src/GnomeSubtitles/Core/Config.cs b/src/GnomeSubtitles/Core/Config.cs
index e1a514e..89deff2 100644
--- a/src/GnomeSubtitles/Core/Config.cs
+++ b/src/GnomeSubtitles/Core/Config.cs
@@ -1,6 +1,6 @@
/*
* This file is part of Gnome Subtitles.
- * Copyright (C) 2007-2010 Pedro Castro
+ * Copyright (C) 2007-2011 Pedro Castro
*
* Gnome Subtitles is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -47,6 +47,7 @@ public class Config {
private const string keyPrefsDefaults = keyPrefs + "defaults/";
private const string keyPrefsTranslation = keyPrefs + "translation/";
private const string keyPrefsBackup = keyPrefs + "backup/";
+ private const string keyPrefsTimings = keyPrefs + "timings/";
/* Constant key strings */
private const string keyPrefsEncodingsShownInMenu = keyPrefsEncodings + "shown_in_menu";
@@ -71,11 +72,15 @@ public class Config {
private const string keyPrefsDefaultsFileSaveNewline = keyPrefsDefaults + "file_save_newline";
private const string keyPrefsBackupAutoBackup = keyPrefsBackup + "auto_backup";
private const string keyPrefsBackupBackupTime = keyPrefsBackup + "backup_time";
+ private const string keyPrefsTimingsTimeStep = keyPrefsTimings + "time_step";
+ private const string keyPrefsTimingsFramesStep = keyPrefsTimings + "frames_step";
/* Cached values */
private bool isValuePrefsVideoApplyReactionDelayCached = false;
private bool valuePrefsVideoApplyReactionDelay = false;
private int valuePrefsVideoReactionDelay = -1;
+ private int valuePrefsTimingsTimeStep = -1;
+ private int valuePrefsTimingsFramesStep = -1;
public Config () {
@@ -235,11 +240,38 @@ public class Config {
set { Set(keyPrefsBackupAutoBackup, value); }
}
- /* Backup time in seconds */
public int PrefsBackupBackupTime {
get { return GetInt(keyPrefsBackupBackupTime, 120, 30, true, 0, false); }
set { Set(keyPrefsBackupBackupTime, value); }
}
+
+ /* Time in milliseconds */
+ public int PrefsTimingsTimeStep {
+ get {
+ if (this.valuePrefsTimingsTimeStep == -1) {
+ this.valuePrefsTimingsTimeStep = GetInt(keyPrefsTimingsTimeStep, 100, 1, true, 0, false);
+ }
+ return this.valuePrefsTimingsTimeStep;
+ }
+ set {
+ Set(keyPrefsTimingsTimeStep, value);
+ this.valuePrefsTimingsTimeStep = value;
+ }
+ }
+
+ /* Time in milliseconds */
+ public int PrefsTimingsFramesStep {
+ get {
+ if (this.valuePrefsTimingsFramesStep == -1) {
+ this.valuePrefsTimingsFramesStep = GetInt(keyPrefsTimingsFramesStep, 2, 1, true, 0, false);
+ }
+ return this.valuePrefsTimingsFramesStep;
+ }
+ set {
+ Set(keyPrefsTimingsFramesStep, value);
+ this.valuePrefsTimingsFramesStep = value;
+ }
+ }
/* Private members */
diff --git a/src/GnomeSubtitles/Core/Util.cs b/src/GnomeSubtitles/Core/Util.cs
index fd7c35f..649d998 100644
--- a/src/GnomeSubtitles/Core/Util.cs
+++ b/src/GnomeSubtitles/Core/Util.cs
@@ -1,6 +1,6 @@
/*
* This file is part of Gnome Subtitles.
- * Copyright (C) 2006-2010 Pedro Castro
+ * Copyright (C) 2006-2011 Pedro Castro
*
* Gnome Subtitles is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -117,13 +117,13 @@ public class Util {
}
public static void SetSpinButtonAdjustment (SpinButton spinButton, TimeSpan upperLimit, bool canNegate) {
- spinButton.Adjustment.StepIncrement = 100; //milliseconds
+ spinButton.Adjustment.StepIncrement = Base.Config.PrefsTimingsTimeStep; //milliseconds
spinButton.Adjustment.Upper = (upperLimit != TimeSpan.Zero ? upperLimit.TotalMilliseconds : 86399999);
spinButton.Adjustment.Lower = (canNegate ? -spinButton.Adjustment.Upper : 0);
}
public static void SetSpinButtonAdjustment (SpinButton spinButton, int upperLimit, bool canNegate) {
- spinButton.Adjustment.StepIncrement = 1; //frame
+ spinButton.Adjustment.StepIncrement = Base.Config.PrefsTimingsFramesStep; //frames
spinButton.Adjustment.Upper = (upperLimit != 0 ? upperLimit : 3000000);
spinButton.Adjustment.Lower = (canNegate ? -spinButton.Adjustment.Upper : 0);
}
diff --git a/src/GnomeSubtitles/Ui/Edit/SubtitleEditSpinButtons.cs b/src/GnomeSubtitles/Ui/Edit/SubtitleEditSpinButtons.cs
index 91407b5..604a27e 100644
--- a/src/GnomeSubtitles/Ui/Edit/SubtitleEditSpinButtons.cs
+++ b/src/GnomeSubtitles/Ui/Edit/SubtitleEditSpinButtons.cs
@@ -1,6 +1,6 @@
/*
* This file is part of Gnome Subtitles.
- * Copyright (C) 2006-2010 Pedro Castro
+ * Copyright (C) 2006-2011 Pedro Castro
*
* Gnome Subtitles is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -35,9 +35,7 @@ public class SubtitleEditSpinButtons {
/* Constants */
private const int maxTime = 86399999; //milliseconds
- private const int timeStepIncrement = 100; //milliseconds
private const int maxFrames = 3000000;
- private const int framesStepIncrement = 1;
public SubtitleEditSpinButtons () {
@@ -102,7 +100,7 @@ public class SubtitleEditSpinButtons {
private void SetTimesMode (SpinButton spinButton, bool allowNegatives) {
Util.SetSpinButtonTimingMode(spinButton, TimingMode.Times);
- spinButton.Adjustment.StepIncrement = timeStepIncrement;
+ spinButton.Adjustment.StepIncrement = Base.Config.PrefsTimingsTimeStep;
spinButton.Adjustment.Upper = maxTime;
spinButton.Adjustment.Lower = (allowNegatives ? -maxTime : 0);
}
@@ -111,7 +109,7 @@ public class SubtitleEditSpinButtons {
private void SetFramesMode (SpinButton spinButton, bool allowNegatives) {
Util.SetSpinButtonTimingMode(spinButton, TimingMode.Frames);
- spinButton.Adjustment.StepIncrement = framesStepIncrement;
+ spinButton.Adjustment.StepIncrement = Base.Config.PrefsTimingsFramesStep;
spinButton.Adjustment.Upper = maxFrames;
spinButton.Adjustment.Lower = (allowNegatives ? -maxFrames : 0);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]