gnome-subtitles r1062 - in trunk/src: Glade GnomeSubtitles/Core GnomeSubtitles/Core/Command GnomeSubtitles/Ui GnomeSubtitles/Ui/VideoPreview



Author: pcastro
Date: Sat Oct  4 23:14:50 2008
New Revision: 1062
URL: http://svn.gnome.org/viewvc/gnome-subtitles?rev=1062&view=rev

Log:
Account for changes in SubLib that separated timing and search operations from Subtitles.

Modified:
   trunk/src/Glade/MainWindow.glade
   trunk/src/GnomeSubtitles/Core/Command/AdjustTimingsCommand.cs
   trunk/src/GnomeSubtitles/Core/Command/ChangeFrameRateCommand.cs
   trunk/src/GnomeSubtitles/Core/Command/ReplaceAllCommand.cs
   trunk/src/GnomeSubtitles/Core/Command/ShiftTimingsCommand.cs
   trunk/src/GnomeSubtitles/Core/Search.cs
   trunk/src/GnomeSubtitles/Ui/MainUi.cs
   trunk/src/GnomeSubtitles/Ui/VideoPreview/Video.cs
   trunk/src/GnomeSubtitles/Ui/VideoPreview/VideoPosition.cs
   trunk/src/GnomeSubtitles/Ui/VideoPreview/VideoSubtitle.cs

Modified: trunk/src/Glade/MainWindow.glade
==============================================================================
--- trunk/src/Glade/MainWindow.glade	(original)
+++ trunk/src/Glade/MainWindow.glade	Sat Oct  4 23:14:50 2008
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
 <!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd">
-<!--Generated with glade3 3.4.5 on Sat Oct  4 00:07:06 2008 
+<!--Generated with glade3 3.4.5 on Sat Oct  4 21:12:26 2008 
 	Version: 3.0.1
 	Date: Thu Dec  7 16:42:10 2006
 	User: noup
@@ -233,8 +233,8 @@
                         <property name="use_underline">True</property>
                         <property name="use_stock">True</property>
                         <signal name="activate" handler="OnEditRedo"/>
-                        <accelerator key="Z" modifiers="GDK_SHIFT_MASK | GDK_CONTROL_MASK" signal="activate"/>
                         <accelerator key="Y" modifiers="GDK_CONTROL_MASK" signal="activate"/>
+                        <accelerator key="Z" modifiers="GDK_SHIFT_MASK | GDK_CONTROL_MASK" signal="activate"/>
                       </widget>
                     </child>
                     <child>
@@ -512,8 +512,8 @@
                         <property name="label" translatable="yes">Find Ne_xt</property>
                         <property name="use_underline">True</property>
                         <signal name="activate" handler="OnSearchFindNext"/>
-                        <accelerator key="G" modifiers="GDK_CONTROL_MASK" signal="activate"/>
                         <accelerator key="F3" modifiers="" signal="activate"/>
+                        <accelerator key="G" modifiers="GDK_CONTROL_MASK" signal="activate"/>
                       </widget>
                     </child>
                     <child>
@@ -523,8 +523,8 @@
                         <property name="label" translatable="yes">Find Pre_vious</property>
                         <property name="use_underline">True</property>
                         <signal name="activate" handler="OnSearchFindPrevious"/>
-                        <accelerator key="G" modifiers="GDK_SHIFT_MASK | GDK_CONTROL_MASK" signal="activate"/>
                         <accelerator key="F3" modifiers="GDK_SHIFT_MASK" signal="activate"/>
+                        <accelerator key="G" modifiers="GDK_SHIFT_MASK | GDK_CONTROL_MASK" signal="activate"/>
                       </widget>
                     </child>
                     <child>
@@ -699,6 +699,14 @@
                       </widget>
                     </child>
                     <child>
+                      <widget class="GtkMenuItem" id="timingsSynchronize">
+                        <property name="visible">True</property>
+                        <property name="label" translatable="yes">_Synchronize</property>
+                        <property name="use_underline">True</property>
+                        <signal name="activate" handler="OnTimingsSynchronize"/>
+                      </widget>
+                    </child>
+                    <child>
                       <widget class="GtkMenuItem" id="timingsAdjust">
                         <property name="visible">True</property>
                         <property name="sensitive">False</property>
