From fb24594c5c34653d0841ccb735d8eecd00d06178 Mon Sep 17 00:00:00 2001 From: niksedk Date: Fri, 8 Apr 2011 13:21:37 +0000 Subject: [PATCH] Defect 20/21 - applied logic from Hawk's patches, so SE runs better on Linux :) git-svn-id: https://subtitleedit.googlecode.com/svn/trunk@387 99eadd0c-20b8-1223-b5c4-2a2b2df33de2 --- src/Forms/VobSubOcr.cs | 15 +++++++++++---- src/Logic/OCR/OcrFixEngine.cs | 15 +++++++++++---- src/Logic/Utilities.cs | 6 ++++++ src/Logic/VideoPlayers/LibVlcDynamic.cs | 3 +++ 4 files changed, 31 insertions(+), 8 deletions(-) diff --git a/src/Forms/VobSubOcr.cs b/src/Forms/VobSubOcr.cs index 20f103d7e..70d17aade 100644 --- a/src/Forms/VobSubOcr.cs +++ b/src/Forms/VobSubOcr.cs @@ -1,5 +1,4 @@ - -using System; +using System; using System.Collections.Generic; using System.ComponentModel; using System.Diagnostics; @@ -1248,9 +1247,17 @@ namespace Nikse.SubtitleEdit.Forms Process process = new Process(); process.StartInfo = new ProcessStartInfo(Configuration.TesseractFolder + "tesseract.exe"); + process.StartInfo.UseShellExecute = true; process.StartInfo.Arguments = "\"" + tempTiffFileName + "\" \"" + tempTextFileName + "\" -l " + language; process.StartInfo.WorkingDirectory = (Configuration.TesseractFolder); process.StartInfo.WindowStyle = ProcessWindowStyle.Hidden; + + if (Utilities.IsRunningOnLinux()) + { + process.StartInfo.FileName = "tesseract"; + process.StartInfo.UseShellExecute = false; + } + process.Start(); process.WaitForExit(5000); @@ -1535,9 +1542,9 @@ namespace Nikse.SubtitleEdit.Forms foreach (var culture in System.Globalization.CultureInfo.GetCultures(System.Globalization.CultureTypes.NeutralCultures)) { string tesseractName = culture.ThreeLetterISOLanguageName; - if (culture.LCID == 0x4 && !File.Exists(dir + "\\" + tesseractName + ".traineddata")) + if (culture.LCID == 0x4 && !File.Exists(dir + Path.PathSeparator + tesseractName + ".traineddata")) tesseractName = "chi_sim"; - string trainDataFileName = dir + "\\" + tesseractName + ".traineddata"; + string trainDataFileName = dir + Path.PathSeparator + tesseractName + ".traineddata"; if (!list.Contains(culture.ThreeLetterISOLanguageName) && File.Exists(trainDataFileName)) { list.Add(culture.ThreeLetterISOLanguageName); diff --git a/src/Logic/OCR/OcrFixEngine.cs b/src/Logic/OCR/OcrFixEngine.cs index 831f1eb55..0384a010b 100644 --- a/src/Logic/OCR/OcrFixEngine.cs +++ b/src/Logic/OCR/OcrFixEngine.cs @@ -186,10 +186,17 @@ namespace Nikse.SubtitleEdit.Logic.OCR } // Load NHunspell spellchecker - _hunspell = new Hunspell(dictionary + ".aff", dictionary + ".dic"); - IsDictionaryLoaded = true; - _spellCheckDictionaryName = dictionary; - DictionaryCulture = culture; + try + { + _hunspell = new Hunspell(dictionary + ".aff", dictionary + ".dic"); + IsDictionaryLoaded = true; + _spellCheckDictionaryName = dictionary; + DictionaryCulture = culture; + } + catch + { + IsDictionaryLoaded = false; + } } public string SpellCheckDictionaryName diff --git a/src/Logic/Utilities.cs b/src/Logic/Utilities.cs index 31394e0b1..00c3ef9dc 100644 --- a/src/Logic/Utilities.cs +++ b/src/Logic/Utilities.cs @@ -1031,6 +1031,12 @@ namespace Nikse.SubtitleEdit.Logic return Type.GetType("Mono.Runtime") != null; } + public static bool IsRunningOnLinux() + { + int p = (int)Environment.OSVersion.Platform; + return (p == 4 || p == 6 || p == 128); + } + public static void ShowHelp(string parameter) { string helpFile = Configuration.Settings.Language.General.HelpFile; diff --git a/src/Logic/VideoPlayers/LibVlcDynamic.cs b/src/Logic/VideoPlayers/LibVlcDynamic.cs index ba9a5ac75..40b3b321a 100644 --- a/src/Logic/VideoPlayers/LibVlcDynamic.cs +++ b/src/Logic/VideoPlayers/LibVlcDynamic.cs @@ -401,6 +401,9 @@ namespace Nikse.SubtitleEdit.Logic.VideoPlayers public static string GetVlcPath(string fileName) { + if (Utilities.IsRunningOnLinux()) + return null; + string path; path = Path.Combine(Configuration.BaseDirectory, @"VLC\" + fileName);