[gnome-subtitles] Fixed the way sync points are inserted



commit 0ba1fb5d41fcdf949042728339e2bd9a45b508ca
Author: Pedro Castro <mail pedrocastro org>
Date:   Sat May 23 12:40:47 2009 +0100

    Fixed the way sync points are inserted
---
 gnome-subtitles.mdp                   |   26 +++++++++++--------
 src/GnomeSubtitles/Core/SyncPoints.cs |   45 +++++++++++++++++++--------------
 2 files changed, 41 insertions(+), 30 deletions(-)

diff --git a/gnome-subtitles.mdp b/gnome-subtitles.mdp
index 52bb8d8..9042ace 100644
--- a/gnome-subtitles.mdp
+++ b/gnome-subtitles.mdp
@@ -1,16 +1,20 @@
-<Project name="gnome-subtitles" fileversion="2.0" language="C#" clr-version="Net_2_0" ctype="DotNetProject">
+<Project name="gnome-subtitles" fileversion="2.0" language="C#" clr-version="Net_2_0" targetFramework="2.0" ctype="DotNetProject">
+  <Policies>
+    <TextStylePolicy FileWidth="120" TabWidth="4" TabsToSpaces="False" NoTabsAfterNonTabs="False" RemoveTrailingWhitespace="True" EolMarker="Native" />
+  </Policies>
   <Configurations active="Debug">
     <Configuration name="Debug" ctype="DotNetProjectConfiguration">
-      <Output directory="build" assemblyKeyFile="." assembly="gnome-subtitles" />
+      <Output directory="build" assemblyKeyFile="/home/noup/Workspace/gnome-subtitles/." assembly="gnome-subtitles" />
       <Build debugmode="True" target="WinExe" />
       <Execution runwithwarnings="True" consolepause="True" runtime="MsNet" clr-version="Net_2_0" />
-      <CodeGeneration compiler="Csc" warninglevel="4" optimize="True" unsafecodeallowed="False" generateoverflowchecks="True" mainclass="GnomeSubtitles.Execution.Executable" generatexmldocumentation="False" win32Icon="." ctype="CSharpCompilerParameters" />
+      <EnvironmentVariables />
+      <CodeGeneration compiler="Mcs" warninglevel="3" optimize="True" unsafecodeallowed="False" generateoverflowchecks="True" generatexmldocumentation="False" ctype="CSharpCompilerParameters" />
     </Configuration>
     <Configuration name="Release" ctype="DotNetProjectConfiguration">
       <Output directory="build" assembly="gnome-subtitles" />
       <Build debugmode="False" target="WinExe" />
       <Execution runwithwarnings="True" consolepause="True" runtime="MsNet" clr-version="Net_2_0" />
-      <CodeGeneration compiler="Csc" warninglevel="4" optimize="True" unsafecodeallowed="False" generateoverflowchecks="False" mainclass="GnomeSubtitles.Execution.Executable" generatexmldocumentation="False" win32Icon="." ctype="CSharpCompilerParameters" />
+      <CodeGeneration compiler="Mcs" warninglevel="4" optimize="True" unsafecodeallowed="False" generateoverflowchecks="False" generatexmldocumentation="False" ctype="CSharpCompilerParameters" />
     </Configuration>
   </Configurations>
   <Contents>
@@ -139,20 +143,20 @@
     <File name="src/GnomeSubtitles/Execution/ConfigureDefines.cs" subtype="Code" buildaction="Compile" />
     <File name="src/GnomeSubtitles/Ui/VideoPreview/SubtitleOverlay.cs" subtype="Code" buildaction="Compile" />
     <File name="src/GnomeSubtitles/Core/SyncPoints.cs" subtype="Code" buildaction="Compile" />
+    <File name="src/GnomeSubtitles/Core/Command/SynchronizeTimingsCommand.cs" subtype="Code" buildaction="Compile" />
+    <File name="src/GnomeSubtitles/Dialog/DialogScope.cs" subtype="Code" buildaction="Compile" />
   </Contents>
   <References>
