[gnome-subtitles] Don't seek the video to the start of a selection on a selection change by default. For now, seek in



commit 921fb3936b7a0ec66074310683b9158a25b37ccc
Author: Pedro Castro <mail pedrocastro org>
Date:   Mon Jun 6 23:33:11 2011 +0100

    Don't seek the video to the start of a selection on a selection change by default. For now, seek in the following conditions: a) setting subtitle start or end times; b) shifting.

 .../Core/Command/ChangeTimingCommand.cs            |   23 ++++++++++++-------
 .../Core/Command/VideoSetSubtitleTimingCommand.cs  |   10 ++++----
 .../Ui/Edit/SubtitleEditSpinButtons.cs             |   12 +++++-----
 3 files changed, 25 insertions(+), 20 deletions(-)
---
diff --git a/src/GnomeSubtitles/Core/Command/ChangeTimingCommand.cs b/src/GnomeSubtitles/Core/Command/ChangeTimingCommand.cs
index 633c19d..2e4d7ee 100644
--- a/src/GnomeSubtitles/Core/Command/ChangeTimingCommand.cs
+++ b/src/GnomeSubtitles/Core/Command/ChangeTimingCommand.cs
@@ -26,18 +26,21 @@ namespace GnomeSubtitles.Core.Command {
 public abstract class ChangeTimingCommand : FixedSingleSelectionCommand {
 	private TimeSpan storedTime;
 	private int storedFrames = -1;
+	private bool seekAfterChange = false; //FIXME put this in upper classes
 	
 	/* Protected variables */
 	protected Subtitle subtitle = null;
 	
-	public ChangeTimingCommand (int frames, string description): base(description, true, true) {
+	public ChangeTimingCommand (int frames, string description, bool seekAfterChange): base(description, true, true) {
 		this.subtitle = Base.Document.Subtitles[Path];
 		this.storedFrames = frames;
+		this.seekAfterChange = seekAfterChange;
 	}
 	
-	public ChangeTimingCommand (TimeSpan time, string description): base(description, true, true) {
+	public ChangeTimingCommand (TimeSpan time, string description, bool seekAfterChange): base(description, true, true) {
 		this.subtitle = Base.Document.Subtitles[Path];
 		this.storedTime = time;
+		this.seekAfterChange = seekAfterChange;
 	}
 
 	public override bool CanGroupWith (Command command) {
@@ -57,7 +60,9 @@ public abstract class ChangeTimingCommand : FixedSingleSelectionCommand {
 	}
 	
 	protected override void PostProcess () {
-		Base.Ui.Video.SeekToSelection(true);
+		if (this.seekAfterChange) {
+			Base.Ui.Video.SeekToSelection(true);
+		}
 	}
 
 	protected abstract TimeSpan GetPreviousTime ();
@@ -68,10 +73,10 @@ public abstract class ChangeTimingCommand : FixedSingleSelectionCommand {
 public class ChangeStartCommand : ChangeTimingCommand {
 	private static string description = Catalog.GetString("Editing From");
 
-	public ChangeStartCommand (int frames): base(frames, description) {
+	public ChangeStartCommand (int frames, bool seekAfterChange): base(frames, description, seekAfterChange) {
 	}
 	
-	public ChangeStartCommand (TimeSpan time): base(time, description) {
+	public ChangeStartCommand (TimeSpan time, bool seekAfterChange): base(time, description, seekAfterChange) {
 	}
 	
 	/* Overriden methods */
@@ -92,10 +97,10 @@ public class ChangeStartCommand : ChangeTimingCommand {
 public class ChangeEndCommand : ChangeTimingCommand {
 	private static string description = Catalog.GetString("Editing To");
 
-	public ChangeEndCommand (int frames): base(frames, description) {
+	public ChangeEndCommand (int frames, bool seekAfterChange): base(frames, description, seekAfterChange) {
 	}
 	
-	public ChangeEndCommand (TimeSpan time): base(time, description) {
+	public ChangeEndCommand (TimeSpan time, bool seekAfterChange): base(time, description, seekAfterChange) {
 	}
 
 	protected override TimeSpan GetPreviousTime () {
@@ -114,10 +119,10 @@ public class ChangeEndCommand : ChangeTimingCommand {
 public class ChangeDurationCommand : ChangeTimingCommand {
 	private static string description = Catalog.GetString("Editing During");
 
-	public ChangeDurationCommand (int frames): base(frames, description) {
+	public ChangeDurationCommand (int frames, bool seekAfterChange): base(frames, description, seekAfterChange) {
 	}
 	
-	public ChangeDurationCommand (TimeSpan time): base(time, description) {
+	public ChangeDurationCommand (TimeSpan time, bool seekAfterChange): base(time, description, seekAfterChange) {
 	}
 
 	protected override TimeSpan GetPreviousTime () {
diff --git a/src/GnomeSubtitles/Core/Command/VideoSetSubtitleTimingCommand.cs b/src/GnomeSubtitles/Core/Command/VideoSetSubtitleTimingCommand.cs
index d79ba15..8de84bd 100644
--- a/src/GnomeSubtitles/Core/Command/VideoSetSubtitleTimingCommand.cs
+++ b/src/GnomeSubtitles/Core/Command/VideoSetSubtitleTimingCommand.cs
@@ -1,6 +1,6 @@
 /*
  * This file is part of Gnome Subtitles.
- * Copyright (C) 2007-2008 Pedro Castro
+ * Copyright (C) 2007-2008,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
@@ -25,11 +25,11 @@ namespace GnomeSubtitles.Core.Command {
 public class VideoSetSubtitleStartCommand : ChangeStartCommand {
 	private static string description = Catalog.GetString("Setting Subtitle Start");
 
-	public VideoSetSubtitleStartCommand (int frames) : base(frames) {
+	public VideoSetSubtitleStartCommand (int frames) : base(frames, false) {
 		SetCommandProperties();
 	}
 	
-	public VideoSetSubtitleStartCommand (TimeSpan time) : base(time) {
+	public VideoSetSubtitleStartCommand (TimeSpan time) : base(time, false) {
 		SetCommandProperties();
 	}
 	
@@ -44,11 +44,11 @@ public class VideoSetSubtitleStartCommand : ChangeStartCommand {
 public class VideoSetSubtitleEndCommand : ChangeEndCommand {
 	private static string description = Catalog.GetString("Setting Subtitle End");
 
-	public VideoSetSubtitleEndCommand (int frames) : base(frames) {
+	public VideoSetSubtitleEndCommand (int frames) : base(frames, false) {
 		SetCommandProperties();
 	}
 	
-	public VideoSetSubtitleEndCommand (TimeSpan time) : base(time) {
+	public VideoSetSubtitleEndCommand (TimeSpan time) : base(time, false) {
 		SetCommandProperties();
 	}
 	
diff --git a/src/GnomeSubtitles/Ui/Edit/SubtitleEditSpinButtons.cs b/src/GnomeSubtitles/Ui/Edit/SubtitleEditSpinButtons.cs
index 61dfae3..05715ae 100644
--- a/src/GnomeSubtitles/Ui/Edit/SubtitleEditSpinButtons.cs
+++ b/src/GnomeSubtitles/Ui/Edit/SubtitleEditSpinButtons.cs
@@ -188,23 +188,23 @@ public class SubtitleEditSpinButtons {
    	
 	private void OnStartValueChanged (object o, EventArgs args) {
 		if (Base.TimingModeIsFrames)
-			Base.CommandManager.Execute(new ChangeStartCommand((int)startSpinButton.Value));
+			Base.CommandManager.Execute(new ChangeStartCommand((int)startSpinButton.Value, true));
 		else
-			Base.CommandManager.Execute(new ChangeStartCommand(TimeSpan.FromMilliseconds(startSpinButton.Value)));
+			Base.CommandManager.Execute(new ChangeStartCommand(TimeSpan.FromMilliseconds(startSpinButton.Value), true));
 	}
 	
 	private void OnEndValueChanged (object o, EventArgs args) {
 		if (Base.TimingModeIsFrames)
-			Base.CommandManager.Execute(new ChangeEndCommand((int)endSpinButton.Value));
+			Base.CommandManager.Execute(new ChangeEndCommand((int)endSpinButton.Value, true));
 		else
-			Base.CommandManager.Execute(new ChangeEndCommand(TimeSpan.FromMilliseconds(endSpinButton.Value)));
+			Base.CommandManager.Execute(new ChangeEndCommand(TimeSpan.FromMilliseconds(endSpinButton.Value), true));
 	}
 	
 	private void OnDurationValueChanged (object o, EventArgs args) {
 		if (Base.TimingModeIsFrames)
-			Base.CommandManager.Execute(new ChangeDurationCommand((int)durationSpinButton.Value));
+			Base.CommandManager.Execute(new ChangeDurationCommand((int)durationSpinButton.Value, true));
 		else
-			Base.CommandManager.Execute(new ChangeDurationCommand(TimeSpan.FromMilliseconds(durationSpinButton.Value)));
+			Base.CommandManager.Execute(new ChangeDurationCommand(TimeSpan.FromMilliseconds(durationSpinButton.Value), true));
 	}
 	
 	private void OnBaseInitFinished () {



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]