@@ -711,7 +719,7 @@
                       <widget class="GtkMenuItem" id="timingsShift">
                         <property name="visible">True</property>
                         <property name="sensitive">False</property>
-                        <property name="label" translatable="yes">_Shift</property>
+                        <property name="label" translatable="yes">Sh_ift</property>
                         <property name="use_underline">True</property>
                         <signal name="activate" handler="OnTimingsShift"/>
                       </widget>
@@ -769,8 +777,8 @@
                         <property name="label" translatable="yes">_Play / Pause</property>
                         <property name="use_underline">True</property>
                         <signal name="activate" handler="OnVideoPlayPause"/>
-                        <accelerator key="P" modifiers="GDK_CONTROL_MASK" signal="activate"/>
                         <accelerator key="F5" modifiers="" signal="activate"/>
+                        <accelerator key="P" modifiers="GDK_CONTROL_MASK" signal="activate"/>
                         <child internal-child="image">
                           <widget class="GtkImage" id="videoPlayPauseImage">
                             <property name="visible">True</property>
@@ -789,8 +797,8 @@
                         <property name="use_underline">True</property>
                         <property name="use_stock">True</property>
                         <signal name="activate" handler="OnVideoRewind"/>
-                        <accelerator key="K" modifiers="GDK_CONTROL_MASK" signal="activate"/>
                         <accelerator key="F6" modifiers="" signal="activate"/>
+                        <accelerator key="K" modifiers="GDK_CONTROL_MASK" signal="activate"/>
                       </widget>
                     </child>
                     <child>
@@ -801,8 +809,8 @@
                         <property name="use_underline">True</property>
                         <property name="use_stock">True</property>
                         <signal name="activate" handler="OnVideoForward"/>
-                        <accelerator key="L" modifiers="GDK_CONTROL_MASK" signal="activate"/>
                         <accelerator key="F7" modifiers="" signal="activate"/>
+                        <accelerator key="L" modifiers="GDK_CONTROL_MASK" signal="activate"/>
                       </widget>
                     </child>
                     <child>
@@ -1550,31 +1558,39 @@
                         <property name="n_columns">2</property>
                         <property name="row_spacing">2</property>
                         <child>
-                          <widget class="GtkSpinButton" id="startSpinButton">
+                          <widget class="GtkLabel" id="startLabel">
                             <property name="visible">True</property>
-                            <property name="can_focus">True</property>
-                            <property name="adjustment">0 0 100 1 10 10</property>
-                            <property name="climb_rate">1</property>
-                            <property name="numeric">True</property>
+                            <property name="xalign">0</property>
+                            <property name="label" translatable="yes" comments="This is the start time/frame of a subtitle.">From:</property>
                           </widget>
                           <packing>
-                            <property name="left_attach">1</property>
-                            <property name="right_attach">2</property>
+                            <property name="x_options">GTK_FILL</property>
                             <property name="y_options"></property>
                           </packing>
                         </child>
                         <child>
-                          <widget class="GtkSpinButton" id="durationSpinButton">
+                          <widget class="GtkLabel" id="endLabel">
                             <property name="visible">True</property>
-                            <property name="can_focus">True</property>
-                            <property name="adjustment">0 0 100 1 10 10</property>
-                            <property name="climb_rate">1</property>
+                            <property name="xalign">0</property>
+                            <property name="label" translatable="yes" comments="This is the end time/frame of a subtitle.">To:</property>
+                          </widget>
+                          <packing>
+                            <property name="top_attach">1</property>
+                            <property name="bottom_attach">2</property>
+                            <property name="x_options">GTK_FILL</property>
+                            <property name="y_options"></property>
+                          </packing>
+                        </child>
+                        <child>
+                          <widget class="GtkLabel" id="durationLabel">
+                            <property name="visible">True</property>
+                            <property name="xalign">0</property>
+                            <property name="label" translatable="yes" comments="This is the duration of a subtitle.">During:</property>
                           </widget>
                           <packing>
-                            <property name="left_attach">1</property>
-                            <property name="right_attach">2</property>
                             <property name="top_attach">2</property>
                             <property name="bottom_attach">3</property>
+                            <property name="x_options">GTK_FILL</property>
                             <property name="y_options"></property>
                           </packing>
                         </child>