-    <ProjectReference type="Gac" localcopy="True" refto="gtk-sharp, Version=2.8.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
-    <ProjectReference type="Gac" localcopy="True" refto="glade-sharp, Version=2.8.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
     <ProjectReference type="Gac" localcopy="True" refto="Mono.Posix, Version=2.0.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756" />
     <ProjectReference type="Gac" localcopy="True" refto="System.Xml, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
     <ProjectReference type="Gac" localcopy="True" refto="System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
     <ProjectReference type="Gac" localcopy="True" refto="System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
-    <ProjectReference type="Gac" localcopy="True" refto="gconf-sharp, Version=2.8.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
     <ProjectReference type="Assembly" localcopy="True" refto="../sublib/build/sublib.dll" />
+    <ProjectReference type="Gac" localcopy="True" refto="gtk-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
+    <ProjectReference type="Gac" localcopy="True" refto="gconf-sharp, Version=2.24.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
+    <ProjectReference type="Gac" localcopy="True" refto="glade-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
   </References>
+  <LanguageParameters StartupObject="GnomeSubtitles.Execution.Executable" ApplicationIcon="." ctype="CSharpProjectParameters" />
   <Deployment.LinuxDeployData generateScript="False" />
-  <DeployTargets />
-  <DeploymentInformation strategy="File">
-    <excludeFiles />
-  </DeploymentInformation>
+  <DeploymentInformation strategy="File" />
 </Project>
\ No newline at end of file
diff --git a/src/GnomeSubtitles/Core/SyncPoints.cs b/src/GnomeSubtitles/Core/SyncPoints.cs
index d2b13e4..1108c44 100644
--- a/src/GnomeSubtitles/Core/SyncPoints.cs
+++ b/src/GnomeSubtitles/Core/SyncPoints.cs
@@ -1,6 +1,6 @@
 /*
  * This file is part of Gnome Subtitles.
- * Copyright (C) 2008 Pedro Castro
+ * Copyright (C) 2008-2009 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
@@ -54,20 +54,31 @@ public class SyncPoints {
 	
 	/* Public methods */
 	
-	public void InsertSorted (SyncPoint syncPoint) {
-		for (int index = 0 ; index < collection.Count ; index++) {
-			SyncPoint existing = collection[index] as SyncPoint;
-			if (syncPoint.SubtitleNumber == existing.SubtitleNumber) { //Found an existing sync point for this subtitle number
-				Replace(index, syncPoint);
-				return;
-			}
-			else if (syncPoint.SubtitleNumber < existing.SubtitleNumber) { //The new sync point comes before the current
-				Insert(index, syncPoint);
-				return;
-			}
+	public int Add (SyncPoint syncPoint) {
+		bool didReplace = collection.Add(syncPoint);
+		int index = collection.IndexOf(syncPoint);
+		if (didReplace) {
+			Replace(index, syncPoint); //Replace existing
+			return index;
+		}
+		else if (collection[collection.Count - 1].SubtitleNumber == syncPoint.SubtitleNumber) {
+			Append(syncPoint); //Append to the end
+			return collection.Count - 1;
+		}
+		else {
+			Insert(index, syncPoint); //Insert in position, not replacing
+			return index;
+		}
+	}
+	
+	public void Remove (TreePath[] paths) {
+		foreach (TreePath path in paths) {
+			TreeIter iter;
+			model.GetIter(out iter, path);
+			model.Remove(ref iter);
+			
+			collection.Remove(Util.PathToInt(path));
 		}
-		/* Inserting in the end */
-		Add(syncPoint);
 	}
 	
 	public IEnumerator GetEnumerator () {
@@ -86,20 +97,16 @@ public class SyncPoints {
 	
 		
 	private void Insert (int index, SyncPoint syncPoint) {
-		collection.Insert(index, syncPoint);
 		model.SetValue(model.Insert(index), 0, syncPoint);
 	}
 	
 	private void Replace (int index, SyncPoint syncPoint) {
-		collection.Replace(index, syncPoint);
-		
 		TreeIter iter;
 		model.GetIterFromString(out iter, index.ToString());
 		model.SetValue(iter, 0, syncPoint);
 	}
 	
-	private void Add (SyncPoint syncPoint) {
-		collection.Add(syncPoint);
+	private void Append (SyncPoint syncPoint) {
 		model.AppendValues(syncPoint);
 	}
 



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