From 434bd2c69bd7bad39e5c2c43467648d901d58691 Mon Sep 17 00:00:00 2001 From: sr55 Date: Fri, 17 Jul 2009 23:37:33 +0000 Subject: [PATCH] WinGui: - Added new options: preferred language, "Dub Foreign language audio" and "Use Foreign language audio and Subtitles" - Changed built-in language list to native spellings. - Fixes to CLI Scan Parser AudioTrack.\ - Note: Subtitles panel is not hooked up for this yet. git-svn-id: svn://localhost/HandBrake/trunk@2709 b64f7644-9d1e-0410-96f1-a4d463321fa5 --- win/C#/Controls/AudioPanel.cs | 24 +++++++++- win/C#/Controls/Subtitles.cs | 4 ++ win/C#/Functions/Main.cs | 26 +++++----- win/C#/HandBrakeCS.csproj | 1 + win/C#/Parsing/AudioTrack.cs | 51 ++++++++++---------- win/C#/Properties/Settings.Designer.cs | 26 +++++++++- win/C#/Properties/Settings.settings | 6 +++ win/C#/app.config | 6 +++ win/C#/frmOptions.Designer.cs | 88 ++++++++++++++++++++++++++++++++++ win/C#/frmOptions.cs | 34 +++++++++++++ win/C#/frmOptions.resx | 3 ++ 11 files changed, 229 insertions(+), 40 deletions(-) diff --git a/win/C#/Controls/AudioPanel.cs b/win/C#/Controls/AudioPanel.cs index d086999a..c846f505 100644 --- a/win/C#/Controls/AudioPanel.cs +++ b/win/C#/Controls/AudioPanel.cs @@ -227,7 +227,29 @@ namespace Handbrake.Controls drp_audioTrack.Items.Add("Automatic"); drp_audioTrack.Items.Add("None"); drp_audioTrack.Items.AddRange(selectedTitle.AudioTracks.ToArray()); - drp_audioTrack.SelectedIndex = 0; + + // Handle Native Language and "Dub Foreign language audio" and "Use Foreign language audio and Subtitles" Options + if (Properties.Settings.Default.NativeLanguage == "Any") + drp_audioTrack.SelectedIndex = 0; + else + { + if (Properties.Settings.Default.DubAudio) // "Dub Foreign language audio" + { + int i = 0; + foreach (object item in drp_audioTrack.Items) + { + if (item.ToString().Contains(Properties.Settings.Default.NativeLanguage)) + drp_audioTrack.SelectedIndex = i; + + i++; + } + + foreach (ListViewItem item in lv_audioList.Items) + item.SubItems[1].Text = drp_audioTrack.SelectedItem.ToString(); + } + else + drp_audioTrack.SelectedIndex = 0; // "Use Foreign language audio and Subtitles" + } drp_audioMix.SelectedIndex = 0; } public ListView getAudioPanel() diff --git a/win/C#/Controls/Subtitles.cs b/win/C#/Controls/Subtitles.cs index c785cdeb..9036a6c7 100644 --- a/win/C#/Controls/Subtitles.cs +++ b/win/C#/Controls/Subtitles.cs @@ -22,6 +22,10 @@ namespace Handbrake.Controls } private int FileContainer; + public void setSubtitleTrackAuto() + { + //TODO + } public void setContainer(int value) { FileContainer = value; diff --git a/win/C#/Functions/Main.cs b/win/C#/Functions/Main.cs index 54ef9d45..075bdfa9 100644 --- a/win/C#/Functions/Main.cs +++ b/win/C#/Functions/Main.cs @@ -472,9 +472,9 @@ namespace Handbrake.Functions {"Corsican", "cos"}, {"Cree", "cre"}, {"Czech", "ces"}, - {"Danish", "dan"}, + {"Dansk", "dan"}, {"Divehi", "div"}, - {"Dutch", "nld"}, + {"Nederlands", "nld"}, {"Dzongkha", "dzo"}, {"English", "eng"}, {"Esperanto", "epo"}, @@ -482,12 +482,12 @@ namespace Handbrake.Functions {"Ewe", "ewe"}, {"Faroese", "fao"}, {"Fijian", "fij"}, - {"Finnish", "fin"}, - {"French", "fra"}, + {"Suomi", "fin"}, + {"Francais", "fra"}, {"Western Frisian", "fry"}, {"Fulah", "ful"}, {"Georgian", "kat"}, - {"German", "deu"}, + {"Deutsch", "deu"}, {"Gaelic (Scots)", "gla"}, {"Irish", "gle"}, {"Galician", "glg"}, @@ -501,9 +501,9 @@ namespace Handbrake.Functions {"Herero", "her"}, {"Hindi", "hin"}, {"Hiri Motu", "hmo"}, - {"Hungarian", "hun"}, + {"Magyar", "hun"}, {"Igbo", "ibo"}, - {"Icelandic", "isl"}, + {"Islenska", "isl"}, {"Ido", "ido"}, {"Sichuan Yi", "iii"}, {"Inuktitut", "iku"}, @@ -511,7 +511,7 @@ namespace Handbrake.Functions {"Interlingua", "ina"}, {"Indonesian", "ind"}, {"Inupiaq", "ipk"}, - {"Italian", "ita"}, + {"Italiano", "ita"}, {"Javanese", "jav"}, {"Japanese", "jpn"}, {"Kalaallisut", "kal"}, @@ -555,7 +555,7 @@ namespace Handbrake.Functions {"Nepali", "nep"}, {"Norwegian Nynorsk", "nno"}, {"Norwegian Bokmål", "nob"}, - {"Norwegian", "nor"}, + {"Norsk", "nor"}, {"Chichewa; Nyanja", "nya"}, {"Occitan", "oci"}, {"Ojibwa", "oji"}, @@ -566,7 +566,7 @@ namespace Handbrake.Functions {"Persian", "fas"}, {"Pali", "pli"}, {"Polish", "pol"}, - {"Portuguese", "por"}, + {"Portugues", "por"}, {"Pushto", "pus"}, {"Quechua", "que"}, {"Romansh", "roh"}, @@ -576,7 +576,7 @@ namespace Handbrake.Functions {"Sango", "sag"}, {"Sanskrit", "san"}, {"Serbian", "srp"}, - {"Croatian", "hrv"}, + {"Hrvatski", "hrv"}, {"Sinhala", "sin"}, {"Slovak", "slk"}, {"Slovenian", "slv"}, @@ -586,12 +586,12 @@ namespace Handbrake.Functions {"Sindhi", "snd"}, {"Somali", "som"}, {"Sotho Southern", "sot"}, - {"Spanish", "spa"}, + {"Espanol", "spa"}, {"Sardinian", "srd"}, {"Swati", "ssw"}, {"Sundanese", "sun"}, {"Swahili", "swa"}, - {"Swedish", "swe"}, + {"Svenska", "swe"}, {"Tahitian", "tah"}, {"Tamil", "tam"}, {"Tatar", "tat"}, diff --git a/win/C#/HandBrakeCS.csproj b/win/C#/HandBrakeCS.csproj index fda90e51..3f9aa4de 100644 --- a/win/C#/HandBrakeCS.csproj +++ b/win/C#/HandBrakeCS.csproj @@ -297,6 +297,7 @@ frmSplashScreen.cs + diff --git a/win/C#/Parsing/AudioTrack.cs b/win/C#/Parsing/AudioTrack.cs index 86c2b6e0..c4e1bbc2 100644 --- a/win/C#/Parsing/AudioTrack.cs +++ b/win/C#/Parsing/AudioTrack.cs @@ -22,6 +22,7 @@ namespace Handbrake.Parsing private string m_language; private string m_subFormat; private int m_trackNumber; + private string m_iso639_2; /// /// The track number of this Audio Track @@ -71,6 +72,11 @@ namespace Handbrake.Parsing get { return m_bitrate; } } + public string ISO639_2 + { + get { return m_iso639_2; } + } + /// /// Override of the ToString method to make this object easier to use in the UI /// @@ -86,34 +92,29 @@ namespace Handbrake.Parsing public static AudioTrack Parse(StringReader output) { String audio_track = output.ReadLine(); - Match m = Regex.Match(audio_track, - @"^ \+ ([0-9]*), ([A-Za-z0-9]*) \((.*)\) \((.*)\), ([0-9]*)Hz, ([0-9]*)bps"); - Match y = Regex.Match(audio_track, @"^ \+ ([0-9]*), ([A-Za-z0-9]*) \((.*)\)"); - if (m.Success) - { - var thisTrack = new AudioTrack - { - m_trackNumber = int.Parse(m.Groups[1].Value.Trim()), - m_language = m.Groups[2].Value, - m_format = m.Groups[3].Value, - m_subFormat = m.Groups[4].Value, - m_frequency = int.Parse(m.Groups[5].Value.Trim()), - m_bitrate = int.Parse(m.Groups[6].Value.Trim()) - }; - return thisTrack; - } - - if (y.Success) + Match m = Regex.Match(audio_track, @"^ \+ ([0-9]*), ([A-Za-z0-9]*) \((.*)\) \((.*)\)"); + Match track = Regex.Match(audio_track, @"^ \+ ([0-9]*), ([A-Za-z0-9]*) \((.*)\)"); // ID and Language + Match iso639_2 = Regex.Match(audio_track, @"iso639-2: ([a-zA-Z]*)\)"); + Match samplerate = Regex.Match(audio_track, @"([0-9]*)Hz"); + Match bitrate = Regex.Match(audio_track, @"([0-9]*)bps"); + + string subformat = m.Groups[4].Value.Trim().Contains("iso639") ? null : m.Groups[4].Value; + + if (track.Success) { var thisTrack = new AudioTrack - { - m_trackNumber = int.Parse(y.Groups[1].Value.Trim()), - m_language = y.Groups[2].Value, - m_format = y.Groups[3].Value - }; - return thisTrack; + { + m_trackNumber = int.Parse(track.Groups[1].Value.Trim()), + m_language = track.Groups[2].Value, + m_format = m.Groups[3].Value, + m_subFormat = subformat, + m_frequency = int.Parse(samplerate.Groups[0].Value.Replace("Hz","").Trim()), + m_bitrate = int.Parse(bitrate.Groups[0].Value.Replace("bps","").Trim()), + m_iso639_2 = iso639_2.Value.Replace("iso639-2: ", "").Replace(")", "") + }; + return thisTrack; } - + return null; } diff --git a/win/C#/Properties/Settings.Designer.cs b/win/C#/Properties/Settings.Designer.cs index d7405442..f1cc044f 100644 --- a/win/C#/Properties/Settings.Designer.cs +++ b/win/C#/Properties/Settings.Designer.cs @@ -1,7 +1,7 @@ //------------------------------------------------------------------------------ // // This code was generated by a tool. -// Runtime Version:2.0.50727.4918 +// Runtime Version:2.0.50727.3082 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. @@ -417,5 +417,29 @@ namespace Handbrake.Properties { this["PromptOnUnmatchingQueries"] = value; } } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("Any")] + public string NativeLanguage { + get { + return ((string)(this["NativeLanguage"])); + } + set { + this["NativeLanguage"] = value; + } + } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("False")] + public bool DubAudio { + get { + return ((bool)(this["DubAudio"])); + } + set { + this["DubAudio"] = value; + } + } } } diff --git a/win/C#/Properties/Settings.settings b/win/C#/Properties/Settings.settings index 5f43ded6..ebd6f44f 100644 --- a/win/C#/Properties/Settings.settings +++ b/win/C#/Properties/Settings.settings @@ -101,5 +101,11 @@ True + + Any + + + False + \ No newline at end of file diff --git a/win/C#/app.config b/win/C#/app.config index 1545f33d..eb64a36b 100644 --- a/win/C#/app.config +++ b/win/C#/app.config @@ -106,6 +106,12 @@ True + + Any + + + False + diff --git a/win/C#/frmOptions.Designer.cs b/win/C#/frmOptions.Designer.cs index 697ca263..b24ec2ba 100644 --- a/win/C#/frmOptions.Designer.cs +++ b/win/C#/frmOptions.Designer.cs @@ -61,6 +61,8 @@ namespace Handbrake this.label29 = new System.Windows.Forms.Label(); this.btn_vlcPath = new System.Windows.Forms.Button(); this.txt_vlcPath = new System.Windows.Forms.TextBox(); + this.tab_audio_sub = new System.Windows.Forms.TabPage(); + this.drop_preferredLang = new System.Windows.Forms.ComboBox(); this.tab_cli = new System.Windows.Forms.TabPage(); this.tableLayoutPanel3 = new System.Windows.Forms.TableLayoutPanel(); this.label12 = new System.Windows.Forms.Label(); @@ -128,11 +130,16 @@ namespace Handbrake this.label27 = new System.Windows.Forms.Label(); this.openFile_vlc = new System.Windows.Forms.OpenFileDialog(); this.tableLayoutPanel5 = new System.Windows.Forms.TableLayoutPanel(); + this.label15 = new System.Windows.Forms.Label(); + this.radio_dub = new System.Windows.Forms.RadioButton(); + this.radio_foreignAndSubs = new System.Windows.Forms.RadioButton(); + this.label31 = new System.Windows.Forms.Label(); this.tab_options.SuspendLayout(); this.tab_general.SuspendLayout(); this.tableLayoutPanel1.SuspendLayout(); this.tab_picture.SuspendLayout(); this.tableLayoutPanel2.SuspendLayout(); + this.tab_audio_sub.SuspendLayout(); this.tab_cli.SuspendLayout(); this.tableLayoutPanel3.SuspendLayout(); this.tab_advanced.SuspendLayout(); @@ -182,6 +189,7 @@ namespace Handbrake this.tableLayoutPanel5.SetColumnSpan(this.tab_options, 2); this.tab_options.Controls.Add(this.tab_general); this.tab_options.Controls.Add(this.tab_picture); + this.tab_options.Controls.Add(this.tab_audio_sub); this.tab_options.Controls.Add(this.tab_cli); this.tab_options.Controls.Add(this.tab_advanced); this.tab_options.Dock = System.Windows.Forms.DockStyle.Fill; @@ -522,6 +530,33 @@ namespace Handbrake "ew feature."); this.txt_vlcPath.TextChanged += new System.EventHandler(this.txt_vlcPath_TextChanged); // + // tab_audio_sub + // + this.tab_audio_sub.Controls.Add(this.label31); + this.tab_audio_sub.Controls.Add(this.label15); + this.tab_audio_sub.Controls.Add(this.radio_foreignAndSubs); + this.tab_audio_sub.Controls.Add(this.drop_preferredLang); + this.tab_audio_sub.Controls.Add(this.radio_dub); + this.tab_audio_sub.Location = new System.Drawing.Point(4, 22); + this.tab_audio_sub.Name = "tab_audio_sub"; + this.tab_audio_sub.Padding = new System.Windows.Forms.Padding(3); + this.tab_audio_sub.Size = new System.Drawing.Size(580, 306); + this.tab_audio_sub.TabIndex = 6; + this.tab_audio_sub.Text = "Audio / Subtitles"; + this.tab_audio_sub.UseVisualStyleBackColor = true; + // + // drop_preferredLang + // + this.drop_preferredLang.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.drop_preferredLang.FormattingEnabled = true; + this.drop_preferredLang.Location = new System.Drawing.Point(200, 16); + this.drop_preferredLang.Name = "drop_preferredLang"; + this.drop_preferredLang.Size = new System.Drawing.Size(118, 21); + this.drop_preferredLang.TabIndex = 87; + this.ToolTip.SetToolTip(this.drop_preferredLang, "The number of processor\'s / processor cores. Unless your having problems, leave o" + + "n Automatic."); + this.drop_preferredLang.SelectedIndexChanged += new System.EventHandler(this.drop_preferredLang_SelectedIndexChanged); + // // tab_cli // this.tab_cli.Controls.Add(this.tableLayoutPanel3); @@ -1421,6 +1456,51 @@ namespace Handbrake this.tableLayoutPanel5.Size = new System.Drawing.Size(594, 405); this.tableLayoutPanel5.TabIndex = 62; // + // label15 + // + this.label15.AutoSize = true; + this.label15.Location = new System.Drawing.Point(87, 19); + this.label15.Name = "label15"; + this.label15.Size = new System.Drawing.Size(107, 13); + this.label15.TabIndex = 88; + this.label15.Text = "Preferred Language:"; + // + // radio_dub + // + this.radio_dub.AutoSize = true; + this.radio_dub.Location = new System.Drawing.Point(200, 53); + this.radio_dub.Name = "radio_dub"; + this.radio_dub.Size = new System.Drawing.Size(164, 17); + this.radio_dub.TabIndex = 89; + this.radio_dub.TabStop = true; + this.radio_dub.Text = "DUB Foreign Language Audio"; + this.radio_dub.UseVisualStyleBackColor = true; + this.radio_dub.CheckedChanged += new System.EventHandler(this.radio_dub_CheckedChanged); + // + // radio_foreignAndSubs + // + this.radio_foreignAndSubs.AutoSize = true; + this.radio_foreignAndSubs.Location = new System.Drawing.Point(200, 76); + this.radio_foreignAndSubs.Name = "radio_foreignAndSubs"; + this.radio_foreignAndSubs.Size = new System.Drawing.Size(241, 17); + this.radio_foreignAndSubs.TabIndex = 90; + this.radio_foreignAndSubs.TabStop = true; + this.radio_foreignAndSubs.Text = "Use foreign language audio and add subtitles"; + this.radio_foreignAndSubs.UseVisualStyleBackColor = true; + this.radio_foreignAndSubs.CheckedChanged += new System.EventHandler(this.radio_foreignAndSubs_CheckedChanged); + // + // label31 + // + this.label31.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.label31.AutoSize = true; + this.label31.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.label31.Location = new System.Drawing.Point(16, 19); + this.label31.Margin = new System.Windows.Forms.Padding(3, 5, 3, 0); + this.label31.Name = "label31"; + this.label31.Size = new System.Drawing.Size(52, 13); + this.label31.TabIndex = 91; + this.label31.Text = "Actions:"; + // // frmOptions // this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F); @@ -1449,6 +1529,8 @@ namespace Handbrake this.tab_picture.PerformLayout(); this.tableLayoutPanel2.ResumeLayout(false); this.tableLayoutPanel2.PerformLayout(); + this.tab_audio_sub.ResumeLayout(false); + this.tab_audio_sub.PerformLayout(); this.tab_cli.ResumeLayout(false); this.tab_cli.PerformLayout(); this.tableLayoutPanel3.ResumeLayout(false); @@ -1559,5 +1641,11 @@ namespace Handbrake private System.Windows.Forms.TableLayoutPanel tableLayoutPanel4; private System.Windows.Forms.TableLayoutPanel tableLayoutPanel5; private System.Windows.Forms.CheckBox check_promptOnUnmatchingQueries; + private System.Windows.Forms.TabPage tab_audio_sub; + internal System.Windows.Forms.ComboBox drop_preferredLang; + private System.Windows.Forms.Label label31; + private System.Windows.Forms.RadioButton radio_foreignAndSubs; + private System.Windows.Forms.RadioButton radio_dub; + private System.Windows.Forms.Label label15; } } \ No newline at end of file diff --git a/win/C#/frmOptions.cs b/win/C#/frmOptions.cs index 174b8601..66adf04e 100644 --- a/win/C#/frmOptions.cs +++ b/win/C#/frmOptions.cs @@ -5,6 +5,7 @@ It may be used under the terms of the GNU General Public License. */ using System; +using System.Collections.Generic; using System.Globalization; using System.Windows.Forms; using Handbrake.Functions; @@ -16,6 +17,9 @@ namespace Handbrake public frmOptions() { InitializeComponent(); + IDictionary langList = Main.mapLanguages(); + foreach (string item in langList.Keys) + drop_preferredLang.Items.Add(item); // ############################# // General @@ -63,6 +67,18 @@ namespace Handbrake txt_vlcPath.Text = Properties.Settings.Default.VLC_Path; // ############################# + // Audio and Subtitles Tab + // ############################# + + drop_preferredLang.SelectedItem = Properties.Settings.Default.NativeLanguage; + + if (Properties.Settings.Default.DubAudio) + radio_dub.Checked = true; + else + radio_foreignAndSubs.Checked = true; + + + // ############################# // CLI // ############################# @@ -212,6 +228,23 @@ namespace Handbrake } #endregion + #region Audio and Subtitles + private void drop_preferredLang_SelectedIndexChanged(object sender, EventArgs e) + { + Properties.Settings.Default.NativeLanguage = drop_preferredLang.SelectedItem.ToString(); + } + private void radio_dub_CheckedChanged(object sender, EventArgs e) + { + if (radio_dub.Checked) + Properties.Settings.Default.DubAudio = true; + } + private void radio_foreignAndSubs_CheckedChanged(object sender, EventArgs e) + { + if (radio_foreignAndSubs.Checked) + Properties.Settings.Default.DubAudio = false; + } + #endregion + #region CLI private void check_cli_minimized_CheckedChanged(object sender, EventArgs e) { @@ -362,5 +395,6 @@ namespace Handbrake Properties.Settings.Default.Save(); // Small hack for Vista. Seems to work fine on XP without this this.Close(); } + } } \ No newline at end of file diff --git a/win/C#/frmOptions.resx b/win/C#/frmOptions.resx index 139d8245..427cdd96 100644 --- a/win/C#/frmOptions.resx +++ b/win/C#/frmOptions.resx @@ -120,6 +120,9 @@ 132, 18 + + 132, 18 + 17, 17 -- 2.11.0