[gnome-subtitles] Fix the bug#601195 - Subtitle loop
- From: Pedro Daniel da Rocha Melo e Castro <pcastro src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-subtitles] Fix the bug#601195 - Subtitle loop
- Date: Sun, 25 Jul 2010 23:36:52 +0000 (UTC)
commit d42bb60be89f882f50ead421b3d28807fdecee4c
Author: Valmir Sena <valmirse gmail com>
Date: Mon Jun 28 02:40:14 2010 -0300
Fix the bug#601195 - Subtitle loop
src/Glade/MainWindow.glade | 27 ++++++++++++++-------
src/GnomeSubtitles/Core/EventHandlers.cs | 4 +++
src/GnomeSubtitles/Ui/Menus.cs | 1 +
src/GnomeSubtitles/Ui/VideoPreview/Video.cs | 28 +++++++++++++++++++++-
src/GnomeSubtitles/Ui/View/SubtitleSelection.cs | 11 +++++++++
src/GnomeSubtitles/Ui/View/SubtitleView.cs | 2 +-
src/GnomeSubtitles/Ui/WidgetNames.cs | 1 +
7 files changed, 62 insertions(+), 12 deletions(-)
---
diff --git a/src/Glade/MainWindow.glade b/src/Glade/MainWindow.glade
index c271e35..8916684 100644
--- a/src/Glade/MainWindow.glade
+++ b/src/Glade/MainWindow.glade
@@ -248,8 +248,8 @@
<property name="use_underline">True</property>
<property name="use_stock">True</property>
<signal name="activate" handler="OnEditRedo"/>
- <accelerator key="Z" signal="activate" modifiers="GDK_SHIFT_MASK | GDK_CONTROL_MASK"/>
<accelerator key="Y" signal="activate" modifiers="GDK_CONTROL_MASK"/>
+ <accelerator key="Z" signal="activate" modifiers="GDK_SHIFT_MASK | GDK_CONTROL_MASK"/>
</widget>
</child>
<child>
@@ -532,8 +532,8 @@
<property name="label" translatable="yes">Find Ne_xt</property>
<property name="use_underline">True</property>
<signal name="activate" handler="OnSearchFindNext"/>
- <accelerator key="g" signal="activate" modifiers="GDK_CONTROL_MASK"/>
<accelerator key="F3" signal="activate"/>
+ <accelerator key="g" signal="activate" modifiers="GDK_CONTROL_MASK"/>
</widget>
</child>
<child>
@@ -543,8 +543,8 @@
<property name="label" translatable="yes">Find Pre_vious</property>
<property name="use_underline">True</property>
<signal name="activate" handler="OnSearchFindPrevious"/>
- <accelerator key="g" signal="activate" modifiers="GDK_SHIFT_MASK | GDK_CONTROL_MASK"/>
<accelerator key="F3" signal="activate" modifiers="GDK_SHIFT_MASK"/>
+ <accelerator key="g" signal="activate" modifiers="GDK_SHIFT_MASK | GDK_CONTROL_MASK"/>
</widget>
</child>
<child>
@@ -803,8 +803,8 @@
<property name="use_underline">True</property>
<property name="use_stock">False</property>
<signal name="activate" handler="OnVideoPlayPause"/>
- <accelerator key="p" signal="activate" modifiers="GDK_CONTROL_MASK"/>
<accelerator key="F5" signal="activate"/>
+ <accelerator key="p" signal="activate" modifiers="GDK_CONTROL_MASK"/>
<child internal-child="image">
<widget class="GtkImage" id="videoPlayPauseImage">
<property name="visible">True</property>
@@ -815,6 +815,15 @@
</widget>
</child>
<child>
+ <widget class="GtkCheckMenuItem" id="videoLoopSelectionPlayback">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Loop Selection Playback</property>
+ <property name="use_underline">True</property>
+ <signal name="toggled" handler="OnVideoLoopSelectionPlayback"/>
+ <accelerator key="F11" signal="activate" modifiers="GDK_CONTROL_MASK"/>
+ </widget>
+ </child>
+ <child>
<widget class="GtkImageMenuItem" id="videoRewind">
<property name="label" translatable="yes">R_ewind</property>
<property name="visible">True</property>
@@ -822,8 +831,8 @@
<property name="use_underline">True</property>
<property name="use_stock">False</property>
<signal name="activate" handler="OnVideoRewind"/>
- <accelerator key="k" signal="activate" modifiers="GDK_CONTROL_MASK"/>
<accelerator key="F6" signal="activate"/>
+ <accelerator key="k" signal="activate" modifiers="GDK_CONTROL_MASK"/>
<child internal-child="image">
<widget class="GtkImage" id="videoRewindImage">
<property name="visible">True</property>
@@ -841,8 +850,8 @@
<property name="use_underline">True</property>
<property name="use_stock">False</property>
<signal name="activate" handler="OnVideoForward"/>
- <accelerator key="l" signal="activate" modifiers="GDK_CONTROL_MASK"/>
<accelerator key="F7" signal="activate"/>
+ <accelerator key="l" signal="activate" modifiers="GDK_CONTROL_MASK"/>
<child internal-child="image">
<widget class="GtkImage" id="videoForwardImage">
<property name="visible">True</property>
@@ -882,8 +891,8 @@
<property name="label" translatable="yes">Seek _to Selection</property>
<property name="use_underline">True</property>
<signal name="activate" handler="OnVideoSeekToSelection"/>
- <accelerator key="r" signal="activate" modifiers="GDK_SHIFT_MASK | GDK_CONTROL_MASK"/>
<accelerator key="F4" signal="activate" modifiers="GDK_SHIFT_MASK | GDK_CONTROL_MASK"/>
+ <accelerator key="r" signal="activate" modifiers="GDK_SHIFT_MASK | GDK_CONTROL_MASK"/>
</widget>
</child>
<child>
@@ -893,8 +902,8 @@
<property name="label" translatable="yes">Select Nearest Subtitle</property>
<property name="use_underline">True</property>
<signal name="activate" handler="OnVideoSelectNearestSubtitle"/>
- <accelerator key="F4" signal="activate" modifiers="GDK_CONTROL_MASK"/>
<accelerator key="r" signal="activate" modifiers="GDK_CONTROL_MASK"/>
+ <accelerator key="F4" signal="activate" modifiers="GDK_CONTROL_MASK"/>
</widget>
</child>
<child>
@@ -903,8 +912,8 @@
<property name="label" translatable="yes">Auto Select Subtitles</property>
<property name="use_underline">True</property>
<signal name="toggled" handler="OnVideoAutoSelectSubtitles"/>
- <accelerator key="F3" signal="activate" modifiers="GDK_CONTROL_MASK"/>
<accelerator key="j" signal="activate" modifiers="GDK_CONTROL_MASK"/>
+ <accelerator key="F3" signal="activate" modifiers="GDK_CONTROL_MASK"/>
</widget>
</child>
<child>
diff --git a/src/GnomeSubtitles/Core/EventHandlers.cs b/src/GnomeSubtitles/Core/EventHandlers.cs
index 3859b3e..e63a64d 100644
--- a/src/GnomeSubtitles/Core/EventHandlers.cs
+++ b/src/GnomeSubtitles/Core/EventHandlers.cs
@@ -274,6 +274,10 @@ public class EventHandlers {
Base.Ui.View.SetAutoSelectSubtitles();
}
+ public void OnVideoLoopSelectionPlayback (object o, EventArgs args) {
+ Base.Ui.Video.SetLoopSelectionPlayback();
+ }
+
public void OnVideoSetSubtitleStart (object o, EventArgs args) {
if (Base.TimingMode == TimingMode.Times) {
TimeSpan time = Base.Ui.Video.Position.CurrentTime;
diff --git a/src/GnomeSubtitles/Ui/Menus.cs b/src/GnomeSubtitles/Ui/Menus.cs
index a10759a..1d78ae1 100644
--- a/src/GnomeSubtitles/Ui/Menus.cs
+++ b/src/GnomeSubtitles/Ui/Menus.cs
@@ -314,6 +314,7 @@ public class Menus {
private void SetVideoDocumentLoadedSensitivity (bool isDocumentLoaded) {
bool sensitivity = isDocumentLoaded && (Base.Ui != null) && Base.Ui.Video.IsLoaded;
SetSensitivity(WidgetNames.VideoSelectNearestSubtitle, sensitivity);
+ SetSensitivity(WidgetNames.VideoLoopSelectionPlayback, sensitivity);
SetSensitivity(WidgetNames.VideoAutoSelectSubtitles, sensitivity);
}
diff --git a/src/GnomeSubtitles/Ui/VideoPreview/Video.cs b/src/GnomeSubtitles/Ui/VideoPreview/Video.cs
index 7081b3c..b3ffc70 100644
--- a/src/GnomeSubtitles/Ui/VideoPreview/Video.cs
+++ b/src/GnomeSubtitles/Ui/VideoPreview/Video.cs
@@ -138,6 +138,14 @@ public class Video {
public void Quit () {
player.Close();
}
+
+ public void SetLoopSelectionPlayback(){
+ CheckMenuItem loopSelectionPlayback = Base.GetWidget(WidgetNames.VideoLoopSelectionPlayback) as CheckMenuItem;
+ if (loopSelectionPlayback.Active)
+ Base.Ui.Video.Position.Changed += OnVideoPositionChanged;
+ else
+ Base.Ui.Video.Position.Changed -= OnVideoPositionChanged;
+ }
public void Rewind () {
player.Rewind(position.SeekIncrement);
@@ -278,7 +286,7 @@ public class Video {
ToggleButton button = Base.GetWidget(WidgetNames.VideoPlayPauseButton) as ToggleButton;
button.Toggled += OnPlayPauseButtonToggled;
- Base.Ui.View.Selection.Changed += OnSubtitleSelectionChanged;
+ Base.Ui.View.Selection.Changed += OnSubtitleSelectionChanged;
}
private void OnPlayPauseButtonToggled (object o, EventArgs args) {
@@ -322,10 +330,26 @@ public class Video {
private void OnSubtitleSelectionChanged (TreePath[] paths, Subtitle subtitle) {
if ((subtitle != null) && IsLoaded)
- SetSelectionDependentControlsSensitivity(true);
+ SetSelectionDependentControlsSensitivity(true);
else
SetSelectionDependentControlsSensitivity(false);
}
+
+ private void OnVideoPositionChanged (TimeSpan position) {
+
+
+ Subtitle firstSubtitle = Core.Base.Ui.View.Selection.FirstSubtitle;
+ Subtitle lastSubtitle = Core.Base.Ui.View.Selection.LastSubtitle;
+
+ if( firstSubtitle != null ){
+
+ double startTime = firstSubtitle.Times.Start.TotalSeconds;
+ double endTime = lastSubtitle.Times.End.TotalSeconds;
+
+ if( position.TotalSeconds < startTime || position.TotalSeconds > endTime )
+ SeekToSelection();
+ }
+ }
}
diff --git a/src/GnomeSubtitles/Ui/View/SubtitleSelection.cs b/src/GnomeSubtitles/Ui/View/SubtitleSelection.cs
index 784a7ac..2c3fe35 100644
--- a/src/GnomeSubtitles/Ui/View/SubtitleSelection.cs
+++ b/src/GnomeSubtitles/Ui/View/SubtitleSelection.cs
@@ -150,6 +150,17 @@ public class SubtitleSelection {
return null;
}
}
+
+ /// <summary>The last selected subtitle. If there is only one selected, the first is returned.</summary>
+ public Subtitle LastSubtitle {
+ get {
+ TreePath path = this.LastPath;
+ if (path != null)
+ return Base.Document.Subtitles[path];
+ else
+ return null;
+ }
+ }
/// <summary>The number of selected paths.</summary>
public int Count {
diff --git a/src/GnomeSubtitles/Ui/View/SubtitleView.cs b/src/GnomeSubtitles/Ui/View/SubtitleView.cs
index 492b6c1..392f09e 100644
--- a/src/GnomeSubtitles/Ui/View/SubtitleView.cs
+++ b/src/GnomeSubtitles/Ui/View/SubtitleView.cs
@@ -358,7 +358,7 @@ public class SubtitleView {
SetEmptyModel();
tree.Model.RowInserted -= OnModelRowInserted;
- tree.Model.RowDeleted -= OnModelRowDeleted;
+ tree.Model.RowDeleted -= OnModelRowDeleted;
}
private void OnModelRowInserted (object o, RowInsertedArgs args) {
diff --git a/src/GnomeSubtitles/Ui/WidgetNames.cs b/src/GnomeSubtitles/Ui/WidgetNames.cs
index dc03c42..8647b06 100644
--- a/src/GnomeSubtitles/Ui/WidgetNames.cs
+++ b/src/GnomeSubtitles/Ui/WidgetNames.cs
@@ -81,6 +81,7 @@ public class WidgetNames {
public const string VideoSeekToSelection = "videoSeekToSelection";
public const string VideoSelectNearestSubtitle = "videoSelectNearestSubtitle";
public const string VideoAutoSelectSubtitles = "videoAutoSelectSubtitles";
+ public const string VideoLoopSelectionPlayback = "videoLoopSelectionPlayback";
public const string VideoSetSubtitleStart = "videoSetSubtitleStart";
public const string VideoSetSubtitleEnd = "videoSetSubtitleEnd";
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]