@@ -1594,39 +1610,31 @@
                           </packing>
                         </child>
                         <child>
-                          <widget class="GtkLabel" id="durationLabel">
+                          <widget class="GtkSpinButton" id="durationSpinButton">
                             <property name="visible">True</property>
-                            <property name="xalign">0</property>
-                            <property name="label" translatable="yes" comments="This is the duration of a subtitle.">During:</property>
+                            <property name="can_focus">True</property>
+                            <property name="adjustment">0 0 100 1 10 10</property>
+                            <property name="climb_rate">1</property>
                           </widget>
                           <packing>
+                            <property name="left_attach">1</property>
+                            <property name="right_attach">2</property>
                             <property name="top_attach">2</property>
                             <property name="bottom_attach">3</property>
-                            <property name="x_options">GTK_FILL</property>
-                            <property name="y_options"></property>
-                          </packing>
-                        </child>
-                        <child>
-                          <widget class="GtkLabel" id="endLabel">
-                            <property name="visible">True</property>
-                            <property name="xalign">0</property>
-                            <property name="label" translatable="yes" comments="This is the end time/frame of a subtitle.">To:</property>
-                          </widget>
-                          <packing>
-                            <property name="top_attach">1</property>
-                            <property name="bottom_attach">2</property>
-                            <property name="x_options">GTK_FILL</property>
                             <property name="y_options"></property>
                           </packing>
                         </child>
                         <child>
-                          <widget class="GtkLabel" id="startLabel">
+                          <widget class="GtkSpinButton" id="startSpinButton">
                             <property name="visible">True</property>
-                            <property name="xalign">0</property>
-                            <property name="label" translatable="yes" comments="This is the start time/frame of a subtitle.">From:</property>
+                            <property name="can_focus">True</property>
+                            <property name="adjustment">0 0 100 1 10 10</property>
+                            <property name="climb_rate">1</property>
+                            <property name="numeric">True</property>
                           </widget>
                           <packing>
-                            <property name="x_options">GTK_FILL</property>
+                            <property name="left_attach">1</property>
+                            <property name="right_attach">2</property>
                             <property name="y_options"></property>
                           </packing>
                         </child>

Modified: trunk/src/GnomeSubtitles/Core/Command/AdjustTimingsCommand.cs
==============================================================================
--- trunk/src/GnomeSubtitles/Core/Command/AdjustTimingsCommand.cs	(original)
+++ trunk/src/GnomeSubtitles/Core/Command/AdjustTimingsCommand.cs	Sat Oct  4 23:14:50 2008
@@ -19,6 +19,7 @@
 
 using GnomeSubtitles.Ui.View;
 using Mono.Unix;
