From 04e2d5d670d905a22ad5b19b83f4758c5647b10f Mon Sep 17 00:00:00 2001 From: niksedk Date: Wed, 19 Mar 2014 20:49:12 +0100 Subject: [PATCH] Added an "Update all" button for the plugin window --- .gitignore | 2 + src/Changelog.txt | 2 + src/Forms/PluginsGet.Designer.cs | 14 +++++ src/Forms/PluginsGet.cs | 102 +++++++++++++++++++++++++------ src/Languages/da-DK.xml | 17 ++++++ src/Logic/Language.cs | 4 +- src/Logic/LanguageStructure.cs | 2 + 7 files changed, 125 insertions(+), 18 deletions(-) diff --git a/.gitignore b/.gitignore index 90768a5dd..d9aa1ab62 100644 --- a/.gitignore +++ b/.gitignore @@ -12,3 +12,5 @@ /SubtitleEdit-*-setup.exe /src/SubtitleEdit.csproj.user /src/Languages/Language.xml +/src/Languages/LanguageMaster.xml +/src/Languages/XmlContentTranslator.exe diff --git a/src/Changelog.txt b/src/Changelog.txt index 69024adf3..4eb99f8b4 100644 --- a/src/Changelog.txt +++ b/src/Changelog.txt @@ -9,6 +9,7 @@ * Added shortcut for Tools -> "Split long lines" - thx John * Added shortcut for Sync -> "Change frame rate" - thx Alfonso * Added setting regarding "Fix short display times" - thx S1l3nc0r + * Added an "Update all" button for the plugin window * IMPROVED: * Updated French language file - thx JM GBT * Updated Dutch language file - thx Quetsbeek @@ -22,6 +23,7 @@ * Some fixes for move word up/down - thx rebawest * Delete custom export format now works - thx Leon * Possible crash in OCR window - thx grfilho + * Dcinema smpte sometimes generated illegal frame numbers - thx knut 3.3.14 (23rd February 2014) diff --git a/src/Forms/PluginsGet.Designer.cs b/src/Forms/PluginsGet.Designer.cs index 7380f1ce2..b482bc91e 100644 --- a/src/Forms/PluginsGet.Designer.cs +++ b/src/Forms/PluginsGet.Designer.cs @@ -48,6 +48,7 @@ this.columnHeaderInsType = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); this.tabPageGetPlugins = new System.Windows.Forms.TabPage(); this.labelPleaseWait = new System.Windows.Forms.Label(); + this.buttonUpdateAll = new System.Windows.Forms.Button(); this.tabControlPlugins.SuspendLayout(); this.tabPageInstalledPlugins.SuspendLayout(); this.tabPageGetPlugins.SuspendLayout(); @@ -160,6 +161,7 @@ // // tabPageInstalledPlugins // + this.tabPageInstalledPlugins.Controls.Add(this.buttonUpdateAll); this.tabPageInstalledPlugins.Controls.Add(this.buttonRemove); this.tabPageInstalledPlugins.Controls.Add(this.listViewInstalledPlugins); this.tabPageInstalledPlugins.Location = new System.Drawing.Point(4, 22); @@ -246,6 +248,17 @@ this.labelPleaseWait.TabIndex = 28; this.labelPleaseWait.Text = "Please wait..."; // + // buttonUpdateAll + // + this.buttonUpdateAll.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonUpdateAll.Location = new System.Drawing.Point(510, 375); + this.buttonUpdateAll.Name = "buttonUpdateAll"; + this.buttonUpdateAll.Size = new System.Drawing.Size(134, 25); + this.buttonUpdateAll.TabIndex = 30; + this.buttonUpdateAll.Text = "Updata all"; + this.buttonUpdateAll.UseVisualStyleBackColor = true; + this.buttonUpdateAll.Click += new System.EventHandler(this.buttonUpdateAll_Click); + // // PluginsGet // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); @@ -295,5 +308,6 @@ private System.Windows.Forms.ColumnHeader columnHeaderInsType; private System.Windows.Forms.TabPage tabPageGetPlugins; private System.Windows.Forms.Label labelPleaseWait; + private System.Windows.Forms.Button buttonUpdateAll; } } \ No newline at end of file diff --git a/src/Forms/PluginsGet.cs b/src/Forms/PluginsGet.cs index 7f31294f1..aaeaa2877 100644 --- a/src/Forms/PluginsGet.cs +++ b/src/Forms/PluginsGet.cs @@ -16,13 +16,17 @@ namespace Nikse.SubtitleEdit.Forms private XmlDocument _pluginDoc = new XmlDocument(); private string _downloadedPluginName; readonly LanguageStructure.PluginsGet _language; - bool _firstTry = true; +// bool _firstTry = true; + List _updateAllListUrls; + List _updateAllListNames; + bool _updatingAllPlugins = false; + int _updatingAllPluginsCount = 0; private string GetPluginXmlFileUrl() { if (Environment.Version.Major < 4) - return "https://raw.github.com/SubtitleEdit/plugins/master/Plugins2.xml"; - return "https://raw.github.com/SubtitleEdit/plugins/master/Plugins4.xml"; + return "https://raw.github.com/SubtitleEdit/plugins/master/Plugins2.xml"; // .net 2-3.5 + return "https://raw.github.com/SubtitleEdit/plugins/master/Plugins4.xml"; // .net 4-? } public PluginsGet() @@ -34,7 +38,7 @@ namespace Nikse.SubtitleEdit.Forms tabPageGetPlugins.Text = _language.GetPlugins; buttonDownload.Text = _language.Download; - buttonRemove.Text = _language.Remove; + buttonRemove.Text = _language.Remove; buttonOK.Text = Configuration.Settings.Language.General.OK; linkLabelOpenPluginFolder.Text = _language.OpenPluginsFolder; labelDescription1.Text = _language.GetPluginsInfo1; @@ -50,6 +54,7 @@ namespace Nikse.SubtitleEdit.Forms columnHeaderInsVersion.Text = _language.Version; columnHeaderInsType.Text = _language.Type; + buttonUpdateAll.Visible = false; try { labelPleaseWait.Text = Configuration.Settings.Language.General.PleaseWait; @@ -74,17 +79,17 @@ namespace Nikse.SubtitleEdit.Forms void wc_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e) { - if (e.Error != null && _firstTry) - { - _firstTry = false; - string url = "http://www.nikse.dk/Content/SubtitleEdit/Plugins/Plugins.xml"; // retry with alternate download url - var wc = new WebClient { Proxy = Utilities.GetProxy() }; - wc.Encoding = System.Text.Encoding.UTF8; - wc.Headers.Add("Accept-Encoding", ""); - wc.DownloadStringCompleted += new DownloadStringCompletedEventHandler(wc_DownloadStringCompleted); - wc.DownloadStringAsync(new Uri(url)); - return; - } + //if (e.Error != null && _firstTry) + //{ + // _firstTry = false; + // string url = "http://www.nikse.dk/Content/SubtitleEdit/Plugins/Plugins.xml"; // retry with alternate download url + // var wc = new WebClient { Proxy = Utilities.GetProxy() }; + // wc.Encoding = System.Text.Encoding.UTF8; + // wc.Headers.Add("Accept-Encoding", ""); + // wc.DownloadStringCompleted += new DownloadStringCompletedEventHandler(wc_DownloadStringCompleted); + // wc.DownloadStringAsync(new Uri(url)); + // return; + //} labelPleaseWait.Text = string.Empty; if (e.Error != null) @@ -96,6 +101,8 @@ namespace Nikse.SubtitleEdit.Forms } return; } + _updateAllListUrls = new List(); + _updateAllListNames = new List(); try { _pluginDoc.LoadXml(e.Result); @@ -125,9 +132,12 @@ namespace Nikse.SubtitleEdit.Forms if (installed.Text.TrimEnd('.') == node.SelectSingleNode("Name").InnerText.TrimEnd('.') && installed.SubItems[2].Text.Replace(",", ".") != node.SelectSingleNode("Version").InnerText.Replace(",", ".")) { - item.BackColor = Color.LightGreen; +// item.BackColor = Color.LightGreen; installed.BackColor = Color.LightPink; installed.SubItems[1].Text = _language.UpdateAvailable + " " + installed.SubItems[1].Text; + buttonUpdateAll.Visible = true; + _updateAllListUrls.Add(node.SelectSingleNode("Url").InnerText); + _updateAllListNames.Add(node.SelectSingleNode("Name").InnerText); } } } @@ -136,6 +146,20 @@ namespace Nikse.SubtitleEdit.Forms { MessageBox.Show(string.Format(_language.UnableToDownloadPluginListX, exception.Source + ": " + exception.Message + Environment.NewLine + Environment.NewLine + exception.StackTrace)); } + if (_updateAllListUrls.Count > 0) + { + buttonUpdateAll.BackColor = Color.LightGreen; + if (!string.IsNullOrEmpty(Configuration.Settings.Language.PluginsGet.UpdateAllX)) + { + buttonUpdateAll.Text = string.Format(Configuration.Settings.Language.PluginsGet.UpdateAllX, _updateAllListUrls.Count); + buttonUpdateAll.Visible = true; + } + else if (!string.IsNullOrEmpty(Configuration.Settings.Language.PluginsGet.UpdateAll)) + { + buttonUpdateAll.Text = Configuration.Settings.Language.PluginsGet.UpdateAll; + buttonUpdateAll.Visible = true; + } + } } private void ShowInstalledPlugins() @@ -264,7 +288,18 @@ namespace Nikse.SubtitleEdit.Forms buttonOK.Enabled = true; buttonDownload.Enabled = true; listViewGetPlugins.Enabled = true; - MessageBox.Show(string.Format(_language.PluginXDownloaded, _downloadedPluginName)); + if (_updatingAllPlugins) + { + _updatingAllPluginsCount++; + if (_updatingAllPluginsCount == _updateAllListUrls.Count) + { + MessageBox.Show(string.Format(_language.XPluginsUpdated, _updatingAllPluginsCount)); + } + } + else + { + MessageBox.Show(string.Format(_language.PluginXDownloaded, _downloadedPluginName)); + } ShowInstalledPlugins(); } @@ -335,5 +370,38 @@ namespace Nikse.SubtitleEdit.Forms } } + private void buttonUpdateAll_Click(object sender, EventArgs e) + { + buttonUpdateAll.Enabled = false; + buttonUpdateAll.BackColor = Control.DefaultBackColor; + try + { + labelPleaseWait.Text = Configuration.Settings.Language.General.PleaseWait; + buttonOK.Enabled = false; + buttonDownload.Enabled = false; + listViewGetPlugins.Enabled = false; + this.Refresh(); + Cursor = Cursors.WaitCursor; + _updatingAllPluginsCount = 0; + _updatingAllPlugins = true; + for (int i = 0; i < _updateAllListUrls.Count; i++) + { + var wc = new WebClient { Proxy = Utilities.GetProxy() }; + wc.DownloadDataCompleted += new DownloadDataCompletedEventHandler(wc_DownloadDataCompleted); + wc.DownloadDataAsync(new Uri(_updateAllListUrls[i])); + } + Cursor = Cursors.Default; + } + catch (Exception exception) + { + labelPleaseWait.Text = string.Empty; + buttonOK.Enabled = true; + buttonDownload.Enabled = true; + listViewGetPlugins.Enabled = true; + Cursor = Cursors.Default; + MessageBox.Show(exception.Message + Environment.NewLine + Environment.NewLine + exception.StackTrace); + } + } + } } diff --git a/src/Languages/da-DK.xml b/src/Languages/da-DK.xml index 9612a55c8..006ab1b7a 100644 --- a/src/Languages/da-DK.xml +++ b/src/Languages/da-DK.xml @@ -248,6 +248,9 @@ E-mail: mailto:nikse.dk@gmail.com Effekt Effekt farve Str. + Top/bund margin + Z-position + positive tal flytter tekst væk, negative tal flytter tekst tættere på, hvis z-position er nul så er det 2D Vælg farve... Generer @@ -365,6 +368,7 @@ E-mail: mailto:nikse.dk@gmail.com Alpha Billed format Simpel rendering + Anti-aliasing med gennemsigtighed 3D Half-Side-by-side Half-Top/Bottom @@ -812,6 +816,7 @@ E-mail: mailto:nikse.dk@gmail.com Gem som Find Erstat + Fix almindelige fejl Visuel synkroniser Stavekontrol Indstillinger @@ -1119,6 +1124,7 @@ Fortsæt? '{0} -> {1}' blev IKKE tilføjet til OCR erstat listen {0} linjer valgt Undertekst indeholder unicode tegn. Gemmes i ANSI filformat vil disse gå tabt. Fortsæt? + Undertekst indeholder Unicode-tegn. Ved gem i ANSI filkodning vil disse gå tabt. Fortsæt gem? Undertekst indeholder negative tidskoder. Gem? Før fusionere korte linjer Før split lange linjer @@ -1178,6 +1184,7 @@ Fortsæt? Ikke en valid xsub fil! Før fusioner linjer med samme tekst Undertekst med tidskoder har et forskelligt antal linier ({0}) end nuværende undertekst ({1}) - fortsæt alligevel? + Læser transport stream - vent venligst... Subtitle Edit kan ikke læse/redigere .idx filer. Idx filer er en del af et idx/sub fil par (også kaldet VobSub), og SE kan kun åbne .sub filen. Denne fil er sandsynligvis en komprimeret .rar fil. SE kan ikke åbne komprimerede filer. Denne fil er sandsynligvis en komprimeret .zip fil. SE kan ikke åbne komprimerede filer. @@ -1297,9 +1304,11 @@ Fortsæt? Plugin {0} downloadet &Download &Fjern + Opdater alle ({0}) Kunne ikke downloade plug liste: {0} Nyere version af Subtitle Edit kræves! [Ny version findes!] + Opdater alle Fjern tekst for hørehæmmede @@ -1392,6 +1401,8 @@ Fortsæt? Auto-ombryd tekst mens du skriver Min. varighed, millisekunder Max. varighed, millisekunder + + undertekst skrifttype undertekst skriftstørrelse Fed @@ -1433,6 +1444,8 @@ Fortsæt? MPlayer2/Mplayer VLC Media Player libvlc.dll fra VLC Media Player 1.1.0 eller nyere + + Vis stop-knap Vis mute-knap Vis fuldskærm knap @@ -1462,6 +1475,8 @@ Fortsæt? Benyt FFMPEG til at udtrække lydfiler Sti til FFMPEG Vælg sti stil FFMPEG + + Sub Station Alpha Style Vælg skrifttype Vælg farve @@ -1500,6 +1515,8 @@ Fortsæt? Musik symbol Musik symboler der skal erstattes (adskilt af mellemrum) Ret normale OCR fejl - Inkluder hardcodede regler + + Genveje Genvej Control diff --git a/src/Logic/Language.cs b/src/Logic/Language.cs index ec31664b6..c24350221 100644 --- a/src/Logic/Language.cs +++ b/src/Logic/Language.cs @@ -1558,10 +1558,12 @@ can edit in same subtitle file (collaboration)", PluginXDownloaded = "Plugin {0} downloaded", Download = "&Download", Remove = "&Remove", + UpdateAllX = "Update all ({0})", UnableToDownloadPluginListX = "Unable to download plug list: {0}", NewVersionOfSubtitleEditRequired = "Newer version of Subtitle Edit required!", UpdateAvailable = "[Update available!]", UpdateAll = "Update all", + XPluginsUpdated = "{0} plugin(s) updated", }; RemoveTextFromHearImpaired = new LanguageStructure.RemoveTextFromHearImpaired @@ -1710,7 +1712,7 @@ can edit in same subtitle file (collaboration)", MPlayerDescription = "MPlayer2/Mplayer", VlcMediaPlayer = "VLC Media Player", VlcMediaPlayerDescription = "libvlc.dll from VLC Media Player 1.1.0 or newer", - VlcBrowseToLabel = "VLC path (only needed if you using the portable version of VLC)", + VlcBrowseToLabel = "VLC path (only needed if you're using the portable version of VLC)", ShowStopButton = "Show stop button", ShowMuteButton = "Show mute button", ShowFullscreenButton = "Show fullscreen button", diff --git a/src/Logic/LanguageStructure.cs b/src/Logic/LanguageStructure.cs index 0fc9c5c5e..1b0d14105 100644 --- a/src/Logic/LanguageStructure.cs +++ b/src/Logic/LanguageStructure.cs @@ -1453,10 +1453,12 @@ public string PluginXDownloaded { get; set; } public string Download { get; set; } public string Remove { get; set; } + public string UpdateAllX { get; set; } public string UnableToDownloadPluginListX { get; set; } public string NewVersionOfSubtitleEditRequired { get; set; } public string UpdateAvailable { get; set; } public string UpdateAll { get; set; } + public string XPluginsUpdated { get; set; } } public class RemoveTextFromHearImpaired