[gnome-subtitles/gtk3] Timings Shift dialog refactor



commit c72a4d84b6395644c2103bfda9a36099bbd7c41b
Author: Pedro Castro <pedro gnomesubtitles org>
Date:   Sat May 12 00:08:14 2018 +0100

    Timings Shift dialog refactor

 src/Glade/old.glade/TimingsShiftDialog.glade    |  283 ++++++++++++++++++++++
 src/Glade/old.glade/TimingsShiftDialog.ui       |  287 +++++++++++++++++++++++
 src/GnomeSubtitles/Dialog/TimingsShiftDialog.cs |  113 +++++++--
 3 files changed, 657 insertions(+), 26 deletions(-)
---
diff --git a/src/Glade/old.glade/TimingsShiftDialog.glade b/src/Glade/old.glade/TimingsShiftDialog.glade
new file mode 100644
index 0000000..216e100
--- /dev/null
+++ b/src/Glade/old.glade/TimingsShiftDialog.glade
@@ -0,0 +1,283 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<glade-interface>
+  <!-- interface-requires gtk+ 2.16 -->
+  <!-- interface-naming-policy toplevel-contextual -->
+  <widget class="GtkDialog" id="dialog">
+    <property name="title" translatable="yes">Shift Timings</property>
+    <property name="resizable">False</property>
+    <property name="modal">True</property>
+    <property name="window_position">center-on-parent</property>
+    <property name="type_hint">dialog</property>
+    <property name="skip_taskbar_hint">True</property>
+    <property name="skip_pager_hint">True</property>
+    <child internal-child="vbox">
+      <widget class="GtkVBox" id="dialogVBox">
+        <property name="visible">True</property>
+        <property name="spacing">5</property>
+        <child>
+          <widget class="GtkFrame" id="amountFrame">
+            <property name="visible">True</property>
+            <property name="border_width">2</property>
+            <property name="label_xalign">0</property>
+            <property name="shadow_type">none</property>
+            <child>
+              <widget class="GtkAlignment" id="alignment">
+                <property name="visible">True</property>
+                <property name="border_width">5</property>
+                <property name="xalign">0</property>
+                <property name="xscale">0.80000001192092896</property>
+                <property name="left_padding">10</property>
+                <child>
+                  <widget class="GtkHBox" id="alignmentHBox">
+                    <property name="visible">True</property>
+                    <property name="spacing">4</property>
+                    <child>
+                      <widget class="GtkSpinButton" id="spinButton">
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="has_focus">True</property>
+                        <property name="is_focus">True</property>
+                        <property name="activates_default">True</property>
+                        <property name="adjustment">0 -3000000 3000000 1 10 0</property>
+                        <property name="climb_rate">1</property>
+                        <property name="numeric">True</property>
+                      </widget>
+                      <packing>
+                        <property name="expand">False</property>
+                        <property name="fill">False</property>
+                        <property name="position">0</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <widget class="GtkButton" id="clearButton">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="receives_default">False</property>
+                        <property name="relief">none</property>
+                        <signal name="clicked" handler="OnClear"/>
+                        <child>
+                          <widget class="GtkImage" id="clearButtonImage">
+                            <property name="visible">True</property>
+                            <property name="stock">gtk-clear</property>
+                            <property name="icon-size">1</property>
+                          </widget>
+                        </child>
+                      </widget>
+                      <packing>
+                        <property name="expand">False</property>
+                        <property name="fill">False</property>
+                        <property name="position">1</property>
+                      </packing>
+                    </child>
+                  </widget>
+                </child>
+              </widget>
+            </child>
+            <child>
+              <widget class="GtkLabel" id="timingModeLabel">
+                <property name="visible">True</property>
+                <property name="label" translatable="yes">&lt;b&gt;Frames&lt;/b&gt;</property>
+                <property name="use_markup">True</property>
+              </widget>
+              <packing>
+                <property name="type">label_item</property>
+              </packing>
+            </child>
+          </widget>
+          <packing>
+            <property name="position">1</property>
+          </packing>
+        </child>
+        <child>
+          <widget class="GtkFrame" id="applyToFrame">
+            <property name="visible">True</property>
+            <property name="border_width">2</property>
+            <property name="label_xalign">0</property>
+            <property name="shadow_type">none</property>
+            <child>
+              <widget class="GtkAlignment" id="applyToAlignment">
+                <property name="visible">True</property>
+                <property name="border_width">4</property>
+                <property name="left_padding">12</property>
+                <child>
+                  <widget class="GtkVBox" id="vBox">
+                    <property name="visible">True</property>
+                    <property name="spacing">4</property>
+                    <child>
+                      <widget class="GtkRadioButton" id="allSubtitlesRadioButton">
+                        <property name="label" translatable="yes">_All subtitles</property>
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="receives_default">False</property>
+                        <property name="use_underline">True</property>
+                        <property name="active">True</property>
+                        <property name="draw_indicator">True</property>
+                      </widget>
+                      <packing>
+                        <property name="expand">False</property>
+                        <property name="fill">False</property>
+                        <property name="position">0</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <widget class="GtkRadioButton" id="selectedSubtitlesRadioButton">
+                        <property name="label" translatable="yes">_Selected subtitles</property>
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="receives_default">False</property>
+                        <property name="use_underline">True</property>
+                        <property name="draw_indicator">True</property>
+                        <property name="group">allSubtitlesRadioButton</property>
+                      </widget>
+                      <packing>
+                        <property name="expand">False</property>
+                        <property name="fill">False</property>
+                        <property name="position">1</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <widget class="GtkRadioButton" id="fromFirstSubtitleToSelectionRadioButton">
+                        <property name="label" translatable="yes" comments="This means to apply the shift 
command from the selected subtitle to the first subtitle.">From _first subtitle to selection</property>
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="receives_default">False</property>
+                        <property name="use_underline">True</property>
+                        <property name="draw_indicator">True</property>
+                        <property name="group">allSubtitlesRadioButton</property>
+                      </widget>
+                      <packing>
+                        <property name="expand">False</property>
+                        <property name="fill">False</property>
+                        <property name="position">2</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <widget class="GtkRadioButton" id="fromSelectionToLastSubtitleRadioButton">
+                        <property name="label" translatable="yes" comments="This means to apply the shift 
command from the selected subtitle to the last subtitle.">From selection to _last subtitle</property>
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="receives_default">False</property>
+                        <property name="use_underline">True</property>
+                        <property name="draw_indicator">True</property>
+                        <property name="group">allSubtitlesRadioButton</property>
+                      </widget>
+                      <packing>
+                        <property name="expand">False</property>
+                        <property name="fill">False</property>
+                        <property name="position">3</property>
+                      </packing>
+                    </child>
+                  </widget>
+                </child>
+              </widget>
+            </child>
+            <child>
+              <widget class="GtkLabel" id="applyToLabel">
+                <property name="visible">True</property>
+                <property name="label" translatable="yes">&lt;b&gt;Apply to&lt;/b&gt;</property>
+                <property name="use_markup">True</property>
+              </widget>
+              <packing>
+                <property name="type">label_item</property>
+              </packing>
+            </child>
+          </widget>
+          <packing>
+            <property name="position">2</property>
+          </packing>
+        </child>
+        <child>
+          <widget class="GtkLabel" id="label1">
+            <property name="visible">True</property>
+            <property name="xalign">0</property>
+            <property name="yalign">0</property>
+            <property name="xpad">10</property>
+            <property name="label" translatable="yes">&lt;small&gt;&lt;i&gt;Tip: use Shift+Plus/Minus (on 
the numpad)
+to shift timings from the main window.&lt;/i&gt;&lt;/small&gt;</property>
+            <property name="use_markup">True</property>
+          </widget>
+          <packing>
+            <property name="position">3</property>
+          </packing>
+        </child>
+        <child internal-child="action_area">
+          <widget class="GtkHButtonBox" id="dialogActionArea">
+            <property name="visible">True</property>
+            <property name="layout_style">end</property>
+            <child>
+              <widget class="GtkButton" id="buttonCancel">
+                <property name="label">gtk-cancel</property>
+                <property name="response_id">-6</property>
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">False</property>
+                <property name="use_stock">True</property>
+              </widget>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
+                <property name="position">0</property>
+              </packing>
+            </child>
+            <child>
+              <widget class="GtkButton" id="buttonShift">
+                <property name="response_id">-5</property>
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="can_default">True</property>
+                <property name="has_default">True</property>
+                <property name="receives_default">False</property>
+                <child>
+                  <widget class="GtkAlignment" id="actionAreaAlignment">
+                    <property name="visible">True</property>
+                    <property name="xscale">0</property>
+                    <property name="yscale">0</property>
+                    <child>
+                      <widget class="GtkHBox" id="hBox">
+                        <property name="visible">True</property>
+                        <property name="spacing">2</property>
+                        <child>
+                          <widget class="GtkImage" id="buttonImage">
+                            <property name="visible">True</property>
+                            <property name="stock">gtk-ok</property>
+                          </widget>
+                          <packing>
+                            <property name="expand">False</property>
+                            <property name="fill">False</property>
+                            <property name="position">0</property>
+                          </packing>
+                        </child>
+                        <child>
+                          <widget class="GtkLabel" id="buttonLabel">
+                            <property name="visible">True</property>
+                            <property name="label" translatable="yes">_Shift</property>
+                            <property name="use_underline">True</property>
+                          </widget>
+                          <packing>
+                            <property name="expand">False</property>
+                            <property name="fill">False</property>
+                            <property name="position">1</property>
+                          </packing>
+                        </child>
+                      </widget>
+                    </child>
+                  </widget>
+                </child>
+              </widget>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
+                <property name="position">1</property>
+              </packing>
+            </child>
+          </widget>
+          <packing>
+            <property name="expand">False</property>
+            <property name="pack_type">end</property>
+            <property name="position">0</property>
+          </packing>
+        </child>
+      </widget>
+    </child>
+  </widget>
+</glade-interface>
diff --git a/src/Glade/old.glade/TimingsShiftDialog.ui b/src/Glade/old.glade/TimingsShiftDialog.ui
new file mode 100644
index 0000000..1bda289
--- /dev/null
+++ b/src/Glade/old.glade/TimingsShiftDialog.ui
@@ -0,0 +1,287 @@
+<?xml version="1.0"?>
+<interface>
+  <object class="GtkAdjustment" id="adjustment1">
+    <property name="upper">3000000</property>
+    <property name="lower">-3000000</property>
+    <property name="page_increment">10</property>
+    <property name="step_increment">1</property>
+    <property name="page_size">0</property>
+    <property name="value">0</property>
+  </object>
+  <!-- interface-requires gtk+ 2.16 -->
+  <!-- interface-naming-policy toplevel-contextual -->
+  <object class="GtkDialog" id="dialog">
+    <property name="title" translatable="yes">Shift Timings</property>
+    <property name="resizable">False</property>
+    <property name="modal">True</property>
+    <property name="window_position">center-on-parent</property>
+    <property name="type_hint">dialog</property>
+    <property name="skip_taskbar_hint">True</property>
+    <property name="skip_pager_hint">True</property>
+    <child internal-child="vbox">
+      <object class="GtkVBox" id="dialogVBox">
+        <property name="visible">True</property>
+        <property name="spacing">5</property>
+        <child>
+          <object class="GtkFrame" id="amountFrame">
+            <property name="visible">True</property>
+            <property name="border_width">2</property>
+            <property name="label_xalign">0</property>
+            <property name="shadow_type">none</property>
+            <child>
+              <object class="GtkAlignment" id="alignment">
+                <property name="visible">True</property>
+                <property name="border_width">5</property>
+                <property name="xalign">0</property>
+                <property name="xscale">0.80000001192092896</property>
+                <property name="left_padding">10</property>
+                <child>
+                  <object class="GtkHBox" id="alignmentHBox">
+                    <property name="visible">True</property>
+                    <property name="spacing">4</property>
+                    <child>
+                      <object class="GtkSpinButton" id="spinButton">
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="has_focus">True</property>
+                        <property name="is_focus">True</property>
+                        <property name="activates_default">True</property>
+                        <property name="adjustment">adjustment1</property>
+                        <property name="climb_rate">1</property>
+                        <property name="numeric">True</property>
+                      </object>
+                      <packing>
+                        <property name="expand">False</property>
+                        <property name="fill">False</property>
+                        <property name="position">0</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkButton" id="clearButton">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="receives_default">False</property>
+                        <property name="relief">none</property>
+                        <signal handler="OnClear" name="clicked"/>
+                        <child>
+                          <object class="GtkImage" id="clearButtonImage">
+                            <property name="visible">True</property>
+                            <property name="stock">gtk-clear</property>
+                            <property name="icon-size">1</property>
+                          </object>
+                        </child>
+                      </object>
+                      <packing>
+                        <property name="expand">False</property>
+                        <property name="fill">False</property>
+                        <property name="position">1</property>
+                      </packing>
+                    </child>
+                  </object>
+                </child>
+              </object>
+            </child>
+            <child type="label">
+              <object class="GtkLabel" id="timingModeLabel">
+                <property name="visible">True</property>
+                <property name="label" translatable="yes">&lt;b&gt;Frames&lt;/b&gt;</property>
+                <property name="use_markup">True</property>
+              </object>
+            </child>
+          </object>
+          <packing>
+            <property name="position">1</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkFrame" id="applyToFrame">
+            <property name="visible">True</property>
+            <property name="border_width">2</property>
+            <property name="label_xalign">0</property>
+            <property name="shadow_type">none</property>
+            <child>
+              <object class="GtkAlignment" id="applyToAlignment">
+                <property name="visible">True</property>
+                <property name="border_width">4</property>
+                <property name="left_padding">12</property>
+                <child>
+                  <object class="GtkVBox" id="vBox">
+                    <property name="visible">True</property>
+                    <property name="spacing">4</property>
+                    <child>
+                      <object class="GtkRadioButton" id="allSubtitlesRadioButton">
+                        <property name="label" translatable="yes">_All subtitles</property>
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="receives_default">False</property>
+                        <property name="use_underline">True</property>
+                        <property name="active">True</property>
+                        <property name="draw_indicator">True</property>
+                      </object>
+                      <packing>
+                        <property name="expand">False</property>
+                        <property name="fill">False</property>
+                        <property name="position">0</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkRadioButton" id="selectedSubtitlesRadioButton">
+                        <property name="label" translatable="yes">_Selected subtitles</property>
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="receives_default">False</property>
+                        <property name="use_underline">True</property>
+                        <property name="draw_indicator">True</property>
+                        <property name="group">allSubtitlesRadioButton</property>
+                      </object>
+                      <packing>
+                        <property name="expand">False</property>
+                        <property name="fill">False</property>
+                        <property name="position">1</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkRadioButton" id="fromFirstSubtitleToSelectionRadioButton">
+                        <property comments="This means to apply the shift command from the selected subtitle 
to the first subtitle." name="label" translatable="yes">From _first subtitle to selection</property>
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="receives_default">False</property>
+                        <property name="use_underline">True</property>
+                        <property name="draw_indicator">True</property>
+                        <property name="group">allSubtitlesRadioButton</property>
+                      </object>
+                      <packing>
+                        <property name="expand">False</property>
+                        <property name="fill">False</property>
+                        <property name="position">2</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkRadioButton" id="fromSelectionToLastSubtitleRadioButton">
+                        <property comments="This means to apply the shift command from the selected subtitle 
to the last subtitle." name="label" translatable="yes">From selection to _last subtitle</property>
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="receives_default">False</property>
+                        <property name="use_underline">True</property>
+                        <property name="draw_indicator">True</property>
+                        <property name="group">allSubtitlesRadioButton</property>
+                      </object>
+                      <packing>
+                        <property name="expand">False</property>
+                        <property name="fill">False</property>
+                        <property name="position">3</property>
+                      </packing>
+                    </child>
+                  </object>
+                </child>
+              </object>
+            </child>
+            <child type="label">
+              <object class="GtkLabel" id="applyToLabel">
+                <property name="visible">True</property>
+                <property name="label" translatable="yes">&lt;b&gt;Apply to&lt;/b&gt;</property>
+                <property name="use_markup">True</property>
+              </object>
+            </child>
+          </object>
+          <packing>
+            <property name="position">2</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkLabel" id="label1">
+            <property name="visible">True</property>
+            <property name="xalign">0</property>
+            <property name="yalign">0</property>
+            <property name="xpad">10</property>
+            <property name="label" translatable="yes">&lt;small&gt;&lt;i&gt;Tip: use Shift+Plus/Minus (on 
the numpad)
+to shift timings from the main window.&lt;/i&gt;&lt;/small&gt;</property>
+            <property name="use_markup">True</property>
+          </object>
+          <packing>
+            <property name="position">3</property>
+          </packing>
+        </child>
+        <child internal-child="action_area">
+          <object class="GtkHButtonBox" id="dialogActionArea">
+            <property name="visible">True</property>
+            <property name="layout_style">end</property>
+            <child>
+              <object class="GtkButton" id="buttonCancel">
+                <property name="label">gtk-cancel</property>
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">False</property>
+                <property name="use_stock">True</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
+                <property name="position">0</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkButton" id="buttonShift">
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="can_default">True</property>
+                <property name="has_default">True</property>
+                <property name="receives_default">False</property>
+                <child>
+                  <object class="GtkAlignment" id="actionAreaAlignment">
+                    <property name="visible">True</property>
+                    <property name="xscale">0</property>
+                    <property name="yscale">0</property>
+                    <child>
+                      <object class="GtkHBox" id="hBox">
+                        <property name="visible">True</property>
+                        <property name="spacing">2</property>
+                        <child>
+                          <object class="GtkImage" id="buttonImage">
+                            <property name="visible">True</property>
+                            <property name="stock">gtk-ok</property>
+                          </object>
+                          <packing>
+                            <property name="expand">False</property>
+                            <property name="fill">False</property>
+                            <property name="position">0</property>
+                          </packing>
+                        </child>
+                        <child>
+                          <object class="GtkLabel" id="buttonLabel">
+                            <property name="visible">True</property>
+                            <property name="label" translatable="yes">_Shift</property>
+                            <property name="use_underline">True</property>
+                          </object>
+                          <packing>
+                            <property name="expand">False</property>
+                            <property name="fill">False</property>
+                            <property name="position">1</property>
+                          </packing>
+                        </child>
+                      </object>
+                    </child>
+                  </object>
+                </child>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
+                <property name="position">1</property>
+              </packing>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="pack_type">end</property>
+            <property name="position">0</property>
+          </packing>
+        </child>
+      </object>
+    </child>
+    <action-widgets>
+      <action-widget response="-6">buttonCancel</action-widget>
+      <action-widget response="-5">buttonShift</action-widget>
+    </action-widgets>
+  </object>
+</interface>
diff --git a/src/GnomeSubtitles/Dialog/TimingsShiftDialog.cs b/src/GnomeSubtitles/Dialog/TimingsShiftDialog.cs
index 8eb781f..521cde5 100644
--- a/src/GnomeSubtitles/Dialog/TimingsShiftDialog.cs
+++ b/src/GnomeSubtitles/Dialog/TimingsShiftDialog.cs
@@ -1,6 +1,6 @@
 /*
  * This file is part of Gnome Subtitles.
- * Copyright (C) 2006-2017 Pedro Castro
+ * Copyright (C) 2006-2018 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
@@ -19,8 +19,8 @@
 
 using GnomeSubtitles.Core;
 using GnomeSubtitles.Core.Command;
+using GnomeSubtitles.Ui;
 using GnomeSubtitles.Ui.View;
-//using Glade;
 using Gtk;
 using Mono.Unix;
 using SubLib.Core.Domain;
@@ -30,27 +30,95 @@ namespace GnomeSubtitles.Dialog {
 
 //TODO set spinButton limits according to selection type
 //TODO show informative message about the Ctrl+Shift++ shortcuts
-public class TimingsShiftDialog : BuilderDialog {
+public class TimingsShiftDialog : BaseDialog {
        private TimingMode timingMode = TimingMode.Frames;
 
-       /* Constant strings */
-       private const string gladeFilename = "TimingsShiftDialog.glade";
-
        /* Widgets */