+using SubLib.Core.Timing;
 using System;
 
 namespace GnomeSubtitles.Core.Command {
@@ -63,7 +64,8 @@
 		TimeSpan oldFirstTime = subtitles[0].Times.Start;
 		TimeSpan oldLastTime = subtitles[subtitles.Count - 1].Times.Start;
 		
-		subtitles.AdjustTimings(firstTime, lastTime);
+		AdjustOperator adjustOp = new AdjustOperator(subtitles);
+		adjustOp.Adjust(firstTime, lastTime);
 		
 		firstTime = oldFirstTime;
 		lastTime = oldLastTime;
@@ -75,7 +77,8 @@
 		int oldFirstFrame = subtitles[0].Frames.Start;
 		int oldLastFrame = subtitles[subtitles.Count - 1].Frames.Start;
 		
-		subtitles.AdjustTimings(firstFrame, lastFrame);
+		AdjustOperator adjustOp = new AdjustOperator(subtitles);
+		adjustOp.Adjust(firstFrame, lastFrame);
 		
 		firstFrame = oldFirstFrame;
 		lastFrame = oldLastFrame;
@@ -90,7 +93,8 @@
 		TimeSpan oldFirstTime = subtitles[firstSubtitle].Times.Start;
 		TimeSpan oldLastTime = subtitles[lastSubtitle].Times.Start;
 		
-		subtitles.AdjustTimings(firstSubtitle, firstTime, lastSubtitle, lastTime);
+		AdjustOperator adjustOp = new AdjustOperator(subtitles);
+		adjustOp.Adjust(firstSubtitle, firstTime, lastSubtitle, lastTime);
 		
 		firstTime = oldFirstTime;
 		lastTime = oldLastTime;
@@ -105,7 +109,8 @@
 		int oldFirstFrame = subtitles[firstSubtitle].Frames.Start;
 		int oldLastFrame = subtitles[lastSubtitle].Frames.Start;
 		
-		subtitles.AdjustTimings(firstSubtitle, firstFrame, lastSubtitle, lastFrame);
+		AdjustOperator adjustOp = new AdjustOperator(subtitles);
+		adjustOp.Adjust(firstSubtitle, firstFrame, lastSubtitle, lastFrame);
 		
 		firstFrame = oldFirstFrame;
 		lastFrame = oldLastFrame;

Modified: trunk/src/GnomeSubtitles/Core/Command/ChangeFrameRateCommand.cs
==============================================================================
--- trunk/src/GnomeSubtitles/Core/Command/ChangeFrameRateCommand.cs	(original)
+++ trunk/src/GnomeSubtitles/Core/Command/ChangeFrameRateCommand.cs	Sat Oct  4 23:14:50 2008
@@ -19,6 +19,7 @@
 
 using GnomeSubtitles.Ui.View;
 using Mono.Unix;
+using SubLib.Core.Timing;
 
 namespace GnomeSubtitles.Core.Command {
 
@@ -54,7 +55,8 @@
 	}
 	
 	protected override void SetFrameRate (float frameRate) {
-		Base.Document.Subtitles.ChangeOriginalFrameRate(frameRate);
+		FrameRateOperator frameRateOp = new FrameRateOperator(Base.Document.Subtitles);
+		frameRateOp.ChangeOriginal(frameRate);
 	}
 	
 	protected override void UpdateMenuItem () {
@@ -73,7 +75,8 @@
 	}
 	
 	protected override void SetFrameRate (float frameRate) {
-		Base.Document.Subtitles.ChangeFrameRate(frameRate);
+		FrameRateOperator frameRateOp = new FrameRateOperator(Base.Document.Subtitles);
+		frameRateOp.ChangeCurrent(frameRate);
 	}
 	
 	protected override void UpdateMenuItem () {

Modified: trunk/src/GnomeSubtitles/Core/Command/ReplaceAllCommand.cs
==============================================================================
--- trunk/src/GnomeSubtitles/Core/Command/ReplaceAllCommand.cs	(original)
+++ trunk/src/GnomeSubtitles/Core/Command/ReplaceAllCommand.cs	Sat Oct  4 23:14:50 2008
@@ -21,6 +21,7 @@
 using Gtk;
 using Mono.Unix;
 using SubLib.Core.Domain;
+using SubLib.Core.Search;
 using System;
 using System.Text.RegularExpressions;
 
@@ -42,7 +43,8 @@
 
 
 	public override bool Execute () {
-		int count = Base.Document.Subtitles.ReplaceAll(regex, replacement, out subtitles, out texts);
+		SearchOperator searchOp = new SearchOperator(Base.Document.Subtitles);
+		int count = searchOp.ReplaceAll(regex, replacement, out subtitles, out texts);
 		if (count == 0)
 			return false;
 		

Modified: trunk/src/GnomeSubtitles/Core/Command/ShiftTimingsCommand.cs
==============================================================================
--- trunk/src/GnomeSubtitles/Core/Command/ShiftTimingsCommand.cs	(original)
+++ trunk/src/GnomeSubtitles/Core/Command/ShiftTimingsCommand.cs	Sat Oct  4 23:14:50 2008
@@ -21,6 +21,7 @@
 using Gtk;
 using Mono.Unix;
 using SubLib.Core.Domain;
+using SubLib.Core.Timing;
 using System;
 
 namespace GnomeSubtitles.Core.Command {
@@ -64,12 +65,14 @@
 	/* Private Members */
 
 	private void ShiftTimesAll () {
-		Base.Document.Subtitles.ShiftTimings(time);
+		ShiftOperator shiftOp = new ShiftOperator(Base.Document.Subtitles);
+		shiftOp.Shift(time);
 		time = time.Negate();
 	}
 	
 	private void ShiftFramesAll () {
-		Base.Document.Subtitles.ShiftTimings(frames);
+		ShiftOperator shiftOp = new ShiftOperator(Base.Document.Subtitles);
+		shiftOp.Shift(frames);
 		frames = -frames;
 	}
 	
@@ -93,7 +96,8 @@
 		int firstSubtitle = Util.PathToInt(FirstPath);
 		int lastSubtitle = Util.PathToInt(LastPath);
 		
-		Base.Document.Subtitles.ShiftTimings(time, firstSubtitle, lastSubtitle);
+		ShiftOperator shiftOp = new ShiftOperator(Base.Document.Subtitles);
+		shiftOp.Shift(time, firstSubtitle, lastSubtitle);
 		time = time.Negate();
 	}
 	
@@ -101,7 +105,8 @@
 		int firstSubtitle = Util.PathToInt(FirstPath);
 		int lastSubtitle = Util.PathToInt(LastPath);
 		
-		Base.Document.Subtitles.ShiftTimings(frames, firstSubtitle, lastSubtitle);
+		ShiftOperator shiftOp = new ShiftOperator(Base.Document.Subtitles);
+		shiftOp.Shift(frames, firstSubtitle, lastSubtitle);
 		frames = -frames;
 	}
 }

Modified: trunk/src/GnomeSubtitles/Core/Search.cs
==============================================================================
--- trunk/src/GnomeSubtitles/Core/Search.cs	(original)
+++ trunk/src/GnomeSubtitles/Core/Search.cs	Sat Oct  4 23:14:50 2008
@@ -21,6 +21,7 @@
 using GnomeSubtitles.Dialog;
 using Gtk;
 using SubLib.Core.Domain;
+using SubLib.Core.Search;
 using System;
 using System.Text.RegularExpressions;
 
@@ -115,7 +116,8 @@
 
 		/* Search */
 		SubtitleSearchOptions options = new SubtitleSearchOptions(regex, textType, subtitle, index, dialog.Wrap, backwards);
-		SubtitleSearchResults results = Base.Document.Subtitles.Find(options);
+		SearchOperator searchOp = new SearchOperator(Base.Document.Subtitles);
+		SubtitleSearchResults results = searchOp.Find(options);
 		
 		/* If no text was found, return */
 		if (results == null)

Modified: trunk/src/GnomeSubtitles/Ui/MainUi.cs
==============================================================================
--- trunk/src/GnomeSubtitles/Ui/MainUi.cs	(original)
+++ trunk/src/GnomeSubtitles/Ui/MainUi.cs	Sat Oct  4 23:14:50 2008
@@ -260,6 +260,7 @@
 		view.UpdateFromNewDocument(wasLoaded);
 		edit.UpdateFromNewDocument(wasLoaded);
 		menus.UpdateFromNewDocument(wasLoaded);
+		video.UpdateFromNewDocument(wasLoaded);
 	}
 	
 	public void UpdateFromNewTranslationDocument () {

Modified: trunk/src/GnomeSubtitles/Ui/VideoPreview/Video.cs
==============================================================================
--- trunk/src/GnomeSubtitles/Ui/VideoPreview/Video.cs	(original)
+++ trunk/src/GnomeSubtitles/Ui/VideoPreview/Video.cs	Sat Oct  4 23:14:50 2008
@@ -22,6 +22,7 @@
 using Gtk;
 using SubLib.Core;
 using SubLib.Core.Domain;
+using SubLib.Core.Timing;
 using System;
 using System.Text.RegularExpressions;
 
@@ -144,6 +145,10 @@
 	public void UpdateFromTimingMode (TimingMode newMode) {
 		position.ToggleTimingMode(newMode);
 	}
+	
+	public void UpdateFromNewDocument (bool wasLoaded) {
+    	subtitle.UpdateFromNewDocument(wasLoaded);
+    }
 
 	/// <summary>Updates the controls for a subtitle selection change.</summary>
 	/// <param name="isSingle">Whether there is only 1 selected subtitle.</param>
@@ -179,7 +184,7 @@
 		if (!isLoaded)
 			return;
 
-		TimeSpan time = Synchronization.FramesToTime(frames, this.FrameRate);
+		TimeSpan time = SyncUtil.FramesToTime(frames, this.FrameRate);
 		Seek(time);
 	}
 	

