[gnome-subtitles/gtk3] Updated FileOpen and VideoOpen dialogs
- From: Pedro Daniel da Rocha Melo e Castro <pcastro src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-subtitles/gtk3] Updated FileOpen and VideoOpen dialogs
- Date: Thu, 23 Nov 2017 00:14:39 +0000 (UTC)
commit 5144811867fa1d037ecd39dab7561823a130c15f
Author: Pedro Castro <pedro gnomesubtitles org>
Date: Thu Nov 23 00:12:35 2017 +0000
Updated FileOpen and VideoOpen dialogs
gnome-subtitles.csproj | 11 +-
src/Glade/{ => old.glade}/FileOpenDialog.glade | 0
.../FileOpenDialog.ui} | 160 ++++++++++---------
src/Glade/{ => old.glade}/VideoOpenDialog.glade | 0
src/Glade/{ => old.glade}/VideoOpenDialog.ui | 0
src/GnomeSubtitles/Core/Util.cs | 6 +
src/GnomeSubtitles/Dialog/BaseDialog.cs | 12 ++-
src/GnomeSubtitles/Dialog/BuilderDialog.cs | 5 +-
src/GnomeSubtitles/Dialog/FileOpenDialog.cs | 76 +++++++---
src/GnomeSubtitles/Dialog/Util.cs | 38 -----
src/GnomeSubtitles/Dialog/VideoOpenDialog.cs | 17 +-
.../Ui/Component/EncodingComboBox.cs | 2 +-
12 files changed, 170 insertions(+), 157 deletions(-)
---
diff --git a/gnome-subtitles.csproj b/gnome-subtitles.csproj
index ba6b249..f9b0a61 100644
--- a/gnome-subtitles.csproj
+++ b/gnome-subtitles.csproj
@@ -63,9 +63,6 @@
<EmbeddedResource Include="src\Glade\EncodingsDialog.glade">
<LogicalName>EncodingsDialog.glade</LogicalName>
</EmbeddedResource>
- <EmbeddedResource Include="src\Glade\FileOpenDialog.glade">
- <LogicalName>FileOpenDialog.glade</LogicalName>
- </EmbeddedResource>
<EmbeddedResource Include="src\Glade\FilePropertiesDialog.glade">
<LogicalName>FilePropertiesDialog.glade</LogicalName>
</EmbeddedResource>
@@ -112,9 +109,6 @@
<EmbeddedResource Include="src\Glade\MainWindow.ui">
<LogicalName>MainWindow.ui</LogicalName>
</EmbeddedResource>
- <EmbeddedResource Include="src\Glade\VideoOpenDialog.ui">
- <LogicalName>VideoOpenDialog.ui</LogicalName>
- </EmbeddedResource>
</ItemGroup>
<ItemGroup>
<Compile Include="src\External\GStreamerPlaybin\Engine.cs" />
@@ -194,7 +188,6 @@
<Compile Include="src\GnomeSubtitles\Dialog\DialogScope.cs" />
<Compile Include="src\GnomeSubtitles\Dialog\Dialogs.cs" />
<Compile Include="src\GnomeSubtitles\Dialog\EncodingsDialog.cs" />
- <Compile Include="src\GnomeSubtitles\Dialog\FileOpenDialog.cs" />
<Compile Include="src\GnomeSubtitles\Dialog\FilePropertiesDialog.cs" />
<Compile Include="src\GnomeSubtitles\Dialog\FileSaveAsDialog.cs" />
<Compile Include="src\GnomeSubtitles\Dialog\FileTranslationOpenDialog.cs" />
@@ -210,8 +203,6 @@
<Compile Include="src\GnomeSubtitles\Dialog\TimingsShiftDialog.cs" />
<Compile Include="src\GnomeSubtitles\Dialog\TimingsSynchronizeDialog.cs" />
<Compile Include="src\GnomeSubtitles\Dialog\TranslationSaveAsDialog.cs" />
- <Compile Include="src\GnomeSubtitles\Dialog\Util.cs" />
- <Compile Include="src\GnomeSubtitles\Dialog\VideoOpenDialog.cs" />
<Compile Include="src\GnomeSubtitles\Dialog\VideoSeekToDialog.cs" />
<Compile Include="src\GnomeSubtitles\Dialog\Unmanaged\BasicErrorDialog.cs" />
<Compile Include="src\GnomeSubtitles\Dialog\Unmanaged\ErrorDialog.cs" />
@@ -327,6 +318,8 @@
<Compile Include="src\SubLib\IO\SubtitleFormats\SubtitleFormatSubViewer2.cs" />
<Compile Include="src\SubLib\IO\SubtitleFormats\SubtitleFormatViPlaySubtitleFile.cs" />
<Compile Include="src\GnomeSubtitles\Dialog\BuilderDialog.cs" />
+ <Compile Include="src\GnomeSubtitles\Dialog\FileOpenDialog.cs" />
+ <Compile Include="src\GnomeSubtitles\Dialog\VideoOpenDialog.cs" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<ItemGroup>
diff --git a/src/Glade/FileOpenDialog.glade b/src/Glade/old.glade/FileOpenDialog.glade
similarity index 100%
copy from src/Glade/FileOpenDialog.glade
copy to src/Glade/old.glade/FileOpenDialog.glade
diff --git a/src/Glade/FileOpenDialog.glade b/src/Glade/old.glade/FileOpenDialog.ui
similarity index 60%
rename from src/Glade/FileOpenDialog.glade
rename to src/Glade/old.glade/FileOpenDialog.ui
index fdbb23a..5059b15 100644
--- a/src/Glade/FileOpenDialog.glade
+++ b/src/Glade/old.glade/FileOpenDialog.ui
@@ -1,9 +1,10 @@
-<?xml version="1.0"?>
-<glade-interface>
- <!-- interface-requires gtk+ 2.16 -->
- <!-- interface-naming-policy toplevel-contextual -->
- <widget class="GtkFileChooserDialog" id="dialog">
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.20.0 -->
+<interface>
+ <requires lib="gtk+" version="3.12"/>
+ <object class="GtkFileChooserDialog" id="dialog">
<property name="height_request">450</property>
+ <property name="can_focus">False</property>
<property name="title" translatable="yes">Open File</property>
<property name="modal">True</property>
<property name="window_position">center-on-parent</property>
@@ -11,83 +12,26 @@
<property name="type_hint">dialog</property>
<property name="skip_taskbar_hint">True</property>
<property name="skip_pager_hint">True</property>
- <property name="has_separator">False</property>
<child internal-child="vbox">
- <widget class="GtkVBox" id="dialogVBox">
+ <object class="GtkBox" id="dialogVBox">
<property name="visible">True</property>
+ <property name="can_focus">False</property>
<property name="orientation">vertical</property>
<property name="spacing">24</property>
- <child>
- <widget class="GtkTable" id="table">
- <property name="visible">True</property>
- <property name="n_rows">2</property>
- <property name="n_columns">2</property>
- <property name="column_spacing">10</property>
- <property name="row_spacing">10</property>
- <child>
- <widget class="GtkComboBox" id="videoComboBox">
- <property name="items" translatable="yes"></property>
- </widget>
- <packing>
- <property name="left_attach">1</property>
- <property name="right_attach">2</property>
- <property name="top_attach">1</property>
- <property name="bottom_attach">2</property>
- </packing>
- </child>
- <child>
- <widget class="GtkLabel" id="videoLabel">
- <property name="xalign">0</property>
- <property name="label" translatable="yes">Video To Open:</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="encodingLabel">
- <property name="visible">True</property>
- <property name="xalign">0</property>
- <property name="label" translatable="yes">Character Coding:</property>
- </widget>
- <packing>
- <property name="x_options">GTK_FILL</property>
- <property name="y_options"></property>
- </packing>
- </child>
- <child>
- <widget class="GtkComboBox" id="fileEncodingComboBox">
- <property name="visible">True</property>
- </widget>
- <packing>
- <property name="left_attach">1</property>
- <property name="right_attach">2</property>
- </packing>
- </child>
- </widget>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">2</property>
- </packing>
- </child>
<child internal-child="action_area">
- <widget class="GtkHButtonBox" id="dialogActionArea">
+ <object class="GtkButtonBox" id="dialogActionArea">
<property name="visible">True</property>
+ <property name="can_focus">False</property>
<property name="layout_style">end</property>
<child>
- <widget class="GtkButton" id="buttonCancel">
+ <object 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="can_default">True</property>
<property name="receives_default">False</property>
<property name="use_stock">True</property>
- </widget>
+ </object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
@@ -95,30 +39,94 @@
</packing>
</child>
<child>
- <widget class="GtkButton" id="buttonOpen">
+ <object class="GtkButton" id="buttonOpen">
<property name="label">gtk-open</property>
- <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>
<property name="use_stock">True</property>
- </widget>
+ </object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
- </widget>
+ </object>
<packing>
<property name="expand">False</property>
+ <property name="fill">False</property>
<property name="pack_type">end</property>
- <property name="position">0</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkGrid">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="margin_left">6</property>
+ <property name="margin_right">6</property>
+ <property name="row_spacing">10</property>
+ <property name="column_spacing">10</property>
+ <child>
+ <object class="GtkLabel" id="encodingLabel">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="halign">start</property>
+ <property name="label" translatable="yes">Character Coding:</property>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="videoLabel">
+ <property name="can_focus">False</property>
+ <property name="halign">start</property>
+ <property name="label" translatable="yes">Video To Open:</property>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkComboBoxText" id="fileEncodingComboBox">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="hexpand">True</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkComboBoxText" id="videoComboBox">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="hexpand">True</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">2</property>
</packing>
</child>
- </widget>
+ </object>
</child>
- </widget>
-</glade-interface>
+ <action-widgets>
+ <action-widget response="-6">buttonCancel</action-widget>
+ <action-widget response="-5">buttonOpen</action-widget>
+ </action-widgets>
+ </object>
+</interface>
diff --git a/src/Glade/VideoOpenDialog.glade b/src/Glade/old.glade/VideoOpenDialog.glade
similarity index 100%
rename from src/Glade/VideoOpenDialog.glade
rename to src/Glade/old.glade/VideoOpenDialog.glade
diff --git a/src/Glade/VideoOpenDialog.ui b/src/Glade/old.glade/VideoOpenDialog.ui
similarity index 100%
rename from src/Glade/VideoOpenDialog.ui
rename to src/Glade/old.glade/VideoOpenDialog.ui
diff --git a/src/GnomeSubtitles/Core/Util.cs b/src/GnomeSubtitles/Core/Util.cs
index 6ad650d..04aed08 100644
--- a/src/GnomeSubtitles/Core/Util.cs
+++ b/src/GnomeSubtitles/Core/Util.cs
@@ -243,6 +243,12 @@ public class Util {
}
}
+ public static String GetStockLabel(string stockId) {
+ StockItem item;
+ StockManager.LookupItem(stockId, out item);
+ return item.Label;
+ }
+
}
}
diff --git a/src/GnomeSubtitles/Dialog/BaseDialog.cs b/src/GnomeSubtitles/Dialog/BaseDialog.cs
index 542cca7..64fedcd 100644
--- a/src/GnomeSubtitles/Dialog/BaseDialog.cs
+++ b/src/GnomeSubtitles/Dialog/BaseDialog.cs
@@ -1,6 +1,6 @@
/*
* This file is part of Gnome Subtitles.
- * Copyright (C) 2009 Pedro Castro
+ * Copyright (C) 2009-2017 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,6 +19,7 @@
using Gtk;
using System;
+using GnomeSubtitles.Core;
namespace GnomeSubtitles.Dialog {
@@ -83,7 +84,7 @@ public abstract class BaseDialog {
protected void Init (Gtk.Dialog dialog) {
this.dialog = dialog;
- Util.SetBaseWindowFromUi(dialog);
+ //SetBaseWindow(dialog, Base.Ui.Window);
dialog.Response += OnResponse;
dialog.DeleteEvent += OnDeleteEvent;
@@ -124,6 +125,13 @@ public abstract class BaseDialog {
}
+ /* Private members */
+
+ private void SetBaseWindow (Gtk.Dialog dialog, Window window) {
+ dialog.TransientFor = window;
+ dialog.Icon = window.Icon; //TODO is this still needed?
+ }
+
}
}
diff --git a/src/GnomeSubtitles/Dialog/BuilderDialog.cs b/src/GnomeSubtitles/Dialog/BuilderDialog.cs
index 80577bb..196aaf6 100644
--- a/src/GnomeSubtitles/Dialog/BuilderDialog.cs
+++ b/src/GnomeSubtitles/Dialog/BuilderDialog.cs
@@ -1,6 +1,6 @@
/*
* This file is part of Gnome Subtitles.
- * Copyright (C) 2006-2009,2017 Pedro Castro
+ * Copyright (C) 2006-2017 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
@@ -57,8 +57,7 @@ public abstract class BuilderDialog : BaseDialog {
Autoconnect();
/*else
glade.BindFields(this); //FIXME WHAT?
-*/
- //base.Init(glade.GetWidget("dialog") as Gtk.Dialog);
+ */
base.Init(builder.GetObject("dialog") as Gtk.Dialog);
}
diff --git a/src/GnomeSubtitles/Dialog/FileOpenDialog.cs b/src/GnomeSubtitles/Dialog/FileOpenDialog.cs
index 32a5ef2..964ed40 100644
--- a/src/GnomeSubtitles/Dialog/FileOpenDialog.cs
+++ b/src/GnomeSubtitles/Dialog/FileOpenDialog.cs
@@ -32,7 +32,7 @@ using System.Text.RegularExpressions;
namespace GnomeSubtitles.Dialog {
-public class FileOpenDialog : BuilderDialog {
+public class FileOpenDialog : BaseDialog {
protected FileChooserDialog dialog = null;
private string chosenFilename = String.Empty;
@@ -42,37 +42,69 @@ public class FileOpenDialog : BuilderDialog {
private Uri chosenVideoUri = null;
private bool autoChooseVideoFile = true;
- /* Constant strings */
- private const string gladeFilename = "FileOpenDialog.glade";
-
/* Components */
private EncodingComboBox encodingComboBox = null;
/* Widgets */
- [Builder.Object] private ComboBoxText fileEncodingComboBox = null;
- [Builder.Object] private ComboBoxText videoComboBox = null;
- [Builder.Object] private Label videoLabel = null;
+ private ComboBoxText fileEncodingComboBox = null;
+ private ComboBoxText videoComboBox = null;
+ private Label videoLabel = null;
public FileOpenDialog () : this(true, Catalog.GetString("Open File")) {
}
- protected FileOpenDialog (bool toEnableVideo, string title) : base(gladeFilename) {
- dialog = GetDialog() as FileChooserDialog;
- dialog.Title = title;
+ protected FileOpenDialog (bool toEnableVideo, string title) : base() {
+ dialog = new FileChooserDialog(title, Base.Ui.Window, FileChooserAction.Open,
+ Util.GetStockLabel("gtk-cancel"), ResponseType.Cancel,
Util.GetStockLabel("gtk-open"), ResponseType.Ok);
+
+ dialog.DefaultResponse = ResponseType.Ok;
- InitEncodingComboBox();
+ InitContentArea();
- if (toEnableVideo)
+ if (toEnableVideo) {
EnableVideo();
+ }
- string startFolder = GetStartFolder();
- dialog.SetCurrentFolder(startFolder);
+ dialog.SetCurrentFolder(GetStartFolder());
SetFilters();
+
+ Init(dialog);
+ }
+
+ private void InitContentArea() {
+ Grid grid = new Grid();
+
+ grid.RowSpacing = 6;
+ grid.ColumnSpacing = 6;
+ grid.MarginLeft = 6;
+ grid.MarginRight = 6;
+ grid.MarginTop = 8;
+ grid.MarginBottom = 10;
+
+ Label encodingLabel = new Label(Catalog.GetString("Character Encoding:"));
+ encodingLabel.Xalign = 0;
+ grid.Attach(encodingLabel, 0, 0, 1, 1);
+
+ this.videoLabel = new Label(Catalog.GetString("Video To Open:"));
+ this.videoLabel.Xalign = 0;
+ grid.Attach(this.videoLabel, 0, 1, 1, 1);
+
+ this.fileEncodingComboBox = new ComboBoxText();
+ this.fileEncodingComboBox.Hexpand = true;
+ grid.Attach(this.fileEncodingComboBox, 1, 0, 1, 1);
+ this.encodingComboBox = BuildEncodingComboBox();
+
+ this.videoComboBox = new ComboBoxText();
+ this.videoComboBox.Hexpand = true;
+ grid.Attach(this.videoComboBox, 1, 1, 1, 1);
+
+ dialog.ContentArea.Add(grid);
+ dialog.ContentArea.ShowAll();
}
- private void InitEncodingComboBox () {
+ private EncodingComboBox BuildEncodingComboBox () {
int fixedEncoding = -1;
ConfigFileOpenEncoding encodingConfig = Base.Config.FileOpenEncoding;
if (encodingConfig == ConfigFileOpenEncoding.Fixed) {
@@ -82,11 +114,14 @@ public class FileOpenDialog : BuilderDialog {
fixedEncoding = encodingDescription.CodePage;
}
- this.encodingComboBox = new EncodingComboBox(fileEncodingComboBox, true, null, fixedEncoding);
+ EncodingComboBox comboBox = new EncodingComboBox(this.fileEncodingComboBox, true, null,
fixedEncoding);
/* Only need to handle the case of currentLocale, as Fixed is handled before and AutoDetect
is the default behaviour */
- if (encodingConfig == ConfigFileOpenEncoding.CurrentLocale)
- encodingComboBox.ActiveSelection = (int)encodingConfig;
+ if (encodingConfig == ConfigFileOpenEncoding.CurrentLocale) {
+ comboBox.ActiveSelection = (int)encodingConfig;
+ }
+
+ return comboBox;
}
/* Overriden members */
@@ -117,10 +152,11 @@ public class FileOpenDialog : BuilderDialog {
/* Protected members */
protected virtual string GetStartFolder () {
- if (Base.IsDocumentLoaded && Base.Document.TextFile.IsPathRooted)
+ if (Base.IsDocumentLoaded && Base.Document.TextFile.IsPathRooted) {
return Base.Document.TextFile.Directory;
- else
+ } else {
return Environment.GetFolderPath(Environment.SpecialFolder.Personal);
+ }
}
diff --git a/src/GnomeSubtitles/Dialog/VideoOpenDialog.cs b/src/GnomeSubtitles/Dialog/VideoOpenDialog.cs
index 5942ebb..b55593e 100644
--- a/src/GnomeSubtitles/Dialog/VideoOpenDialog.cs
+++ b/src/GnomeSubtitles/Dialog/VideoOpenDialog.cs
@@ -24,23 +24,24 @@ using System;
namespace GnomeSubtitles.Dialog {
-public class VideoOpenDialog : BuilderDialog {
+public class VideoOpenDialog : BaseDialog {
protected FileChooserDialog dialog = null;
private Uri chosenUri = null;
- /* Constant strings */
- private const string gladeFilename = "VideoOpenDialog.ui";
+ public VideoOpenDialog () : base() {
+ dialog = new FileChooserDialog(Catalog.GetString("Open Video"), Base.Ui.Window,
FileChooserAction.Open,
+ Util.GetStockLabel("gtk-cancel"), ResponseType.Cancel,
Util.GetStockLabel("gtk-open"), ResponseType.Ok);
+ dialog.DefaultResponse = ResponseType.Ok;
- public VideoOpenDialog () : base(gladeFilename) {
- dialog = GetDialog() as FileChooserDialog;
-
- if (Base.IsDocumentLoaded && Base.Document.TextFile.IsPathRooted)
+ if (Base.IsDocumentLoaded && Base.Document.TextFile.IsPathRooted) {
dialog.SetCurrentFolder(Base.Document.TextFile.Directory);
- else
+ } else {
dialog.SetCurrentFolder(Environment.GetFolderPath(Environment.SpecialFolder.Personal));
+ }
SetFilters();
+ Init(dialog);
}
/* Public properties */
diff --git a/src/GnomeSubtitles/Ui/Component/EncodingComboBox.cs
b/src/GnomeSubtitles/Ui/Component/EncodingComboBox.cs
index 19bb51a..6fe14d8 100644
--- a/src/GnomeSubtitles/Ui/Component/EncodingComboBox.cs
+++ b/src/GnomeSubtitles/Ui/Component/EncodingComboBox.cs
@@ -181,7 +181,7 @@ public class EncodingComboBox {
}
private void AddAutoDetect () {
- comboBox.AppendText(Catalog.GetString("Auto Detected"));
+ comboBox.AppendText(Catalog.GetString("Automatically Detected"));
}
private void SetActiveItem (int item, bool silent) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]