-       [Builder.Object] private Label timingModeLabel = null;
-       [Builder.Object] private SpinButton spinButton = null;
-       [Builder.Object] private RadioButton allSubtitlesRadioButton = null;
-       [Builder.Object] private RadioButton selectedSubtitlesRadioButton = null;
-       [Builder.Object] private RadioButton fromFirstSubtitleToSelectionRadioButton = null;
-       [Builder.Object] private RadioButton fromSelectionToLastSubtitleRadioButton = null;
-
-       public TimingsShiftDialog () : base(gladeFilename){
-               InitSpinButton();
-               UpdateContents(true);
+       private Frame timingModeFrame;
+       private SpinButton spinButton = null;
+       private RadioButton allSubtitlesRadioButton = null;
+       private RadioButton selectedSubtitlesRadioButton = null;
+       private RadioButton fromFirstSubtitleToSelectionRadioButton = null;
+       private RadioButton fromSelectionToLastSubtitleRadioButton = null;
+
+       public TimingsShiftDialog () : base(){
+               Init(BuildDialog());
        }
 
 
        /* Methods */
+       
+       private Gtk.Dialog BuildDialog () {
+               Gtk.Dialog dialog = new Gtk.Dialog(Catalog.GetString("Shift Timings"), Base.Ui.Window, 
DialogFlags.Modal | DialogFlagsUseHeaderBar,
+                       Util.GetStockLabel("gtk-cancel"), ResponseType.Cancel, Catalog.GetString("_Shift"), 
ResponseType.Ok);
+
+               dialog.DefaultResponse = ResponseType.Ok;
+               dialog.DefaultWidth = 1; //Needed otherwise the tip label will be displayed in a single line 
making the dialog have a huge width
+
+               Box box = new Box(Orientation.Vertical, WidgetStyles.BoxSpacingLarge);
+               box.BorderWidth = WidgetStyles.BorderWidthMedium;
+
+               //Timing Mode frame
+
+               timingModeFrame = new Frame();
+               timingModeFrame.ShadowType = ShadowType.None;
+               Label timingModeFrameLabel = new Label();
+               timingModeFrame.LabelWidget = timingModeFrameLabel;
+               
+               spinButton = new SpinButton(new Adjustment(0, 0, 0, 1, 10, 0), 0, 0);
+               spinButton.WidthChars = Core.Util.SpinButtonTimeWidthChars;
+               spinButton.Alignment = 0.5f;
+               Button button = new Button("gtk-clear");
+               button.Clicked += OnClear;
+
+               Box timingModeHBox = new Box(Orientation.Horizontal, WidgetStyles.BoxSpacingMedium);
+               timingModeHBox.BorderWidth = WidgetStyles.BorderWidthMedium;
+               timingModeHBox.MarginLeft = 10;
+               timingModeHBox.Add(spinButton);
+               timingModeHBox.Add(button);
+               
+               timingModeFrame.Add(timingModeHBox);
+               box.Add(timingModeFrame);
+               
+               
+               //Apply To frame
+               
+               Frame applyToFrame = new Frame();
+               applyToFrame.ShadowType = ShadowType.None;
+               Label applyToFrameLabel = new Label();
+               applyToFrameLabel.Markup = "<b>" + Catalog.GetString("Apply to") + "</b>";
+               applyToFrame.LabelWidget = applyToFrameLabel;
+               
+               allSubtitlesRadioButton = new RadioButton(Catalog.GetString("_All subtitles"));
+               selectedSubtitlesRadioButton = new RadioButton(allSubtitlesRadioButton, 
Catalog.GetString("_Selected subtitles"));
+               fromFirstSubtitleToSelectionRadioButton = new RadioButton(allSubtitlesRadioButton, 
Catalog.GetString("From _first subtitle to selection"));
+               fromSelectionToLastSubtitleRadioButton = new RadioButton(allSubtitlesRadioButton, 
Catalog.GetString("From selection to _last subtitle"));
+
+               Box applyToFrameVBox = new Box(Orientation.Vertical, WidgetStyles.BoxSpacingMedium);
+               applyToFrameVBox.BorderWidth = WidgetStyles.BorderWidthMedium;
+               applyToFrameVBox.MarginLeft = 10;
+               applyToFrameVBox.Add(allSubtitlesRadioButton);
+               applyToFrameVBox.Add(selectedSubtitlesRadioButton);
+               applyToFrameVBox.Add(fromFirstSubtitleToSelectionRadioButton);
+               applyToFrameVBox.Add(fromSelectionToLastSubtitleRadioButton);
+               
+               applyToFrame.Add(applyToFrameVBox);
+               
+               box.Add(applyToFrame);
+               
+               //Tips label
+               
+               Label label = new Label("<small><i>" + Catalog.GetString("Tip: use Shift+Plus/Minus (on the 
numpad) to shift timings directly from the main window.") + "</i></small>");
+               label.UseMarkup = true;
+               label.Wrap = true;
+               box.Add(label);
+
+               dialog.ContentArea.Add(box);
+               UpdateContents(true);
+               dialog.ContentArea.ShowAll();
+
+               return dialog;
+       }
 
        public override void Show () {
                UpdateContents(false);
@@ -65,11 +133,6 @@ public class TimingsShiftDialog : BuilderDialog {
                UpdateSpinButtonValue(initializing);
        }
 
-       private void InitSpinButton () {
-               spinButton.WidthChars = Core.Util.SpinButtonTimeWidthChars;
-               spinButton.Alignment = 0.5f;
-       }
-
        private void UpdateFromTimingMode (TimingMode newTimingMode, bool initializing) {
                if ((!initializing) && (newTimingMode == timingMode))
                        return;
@@ -80,7 +143,7 @@ public class TimingsShiftDialog : BuilderDialog {
 
                string label = (timingMode == TimingMode.Times ? Catalog.GetString("Time") : 
Catalog.GetString("Frames"));
                string markup = "<b>" + label + "</b>";
-               timingModeLabel.Markup = markup;
+               (timingModeFrame.LabelWidget as Label).Markup = markup;
        }
 
        private void UpdateFromSelection () {
@@ -133,14 +196,12 @@ public class TimingsShiftDialog : BuilderDialog {
                        return SelectionIntended.SimpleToLast;
        }
 
-       #pragma warning disable 169             //Disables warning about handlers not being used
-
        private void OnClear (object o, EventArgs args) {
                SetSpinButtonValue(0);
        }
 
        protected override bool ProcessResponse (ResponseType response) {
-               if ((response == ResponseType.Ok) && (spinButton.Value != 0)) {
+               if ((response == ResponseType.Ok) && (Math.Abs(spinButton.Value) > float.Epsilon)) {
                        SelectionIntended selectionIntended = GetSelectionIntended();
 
                        if (timingMode == TimingMode.Times) {
@@ -157,4 +218,4 @@ public class TimingsShiftDialog : BuilderDialog {
 
 }
 
-}
+}
\ No newline at end of file


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