Modified: trunk/src/GnomeSubtitles/Ui/VideoPreview/VideoPosition.cs
==============================================================================
--- trunk/src/GnomeSubtitles/Ui/VideoPreview/VideoPosition.cs	(original)
+++ trunk/src/GnomeSubtitles/Ui/VideoPreview/VideoPosition.cs	Sat Oct  4 23:14:50 2008
@@ -22,6 +22,7 @@
 using Mono.Unix;
 using SubLib.Core;
 using SubLib.Core.Domain;
+using SubLib.Core.Timing;
 using System;
 
 namespace GnomeSubtitles.Ui.VideoPreview {
@@ -70,7 +71,7 @@
 	}
 	
 	public int CurrentFrames {
-		get { return Convert.ToInt32(Synchronization.TimeToFrames(position, player.FrameRate)); }
+		get { return Convert.ToInt32(SyncUtil.TimeToFrames(position, player.FrameRate)); }
 	}
 	
 	public TimeSpan Length {
@@ -78,7 +79,7 @@
 	}
 	
 	public int LengthInFrames {
-		get { return Convert.ToInt32(Synchronization.TimeToFrames(player.Length, player.FrameRate)); }
+		get { return Convert.ToInt32(SyncUtil.TimeToFrames(player.Length, player.FrameRate)); }
 	}
 	
 	/* Public methods */
@@ -176,7 +177,7 @@
 		if (Base.TimingMode == TimingMode.Times)
 			positionValueLabel.Text = Util.TimeSpanToText(newPosition);
 		else {
-			double frames = (newPosition == TimeSpan.Zero ? 0 : Synchronization.TimeToFrames(newPosition, player.FrameRate));
+			double frames = (newPosition == TimeSpan.Zero ? 0 : SyncUtil.TimeToFrames(newPosition, player.FrameRate));
 			positionValueLabel.Text = Convert.ToInt32(frames).ToString();
 		}
 	}
@@ -195,7 +196,7 @@
 		if (timingMode == TimingMode.Times)
 			lengthValueLabel.Text = Util.TimeSpanToText(length);
 		else {
-			double frames = (length == TimeSpan.Zero ? 0 : Synchronization.TimeToFrames(length, player.FrameRate));
+			double frames = (length == TimeSpan.Zero ? 0 : SyncUtil.TimeToFrames(length, player.FrameRate));
 			lengthValueLabel.Text = Convert.ToInt32(frames).ToString();
 		}
 	}

Modified: trunk/src/GnomeSubtitles/Ui/VideoPreview/VideoSubtitle.cs
==============================================================================
--- trunk/src/GnomeSubtitles/Ui/VideoPreview/VideoSubtitle.cs	(original)
+++ trunk/src/GnomeSubtitles/Ui/VideoPreview/VideoSubtitle.cs	Sat Oct  4 23:14:50 2008
@@ -20,6 +20,7 @@
 using GnomeSubtitles.Core;
 using Gtk;
 using SubLib.Core.Domain;
+using SubLib.Core.Search;
 using System;
 
 namespace GnomeSubtitles.Ui.VideoPreview {
@@ -27,6 +28,7 @@
 //TODO change name to SubtitleOverlay
 public class VideoSubtitle {
 	private Label label = null;
+	private SearchOperator searchOp = null;
 	
 	/* Current subtitle */
 	private Subtitle subtitle = null;
@@ -56,6 +58,10 @@
 	public void Close () {
 		UnloadSubtitle();
 	}
+	
+	public void UpdateFromNewDocument (bool wasLoaded) {
+    	searchOp = new SearchOperator(Base.Document.Subtitles);
+    }
 
 	/* Event members */
 	
@@ -64,7 +70,7 @@
 			return;
 	
 		if (!(IsTimeInCurrentSubtitle(newPosition))) {
-			int foundSubtitle = Base.Document.Subtitles.FindWithTime((float)newPosition.TotalSeconds); //TODO write method in SubLib that accepts TimeSpans
+			int foundSubtitle = searchOp.FindWithTime((float)newPosition.TotalSeconds); //TODO write method in SubLib that accepts TimeSpans
 			if (foundSubtitle == -1)
 				UnloadSubtitle();
 			else



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