[gnome-subtitles] Allow to set default encoding for opening files (fixes part of #504656)



commit 17138750821892d07120d1d020088156dabf6ced
Author: Pedro Castro <mail>
Date:   Sun Jan 10 19:18:44 2010 +0000

    Allow to set default encoding for opening files (fixes part of #504656)
    
    - Allow to set file opening encoding in settings (allow for auto detect, remember last
    value, current locale or specific encoding
    - Opening files from the desktop (terminal/nautilus/etc) also uses this option
    - Refactored encoding combo boxes as reusable components

 data/gnome-subtitles.schemas                       |   44 ++++
 gnome-subtitles.mdp                                |    4 +-
 src/Glade/FileOpenDialog.glade                     |    4 +-
 src/Glade/FileSaveAsDialog.glade                   |    7 +-
 src/Glade/PreferencesDialog.glade                  |  262 ++++++++++++++++++--
 src/GnomeSubtitles/Core/Config.cs                  |   65 +++++-
 src/GnomeSubtitles/Dialog/FileOpenDialog.cs        |   97 +++++---
 src/GnomeSubtitles/Dialog/PreferencesDialog.cs     |   60 +++++-
 .../Dialog/SubtitleFileChooserDialog.cs            |  196 ---------------
 src/GnomeSubtitles/Ui/Component/ComboBoxUtil.cs    |   41 +++
 .../Ui/Component/EncodingComboBox.cs               |  233 +++++++++++++++++
 src/GnomeSubtitles/Ui/MainUi.cs                    |   26 ++-
 12 files changed, 762 insertions(+), 277 deletions(-)
---
diff --git a/data/gnome-subtitles.schemas b/data/gnome-subtitles.schemas
index 581f7da..2d4005c 100644
--- a/data/gnome-subtitles.schemas
+++ b/data/gnome-subtitles.schemas
@@ -14,6 +14,17 @@
 			</locale>
 		</schema>
 		<schema>
+			<key>/schemas/apps/gnome-subtitles/preferences/encodings/fallback</key>
+			<applyto>/apps/gnome-subtitles/preferences/encodings/fallback</applyto>
+			<owner>gnome-subtitles</owner>
+			<type>string</type>
+			<default>ISO-8859-15</default>
+			<locale name="C">
+				<short>Auto detection fallback encoding</short>
+				<long>Encoding to use when auto detection fails.</long>
+			</locale>
+		</schema>
+		<schema>
 			<key>/schemas/apps/gnome-subtitles/preferences/video/auto_choose_file</key>
 			<applyto>/apps/gnome-subtitles/preferences/video/auto_choose_file</applyto>
 			<owner>gnome-subtitles</owner>
@@ -79,5 +90,38 @@
 				<long>The height of the Main Window.</long>
 			</locale>
 		</schema>
+		<schema>
+			<key>/schemas/apps/gnome-subtitles/preferences/defaults/file_open_encoding_option</key>
+			<applyto>/apps/gnome-subtitles/preferences/defaults/file_open_encoding_option</applyto>
+			<owner>gnome-subtitles</owner>
+			<type>string</type>
+			<default>AutoDetect</default>
+			<locale name="C">
+				<short>File Open encoding option</short>
+				<long>Encoding option to use by default when opening files. Possible values are: "AutoDetect" to use auto detection, "RememberLastUsed" to remember the last used encoding, "CurrentLocale" to use the current locale, and "Specific" to use a specific encoding. The encoding for "RememberLastUsed" and "Specific" is stored in the file_open_encoding key.</long>
+			</locale>
+		</schema>
+		<schema>
+			<key>/schemas/apps/gnome-subtitles/preferences/defaults/file_open_encoding</key>
+			<applyto>/apps/gnome-subtitles/preferences/defaults/file_open_encoding</applyto>
+			<owner>gnome-subtitles</owner>
+			<type>string</type>
+			<default></default>
+			<locale name="C">
+				<short>File Open encoding</short>
+				<long>Encoding to use when opening files. Besides the actual encoding, used when "RememberLastUsed" or "Specific" are set in the file_open_encoding_option key, other possible values are "AutoDetect" and "CurrentLocale".</long>
+			</locale>
+		</schema>
+		<schema>
+			<key>/schemas/apps/gnome-subtitles/preferences/file_save/file_save_subtitle_format</key>
+			<applyto>/apps/gnome-subtitles/preferences/file_save/file_save_subtitle_format</applyto>
+			<owner>gnome-subtitles</owner>
+			<type>string</type>
+			<default>SubRip</default>
+			<locale name="C">
+				<short>File save subtitle format</short>
+				<long>Subtitle format to choose by default in the File Save As dialog.</long>
+			</locale>
+		</schema>
 	</schemalist>
 </gconfschemafile>
diff --git a/gnome-subtitles.mdp b/gnome-subtitles.mdp
index 0a2a588..8e5985d 100644
--- a/gnome-subtitles.mdp
+++ b/gnome-subtitles.mdp
@@ -36,7 +36,6 @@
     <File name="src/GnomeSubtitles/Dialog/GladeDialog.cs" subtype="Code" buildaction="Compile" />
     <File name="src/GnomeSubtitles/Dialog/HeadersDialog.cs" subtype="Code" buildaction="Compile" />
     <File name="src/GnomeSubtitles/Dialog/SearchDialog.cs" subtype="Code" buildaction="Compile" />
-    <File name="src/GnomeSubtitles/Dialog/SubtitleFileChooserDialog.cs" subtype="Code" buildaction="Compile" />
     <File name="data/gnome-subtitles.png" subtype="Code" buildaction="EmbedAsResource" />
     <File name="data/gnome-subtitles-logo.png" subtype="Code" buildaction="EmbedAsResource" />
     <File name="src/GnomeSubtitles/Dialog/TimingsAdjustDialog.cs" subtype="Code" buildaction="Compile" />
@@ -244,6 +243,9 @@
     <File name="src/SubLib/IO/SubtitleFormats/SubtitleFormatViPlaySubtitleFile.cs" subtype="Code" buildaction="Compile" />
     <File name="src/SubLib/Core/Search/SubtitleReplaceResult.cs" subtype="Code" buildaction="Compile" />
     <File name="src/GnomeSubtitles/Core/DragDrop.cs" subtype="Code" buildaction="Compile" />
+    <File name="src/GnomeSubtitles/Ui/Component" subtype="Directory" buildaction="Compile" />
+    <File name="src/GnomeSubtitles/Ui/Component/EncodingComboBox.cs" subtype="Code" buildaction="Compile" />
+    <File name="src/GnomeSubtitles/Ui/Component/ComboBoxUtil.cs" subtype="Code" buildaction="Compile" />
   </Contents>
   <References>
     <ProjectReference type="Gac" localcopy="True" refto="Mono.Posix, Version=2.0.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756" />
diff --git a/src/Glade/FileOpenDialog.glade b/src/Glade/FileOpenDialog.glade
index fe330de..fdbb23a 100644
--- a/src/Glade/FileOpenDialog.glade
+++ b/src/Glade/FileOpenDialog.glade
@@ -59,10 +59,8 @@
               </packing>
             </child>
             <child>
-              <widget class="GtkComboBox" id="encodingComboBox">
+              <widget class="GtkComboBox" id="fileEncodingComboBox">
                 <property name="visible">True</property>
-                <property name="items" translatable="yes"></property>
-                <signal name="changed" handler="OnEncodingComboBoxChanged"/>
               </widget>
               <packing>
                 <property name="left_attach">1</property>
diff --git a/src/Glade/FileSaveAsDialog.glade b/src/Glade/FileSaveAsDialog.glade
index 0ce5cfa..30b45aa 100644
--- a/src/Glade/FileSaveAsDialog.glade
+++ b/src/Glade/FileSaveAsDialog.glade
@@ -9,10 +9,10 @@
     <property name="destroy_with_parent">True</property>
     <property name="type_hint">dialog</property>
     <property name="has_separator">False</property>
-    <property name="action">save</property>
-    <property name="do_overwrite_confirmation">True</property>
     <property name="use_preview_label">False</property>
     <property name="preview_widget_active">False</property>
+    <property name="action">save</property>
+    <property name="do_overwrite_confirmation">True</property>
     <child internal-child="vbox">
       <widget class="GtkVBox" id="dialogVBox">
         <property name="visible">True</property>
@@ -67,10 +67,9 @@
                   </packing>
                 </child>
                 <child>
-                  <widget class="GtkComboBox" id="encodingComboBox">
+                  <widget class="GtkComboBox" id="fileEncodingComboBox">
                     <property name="visible">True</property>
                     <property name="items" translatable="yes"></property>
-                    <signal name="changed" handler="OnEncodingComboBoxChanged"/>
                   </widget>
                   <packing>
                     <property name="left_attach">1</property>
diff --git a/src/Glade/PreferencesDialog.glade b/src/Glade/PreferencesDialog.glade
index 2633a31..26681f2 100644
--- a/src/Glade/PreferencesDialog.glade
+++ b/src/Glade/PreferencesDialog.glade
@@ -12,60 +12,272 @@
       <widget class="GtkVBox" id="dialogVBox">
         <property name="visible">True</property>
         <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_ENTER_NOTIFY_MASK</property>
+        <property name="orientation">vertical</property>
         <property name="spacing">2</property>
         <child>
           <widget class="GtkVBox" id="vbox1">
             <property name="visible">True</property>
+            <property name="orientation">vertical</property>
+            <property name="spacing">10</property>
             <child>
-              <widget class="GtkVBox" id="vbox2">
+              <widget class="GtkFrame" id="frame3">
                 <property name="visible">True</property>
-                <property name="spacing">6</property>
+                <property name="label_xalign">0</property>
+                <property name="shadow_type">none</property>
                 <child>
-                  <widget class="GtkLabel" id="label1">
+                  <widget class="GtkAlignment" id="alignment3">
                     <property name="visible">True</property>
-                    <property name="xalign">0</property>
-                    <property name="label" translatable="yes">&lt;b&gt;Video&lt;/b&gt;</property>
+                    <property name="left_padding">12</property>
+                    <child>
+                      <widget class="GtkVBox" id="vbox2">
+                        <property name="visible">True</property>
+                        <property name="orientation">vertical</property>
+                        <property name="spacing">5</property>
+                        <child>
+                          <widget class="GtkCheckButton" id="videoAutoChooseFileCheckButton1">
+                            <property name="label" translatable="yes">When saving subtitles, also save translation</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>
+                          </widget>
+                          <packing>
+                            <property name="position">0</property>
+                          </packing>
+                        </child>
+                      </widget>
+                    </child>
+                  </widget>
+                </child>
+                <child>
+                  <widget class="GtkLabel" id="label10">
+                    <property name="visible">True</property>
+                    <property name="label" translatable="yes">&lt;b&gt;Translation&lt;/b&gt;</property>
                     <property name="use_markup">True</property>
+                    <property name="use_underline">True</property>
                   </widget>
                   <packing>
-                    <property name="expand">False</property>
-                    <property name="fill">False</property>
-                    <property name="position">0</property>
+                    <property name="type">label_item</property>
                   </packing>
                 </child>
+              </widget>
+              <packing>
+                <property name="position">0</property>
+              </packing>
+            </child>
+            <child>
+              <widget class="GtkFrame" id="frame1">
+                <property name="visible">True</property>
+                <property name="label_xalign">0</property>
+                <property name="shadow_type">none</property>
                 <child>
-                  <widget class="GtkHBox" id="hbox1">
+                  <widget class="GtkAlignment" id="alignment1">
                     <property name="visible">True</property>
+                    <property name="left_padding">12</property>
                     <child>
-                      <widget class="GtkCheckButton" id="videoAutoChooseFileCheckButton">
-                        <property name="label" translatable="yes">Automatically choose video to open</property>
+                      <widget class="GtkVBox" id="vbox4">
                         <property name="visible">True</property>
-                        <property name="can_focus">False</property>
-                        <property name="receives_default">False</property>
-                        <property name="draw_indicator">True</property>
-                        <signal name="toggled" handler="OnVideoAutoChooseFileToggled"/>
+                        <property name="orientation">vertical</property>
+                        <property name="spacing">5</property>
+                        <child>
+                          <widget class="GtkTable" id="table2">
+                            <property name="visible">True</property>
+                            <property name="n_rows">2</property>
+                            <property name="n_columns">2</property>
+                            <property name="column_spacing">5</property>
+                            <property name="row_spacing">5</property>
+                            <child>
+                              <widget class="GtkLabel" id="label6">
+                                <property name="visible">True</property>
+                                <property name="xalign">0</property>
+                                <property name="label" translatable="yes">Character coding to use:</property>
+                                <property name="use_underline">True</property>
+                              </widget>
+                              <packing>
+                                <property name="x_options">GTK_FILL</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <widget class="GtkComboBox" id="fileOpenEncodingComboBox">
+                                <property name="visible">True</property>
+                              </widget>
+                              <packing>
+                                <property name="left_attach">1</property>
+                                <property name="right_attach">2</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <widget class="GtkLabel" id="label7">
+                                <property name="visible">True</property>
+                                <property name="xalign">0</property>
+                                <property name="label" translatable="yes">If character coding auto detection fails, use:</property>
+                                <property name="use_underline">True</property>
+                              </widget>
+                              <packing>
+                                <property name="top_attach">1</property>
+                                <property name="bottom_attach">2</property>
+                                <property name="x_options">GTK_FILL</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <widget class="GtkComboBox" id="combobox5">
+                                <property name="visible">True</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>
+                          </widget>
+                          <packing>
+                            <property name="position">0</property>
+                          </packing>
+                        </child>
+                        <child>
+                          <widget class="GtkCheckButton" id="videoAutoChooseFileCheckButton">
+                            <property name="label" translatable="yes">Automatically choose _video file to open</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>
+                            <signal name="toggled" handler="OnVideoAutoChooseFileToggled"/>
+                          </widget>
+                          <packing>
+                            <property name="position">1</property>
+                          </packing>
+                        </child>
                       </widget>
-                      <packing>
-                        <property name="expand">False</property>
-                        <property name="fill">False</property>
-                        <property name="padding">15</property>
-                        <property name="position">0</property>
-                      </packing>
                     </child>
                   </widget>
+                </child>
+                <child>
+                  <widget class="GtkLabel" id="label3">
+                    <property name="visible">True</property>
+                    <property name="label" translatable="yes">&lt;b&gt;File _Open&lt;/b&gt;</property>
+                    <property name="use_markup">True</property>
+                    <property name="use_underline">True</property>
+                  </widget>
                   <packing>
-                    <property name="expand">False</property>
-                    <property name="fill">False</property>
-                    <property name="position">1</property>
+                    <property name="type">label_item</property>
                   </packing>
                 </child>
               </widget>
               <packing>
-                <property name="position">0</property>
+                <property name="position">1</property>
+              </packing>
+            </child>
+            <child>
+              <widget class="GtkFrame" id="frame2">
+                <property name="visible">True</property>
+                <property name="label_xalign">0</property>
+                <property name="shadow_type">none</property>
+                <child>
+                  <widget class="GtkAlignment" id="alignment2">
+                    <property name="visible">True</property>
+                    <property name="left_padding">12</property>
+                    <child>
+                      <widget class="GtkTable" id="table1">
+                        <property name="visible">True</property>
+                        <property name="n_rows">3</property>
+                        <property name="n_columns">2</property>
+                        <property name="column_spacing">5</property>
+                        <property name="row_spacing">5</property>
+                        <child>
+                          <widget class="GtkLabel" id="label2">
+                            <property name="visible">True</property>
+                            <property name="xalign">0</property>
+                            <property name="label" translatable="yes">Ch_aracter coding to use:</property>
+                            <property name="use_underline">True</property>
+                          </widget>
+                          <packing>
+                            <property name="top_attach">1</property>
+                            <property name="bottom_attach">2</property>
+                            <property name="x_options">GTK_FILL</property>
+                          </packing>
+                        </child>
+                        <child>
+                          <widget class="GtkLabel" id="label1">
+                            <property name="visible">True</property>
+                            <property name="xalign">0</property>
+                            <property name="label" translatable="yes">Subtitle _format to use:</property>
+                            <property name="use_underline">True</property>
+                          </widget>
+                          <packing>
+                            <property name="x_options">GTK_FILL</property>
+                          </packing>
+                        </child>
+                        <child>
+                          <widget class="GtkComboBox" id="combobox1">
+                            <property name="visible">True</property>
+                          </widget>
+                          <packing>
+                            <property name="left_attach">1</property>
+                            <property name="right_attach">2</property>
+                          </packing>
+                        </child>
+                        <child>
+                          <widget class="GtkComboBox" id="combobox2">
+                            <property name="visible">True</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="label5">
+                            <property name="visible">True</property>
+                            <property name="xalign">0</property>
+                            <property name="label" translatable="yes">Newline type to use:</property>
+                            <property name="use_underline">True</property>
+                          </widget>
+                          <packing>
+                            <property name="top_attach">2</property>
+                            <property name="bottom_attach">3</property>
+                            <property name="x_options">GTK_FILL</property>
+                          </packing>
+                        </child>
+                        <child>
+                          <widget class="GtkComboBox" id="combobox3">
+                            <property name="visible">True</property>
+                          </widget>
+                          <packing>
+                            <property name="left_attach">1</property>
+                            <property name="right_attach">2</property>
+                            <property name="top_attach">2</property>
+                            <property name="bottom_attach">3</property>
+                          </packing>
+                        </child>
+                      </widget>
+                    </child>
+                  </widget>
+                </child>
+                <child>
+                  <widget class="GtkLabel" id="label4">
+                    <property name="visible">True</property>
+                    <property name="label" translatable="yes">&lt;b&gt;File _Save As&lt;/b&gt;</property>
+                    <property name="use_markup">True</property>
+                    <property name="use_underline">True</property>
+                  </widget>
+                  <packing>
+                    <property name="type">label_item</property>
+                  </packing>
+                </child>
+              </widget>
+              <packing>
+                <property name="position">2</property>
               </packing>
             </child>
           </widget>
           <packing>
+            <property name="expand">False</property>
+            <property name="fill">False</property>
             <property name="position">1</property>
           </packing>
         </child>
diff --git a/src/GnomeSubtitles/Core/Config.cs b/src/GnomeSubtitles/Core/Config.cs
index 4603174..a04d0cf 100644
--- a/src/GnomeSubtitles/Core/Config.cs
+++ b/src/GnomeSubtitles/Core/Config.cs
@@ -1,6 +1,6 @@
 /*
  * This file is part of Gnome Subtitles.
- * Copyright (C) 2007-2008 Pedro Castro
+ * Copyright (C) 2007-2010 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
@@ -22,6 +22,10 @@ using System;
 
 namespace GnomeSubtitles.Core {
 
+/* Enumerations */
+public enum ConfigFileOpenEncodingOption { AutoDetect = 0, RememberLastUsed = 1, CurrentLocale = 3, Specific = 4 }; //Values match ordering where the options are used
+public enum ConfigFileOpenEncoding { AutoDetect = 0, CurrentLocale = 2, Fixed = 3 };
+
 public class Config {
 	private Client client = null;
 	
@@ -32,7 +36,8 @@ public class Config {
 	private const string keyPrefsSpellCheck = keyPrefs + "spellcheck/";
 	private const string keyPrefsVideo = keyPrefs + "video/";
 	private const string keyPrefsWindow = keyPrefs + "window/";
-	
+	private const string keyPrefsDefaults = keyPrefs + "defaults/";
+
 	/* Constant key strings */
 	private const string keyPrefsEncodingsShownInMenu = keyPrefsEncodings + "shown_in_menu";
 	private const string keyPrefsSpellCheckActiveTextLanguage = keyPrefsSpellCheck + "active_text_language";
@@ -41,6 +46,8 @@ public class Config {
 	private const string keyPrefsVideoAutoChooseFile = keyPrefsVideo + "auto_choose_file";
 	private const string keyPrefsWindowHeight = keyPrefsWindow + "height";
 	private const string keyPrefsWindowWidth = keyPrefsWindow + "width";
+	private const string keyPrefsDefaultsFileOpenEncodingOption = keyPrefsDefaults + "file_open_encoding_option";
+	private const string keyPrefsDefaultsFileOpenEncoding = keyPrefsDefaults + "file_open_encoding";
 
 	public Config () {
 		client = new Client();
@@ -85,6 +92,22 @@ public class Config {
 		get { return GetInt(keyPrefsWindowWidth, 690, 200, true, 0, false); }
 		set { Set(keyPrefsWindowWidth, value); }
 	}
+
+	public ConfigFileOpenEncodingOption PrefsDefaultsFileOpenEncodingOption {
+		get { return (ConfigFileOpenEncodingOption)GetEnumValue(keyPrefsDefaultsFileOpenEncodingOption, ConfigFileOpenEncodingOption.AutoDetect); }
+		set { Set(keyPrefsDefaultsFileOpenEncodingOption, value.ToString()); }
+	}
+
+	public ConfigFileOpenEncoding PrefsDefaultsFileOpenEncoding {
+		get { return (ConfigFileOpenEncoding)GetEnumValueFromSuperset(keyPrefsDefaultsFileOpenEncoding, ConfigFileOpenEncoding.Fixed); }
+		set { Set(keyPrefsDefaultsFileOpenEncoding, value.ToString()); }
+	}
+
+	/* Uses the same key as PrefsDefaultsFileOpenEncoding but is used when there's a specific encoding set */
+	public string PrefsDefaultsFileOpenEncodingFixed {
+		get { return GetString(keyPrefsDefaultsFileOpenEncoding, "ISO-8859-15"); }
+		set { Set(keyPrefsDefaultsFileOpenEncoding, value); }
+	}
 	
 	/* Private members */
 	
@@ -92,7 +115,8 @@ public class Config {
 		try {
 			return (string)client.Get(key);
 		}
-		catch (Exception) {
+		catch (Exception e) {
+			Console.Error.WriteLine(e);
 			return defaultValue;
 		}
 	}
@@ -101,7 +125,8 @@ public class Config {
 		try {
 			return (bool)client.Get(key);
 		}
-		catch (Exception) {
+		catch (Exception e) {
+			Console.Error.WriteLine(e);
 			return defaultValue;
 		}
 	}
@@ -126,7 +151,8 @@ public class Config {
 			
 			return number;
 		}
-		catch (Exception) {
+		catch (Exception e) {
+			Console.Error.WriteLine(e);
 			return defaultValue;
 		}
 	}
@@ -142,9 +168,32 @@ public class Config {
 		catch (Exception e) {
 			Console.Error.WriteLine(e);
 			return defaultValue;
-		}	
+		}
+	}
+
+	/* Gets an enum value from a field which can hold a value not included in the enum (basically assumes an exception
+		can occur). */
+	private Enum GetEnumValueFromSuperset (string key, Enum defaultValue) {
+		try {
+			string stringValue = (string)client.Get(key);
+			return (Enum)Enum.Parse(defaultValue.GetType(), stringValue);
+		}
+		catch (Exception) {
+			return defaultValue;
+		}
+	}
+
+	private Enum GetEnumValue (string key, Enum defaultValue) {
+		try {
+			string stringValue = (string)client.Get(key);
+			return (Enum)Enum.Parse(defaultValue.GetType(), stringValue);
+		}
+		catch (Exception e) {
+			Console.Error.WriteLine(e);
+			return defaultValue;
+		}
 	}
-	
+
 	private void SetStrings (string key, string[] values) {
 		if (values.Length == 0) {
 			string[] newValues = { String.Empty };
@@ -153,7 +202,7 @@ public class Config {
 		else
 			Set(key, values);
 	}
-	
+
 	private void Set (string key, object val) {
 		try {
 			client.Set(key, val);
diff --git a/src/GnomeSubtitles/Dialog/FileOpenDialog.cs b/src/GnomeSubtitles/Dialog/FileOpenDialog.cs
index 817c412..90ce5fa 100644
--- a/src/GnomeSubtitles/Dialog/FileOpenDialog.cs
+++ b/src/GnomeSubtitles/Dialog/FileOpenDialog.cs
@@ -1,6 +1,6 @@
 /*
  * This file is part of Gnome Subtitles.
- * Copyright (C) 2006-2009 Pedro Castro
+ * Copyright (C) 2006-2010 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
@@ -18,6 +18,7 @@
  */
 
 using GnomeSubtitles.Core;
+using GnomeSubtitles.Ui.Component;
 using GnomeSubtitles.Ui.VideoPreview;
 using Glade;
 using Gtk;
@@ -31,27 +32,37 @@ using System.Text.RegularExpressions;
 
 namespace GnomeSubtitles.Dialog {
 
-public class FileOpenDialog : SubtitleFileChooserDialog {
-	private ArrayList videoFiles = null; //The full paths of the video files in the current fir
+public class FileOpenDialog : GladeDialog {
+	protected FileChooserDialog dialog = null;
+
+	private string chosenFilename = String.Empty;
+	private EncodingDescription chosenEncoding = EncodingDescription.Empty;
+	private ArrayList videoFiles = null; //The full paths of the video files in the current dir
 	private ArrayList videoFilenames = null; //The filenames of videoFiles, without extensions
-	
 	private Uri chosenVideoUri = null;
 	private bool autoChooseVideoFile = true;
 
 	/* Constant strings */
 	private const string gladeFilename = "FileOpenDialog.glade";
 
+	/* Components */
+	private EncodingComboBox encodingComboBox = null;
+
 	/* Widgets */
-	[WidgetAttribute] private ComboBox encodingComboBox = null;
+	[WidgetAttribute] private ComboBox fileEncodingComboBox = null;
 	[WidgetAttribute] private ComboBox videoComboBox = null;
 	[WidgetAttribute] 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;
-		
+
+		InitEncodingComboBox();
+
 		if (toEnableVideo)
 			EnableVideo();
 	
@@ -60,23 +71,39 @@ public class FileOpenDialog : SubtitleFileChooserDialog {
 
 		SetFilters();
 	}
-	
-	private void EnableVideo () {
-		videoLabel.Visible = true;
-		videoComboBox.Visible = true;
-		
-		autoChooseVideoFile = Base.Config.PrefsVideoAutoChooseFile;
-		videoComboBox.RowSeparatorFunc = SeparatorFunc;
-		
-		dialog.CurrentFolderChanged += OnCurrentFolderChanged;
-		dialog.SelectionChanged += OnSelectionChanged;
+
+	private void InitEncodingComboBox () {
+		int fixedEncoding = -1;
+		ConfigFileOpenEncoding encodingConfig = Base.Config.PrefsDefaultsFileOpenEncoding;
+		if (encodingConfig == ConfigFileOpenEncoding.Fixed) {
+			string encodingName = Base.Config.PrefsDefaultsFileOpenEncodingFixed;
+			EncodingDescription encodingDescription = EncodingDescription.Empty;
+			Encodings.Find(encodingName, ref encodingDescription);
+			fixedEncoding = encodingDescription.CodePage;
+		}
+
+		this.encodingComboBox = new EncodingComboBox(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;
 	}
-	
-	/* Public properties */
+
+	/* Overriden members */
 
 	public override DialogScope Scope {
 		get { return DialogScope.Singleton; }
 	}
+
+	/* Public properties */
+
+	public EncodingDescription Encoding {
+		get { return chosenEncoding; }
+	}
+
+	public string Filename {
+		get { return chosenFilename; }
+	}
 	
 	public bool HasVideoFilename {
 		get { return chosenVideoUri != null; }
@@ -95,15 +122,7 @@ public class FileOpenDialog : SubtitleFileChooserDialog {
 		else
 			return Environment.GetFolderPath(Environment.SpecialFolder.Personal);
 	}
-	
-	protected override void AddInitialEncodingComboBoxItems () {
-		encodingComboBox.AppendText(Catalog.GetString("Auto Detected"));
-		encodingComboBox.AppendText("-");
-	}
 
-	protected override ComboBox GetEncodingComboBox () {
-		return encodingComboBox;
-	}
 
 	/* Private members */
 	
@@ -207,6 +226,17 @@ public class FileOpenDialog : SubtitleFileChooserDialog {
 			return filename;
 	}
 	
+	private void EnableVideo () {
+		videoLabel.Visible = true;
+		videoComboBox.Visible = true;
+		
+		autoChooseVideoFile = Base.Config.PrefsVideoAutoChooseFile;
+		videoComboBox.RowSeparatorFunc = ComboBoxUtil.SeparatorFunc;
+		
+		dialog.CurrentFolderChanged += OnCurrentFolderChanged;
+		dialog.SelectionChanged += OnSelectionChanged;
+	}
+	
 	private void SetFilters () {
 		SubtitleTypeInfo[] types = Subtitles.AvailableTypesSorted;
 		FileFilter[] filters = new FileFilter[types.Length + 2];
@@ -251,12 +281,17 @@ public class FileOpenDialog : SubtitleFileChooserDialog {
 	protected override bool ProcessResponse (ResponseType response) {
 		if (response == ResponseType.Ok) {
 			chosenFilename = dialog.Filename;
-			int activeEncodingComboBoxItem = GetActiveEncodingComboBoxItem();
-			if (activeEncodingComboBoxItem > 0) {
-				int encodingIndex = activeEncodingComboBoxItem - 2;
-				chosenEncoding = encodings[encodingIndex];
-				hasChosenEncoding = true;
+			chosenEncoding = encodingComboBox.ChosenEncoding;
+
+			if (Base.Config.PrefsDefaultsFileOpenEncodingOption == ConfigFileOpenEncodingOption.RememberLastUsed) {
+				int activeAction = encodingComboBox.ActiveSelection;
+				ConfigFileOpenEncoding activeOption = (ConfigFileOpenEncoding)Enum.ToObject(typeof(ConfigFileOpenEncoding), activeAction);
+				if (((int)activeOption) >= ((int)ConfigFileOpenEncoding.Fixed))
+					Base.Config.PrefsDefaultsFileOpenEncodingFixed = chosenEncoding.Name;
+				else
+					Base.Config.PrefsDefaultsFileOpenEncoding = activeOption;
 			}
+
 			if (videoComboBox.Active > 0) {
 				int videoFileIndex = videoComboBox.Active - 2;
 				chosenVideoUri = new Uri(videoFiles[videoFileIndex] as string);
diff --git a/src/GnomeSubtitles/Dialog/PreferencesDialog.cs b/src/GnomeSubtitles/Dialog/PreferencesDialog.cs
index 8409436..b49beca 100644
--- a/src/GnomeSubtitles/Dialog/PreferencesDialog.cs
+++ b/src/GnomeSubtitles/Dialog/PreferencesDialog.cs
@@ -1,6 +1,6 @@
 /*
  * This file is part of Gnome Subtitles.
- * Copyright (C) 2007-2009 Pedro Castro
+ * Copyright (C) 2007-2010 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,7 +19,9 @@
 
 using Glade;
 using GnomeSubtitles.Core;
+using GnomeSubtitles.Ui.Component;
 using Gtk;
+using Mono.Unix;
 using System;
 
 namespace GnomeSubtitles.Dialog {
@@ -29,10 +31,12 @@ public class PreferencesDialog : GladeDialog {
 	/* Constant strings */
 	private const string gladeFilename = "PreferencesDialog.glade";
 
+	/* Components */
+	private EncodingComboBox fileOpenEncoding = null;
+
 	/* Widgets */
-	
 	[WidgetAttribute] private CheckButton videoAutoChooseFileCheckButton = null;
-
+	[WidgetAttribute] private ComboBox fileOpenEncodingComboBox = null;
 
 	public PreferencesDialog () : base(gladeFilename, false) {
 		LoadValues();
@@ -42,13 +46,63 @@ public class PreferencesDialog : GladeDialog {
 	/* Private members */
 	
 	private void LoadValues () {
+		SetDefaultsFileOpenEncoding();
+
+
+		/* Video Auto choose file */
 		videoAutoChooseFileCheckButton.Active = Base.Config.PrefsVideoAutoChooseFile;
+
+		
+		
 	}
+
+	private void SetDefaultsFileOpenEncoding () {
+		string[] fileOpenAdditionalActions = { Catalog.GetString("Remember Last Used") };
+		int fixedEncoding = -1;
+		ConfigFileOpenEncodingOption fileOpenEncodingOption = Base.Config.PrefsDefaultsFileOpenEncodingOption;
+		if (fileOpenEncodingOption == ConfigFileOpenEncodingOption.Specific) {
+			string encodingName = Base.Config.PrefsDefaultsFileOpenEncodingFixed;
+			EncodingDescription encodingDescription = EncodingDescription.Empty;
+			Encodings.Find(encodingName, ref encodingDescription);
+			fixedEncoding = encodingDescription.CodePage;
+		}
+
+		fileOpenEncoding = new EncodingComboBox(fileOpenEncodingComboBox, true, fileOpenAdditionalActions, fixedEncoding);
+		if (fileOpenEncodingOption != ConfigFileOpenEncodingOption.Specific) {
+			fileOpenEncoding.ActiveSelection = (int)fileOpenEncodingOption;
+		}
+		fileOpenEncoding.SelectionChanged += OnDefaultsFileOpenEncodingChanged;
+	}
+
 	
 	/* Event members */
 
 	#pragma warning disable 169		//Disables warning about handlers not being used
 
+	private void OnDefaultsFileOpenEncodingChanged (object o, EventArgs args) {
+		int active = fileOpenEncoding.ActiveSelection;
+		ConfigFileOpenEncodingOption activeOption = (ConfigFileOpenEncodingOption)Enum.ToObject(typeof(ConfigFileOpenEncodingOption), active);
+		if (((int)activeOption) > ((int)ConfigFileOpenEncodingOption.Specific))
+			activeOption = ConfigFileOpenEncodingOption.Specific;
+
+		Base.Config.PrefsDefaultsFileOpenEncodingOption = activeOption;
+		/* If encoding option is specific, encodingOption=Specific and encoding holds the encoding name */
+		if (activeOption == ConfigFileOpenEncodingOption.Specific) {
+			EncodingDescription chosenEncoding = fileOpenEncoding.ChosenEncoding;
+			if (!chosenEncoding.Equals(EncodingDescription.Empty)) {
+				Base.Config.PrefsDefaultsFileOpenEncodingFixed = chosenEncoding.Name;
+			}
+		}
+		else {
+			/* If encoding option is current locale, encoding holds current locale too, otherwise it just holds auto detect */
+			ConfigFileOpenEncoding encodingToStore = ConfigFileOpenEncoding.AutoDetect;
+			if (activeOption == ConfigFileOpenEncodingOption.CurrentLocale) {
+				encodingToStore = ConfigFileOpenEncoding.CurrentLocale;
+			}
+			Base.Config.PrefsDefaultsFileOpenEncoding = encodingToStore;
+		}
+	}
+
 	private void OnVideoAutoChooseFileToggled (object o, EventArgs args) {
 		Base.Config.PrefsVideoAutoChooseFile = videoAutoChooseFileCheckButton.Active;
 	}
diff --git a/src/GnomeSubtitles/Ui/Component/ComboBoxUtil.cs b/src/GnomeSubtitles/Ui/Component/ComboBoxUtil.cs
new file mode 100644
index 0000000..0670f4e
--- /dev/null
+++ b/src/GnomeSubtitles/Ui/Component/ComboBoxUtil.cs
@@ -0,0 +1,41 @@
+/*
+ * This file is part of Gnome Subtitles.
+ * Copyright (C) 2007-2010 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
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Gnome Subtitles is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+using Gtk;
+
+namespace GnomeSubtitles.Ui.Component {
+
+public class ComboBoxUtil {
+
+	public static bool SeparatorFunc (TreeModel model, TreeIter iter) {
+		string text = (string)model.GetValue(iter, 0);
+		return ((text != null) && (text.CompareTo("-") == 0));
+	}
+
+	public static void InitComboBox (ComboBox comboBox) {
+		comboBox.Clear();
+		CellRendererText cell = new CellRendererText();
+		comboBox.PackStart(cell, false);
+		comboBox.AddAttribute(cell, "text", 0);
+		comboBox.Model = new ListStore(typeof(string));
+	}
+
+}
+
+}
diff --git a/src/GnomeSubtitles/Ui/Component/EncodingComboBox.cs b/src/GnomeSubtitles/Ui/Component/EncodingComboBox.cs
new file mode 100644
index 0000000..23842e1
--- /dev/null
+++ b/src/GnomeSubtitles/Ui/Component/EncodingComboBox.cs
@@ -0,0 +1,233 @@
+/*
+ * This file is part of Gnome Subtitles.
+ * Copyright (C) 2006-2010 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
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Gnome Subtitles is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+using GnomeSubtitles.Core;
+using GnomeSubtitles.Dialog;
+using Gtk;
+using Mono.Unix;
+using System;
+using System.Collections;
+
+namespace GnomeSubtitles.Ui.Component {
+
+public class EncodingComboBox {
+
+	private ComboBox comboBox = null;
+	private int comboBoxActiveItem = 0; //Stores the last active item so we can get back to it after using Add/Remove
+
+	private ArrayList encodings = null; //Encodings present in the combo box
+	private int actionCount = 0; //Actions correspond to the initial items (including auto detection)
+	private bool hasAutoDetect = false; //Whether to add Auto Detect to the top of the item list
+	private string[] additionalActions = null; //
+	private int fixedEncoding = -1; //Codepage of an encoding that must be present (-1 if not)
+	private ArrayList configShownEncodings = null; //Encodings shown in menu from config
+
+	public EncodingComboBox (ComboBox comboBox, bool hasAutoDetect, string[] additionalActions, int fixedEncoding) {
+		this.comboBox = comboBox;
+		this.additionalActions = additionalActions;
+		this.hasAutoDetect = hasAutoDetect;
+		this.fixedEncoding = fixedEncoding;
+
+		InitComboBoxModel();
+		SetActionCount();
+		SetComboBox(Base.Config.PrefsEncodingsShownInMenu);
+		ConnectHandlers();
+	}
+
+	public EncodingComboBox (ComboBox comboBox, bool hasAutoDetect) : this(comboBox, hasAutoDetect, null, -1) {
+	}
+	
+
+	/* Public properties */
+
+	public bool HasChosenAction {
+		get { return comboBox.Active < actionCount; }
+	}
+
+	public int ChosenAction {
+		get { return (HasChosenAction ? comboBox.Active : -1); }
+	}
+
+	public EncodingDescription ChosenEncoding {
+		get {
+			int active = comboBox.Active;
+			if (hasAutoDetect)
+				return (active == 0 ? EncodingDescription.Empty : (EncodingDescription)encodings[active - (actionCount + 1)]); //1 for break line
+			else
+				return (EncodingDescription)encodings[active];
+		}
+	}
+
+	public bool IsChosenCurrentLocale {
+		get { return comboBox.Active == actionCount + 1; }
+	}
+
+	public int ActiveSelection {
+		get { return comboBox.Active; }
+		set { SetActiveItem(value, false); }
+	}
+
+	/* Events */
+	
+	public event EventHandler SelectionChanged;
+
+
+	/* Private members */
+
+	private void InitComboBoxModel () {
+		ComboBoxUtil.InitComboBox(comboBox);
+	}
+
+	private void SetActionCount () {
+		this.actionCount = (hasAutoDetect ? 1 : 0) + (additionalActions != null ? additionalActions.Length : 0);
+	}
+
+	private void SetComboBox (string[] names) {
+		configShownEncodings = new ArrayList(names);
+		LoadEncodings();
+		FillComboBox();
+	}
+
+	private void LoadEncodings () {
+		bool toAddFixedEncoding = (fixedEncoding != -1);
+		ArrayList encodings = new ArrayList();
+		
+		foreach (string name in configShownEncodings) {
+			EncodingDescription description = EncodingDescription.Empty;
+			if (Encodings.Find(name, ref description)) {
+				encodings.Add(description);
+				if (toAddFixedEncoding && (description.CodePage == fixedEncoding))
+					toAddFixedEncoding = false;
+			}
+		}
+
+		if (toAddFixedEncoding) {
+			EncodingDescription description = EncodingDescription.Empty;
+			if (Encodings.Find(fixedEncoding, ref description))
+				encodings.Add(description);		
+		}
+
+		encodings.Sort();
+		encodings.Insert(0, Encodings.SystemDefault);
+
+		this.encodings = encodings;
+	}
+
+	private void FillComboBox () {
+		DisconnectComboBoxChangedSignal();
+
+		(comboBox.Model as ListStore).Clear();
+
+		int activeItem = comboBoxActiveItem;
+		int currentItem = 0;
+
+		/* Add auto detect */
+		if (hasAutoDetect) {
+			AddAutoDetect();
+			currentItem ++;
+		}
+
+		/* Add additional actions */
+		if (additionalActions != null) {
+			foreach (string additionalAction in additionalActions) {
+				comboBox.AppendText(additionalAction);
+				currentItem++;
+			}
+		}
+
+		if (currentItem != 0) {
+			comboBox.AppendText("-");
+			currentItem++;
+		}
+
+		/* Add encodings */
+		foreach (EncodingDescription encoding in encodings) {
+			comboBox.AppendText(encoding.Description + " (" + encoding.Name + ")");
+			if (encoding.CodePage == fixedEncoding) {
+				activeItem = currentItem;
+			}
+			currentItem++;
+		}
+
+		/* Add add/remove action */
+		comboBox.AppendText("-");
+		comboBox.AppendText(Catalog.GetString("Add or Remove..."));
+
+		SetActiveItem(activeItem, false); //Don't use silent change because the signal is already disabled
+
+		ConnectComboBoxChangedSignal();
+	}
+
+	private void AddAutoDetect () {
+		comboBox.AppendText(Catalog.GetString("Auto Detected"));
+	}
+
+	private void SetActiveItem (int item, bool silent) {
+		int itemCount = comboBox.Model.IterNChildren();
+		if (itemCount == 0)
+			return;
+
+		if (silent)
+			DisconnectComboBoxChangedSignal();
+
+		comboBoxActiveItem = (item < itemCount - 2 ? item : 0);
+		comboBox.Active = comboBoxActiveItem;
+
+		if (silent)
+			ConnectComboBoxChangedSignal();
+	}
+
+	/* Event members */
+	
+	#pragma warning disable 169		//Disables warning about handlers not being used
+
+	private void ConnectHandlers () {
+		comboBox.RowSeparatorFunc = ComboBoxUtil.SeparatorFunc;
+	}
+
+	private void ConnectComboBoxChangedSignal () {
+		comboBox.Changed += OnComboBoxChanged;
+	}
+
+	private void DisconnectComboBoxChangedSignal () {
+		comboBox.Changed -= OnComboBoxChanged;
+	}
+
+	private void OnComboBoxChanged (object o, EventArgs args) {
+		ComboBox comboBox = o as ComboBox;
+		int itemCount = comboBox.Model.IterNChildren();
+		int selectedItem = comboBox.Active;
+
+		if (selectedItem == (itemCount - 1)) {
+			EncodingsDialog dialog = Base.Dialogs.Get(typeof(EncodingsDialog)) as EncodingsDialog;
+			dialog.Show();
+			dialog.WaitForResponse();
+			SetComboBox(dialog.ChosenNames);
+			//SetActiveItem(comboBoxActiveItem, true);
+		}
+		else {
+			comboBoxActiveItem = selectedItem;
+			if (SelectionChanged != null)
+				SelectionChanged(o, args);
+		}
+	}
+
+}
+
+}
diff --git a/src/GnomeSubtitles/Ui/MainUi.cs b/src/GnomeSubtitles/Ui/MainUi.cs
index 66e953d..c2487ba 100644
--- a/src/GnomeSubtitles/Ui/MainUi.cs
+++ b/src/GnomeSubtitles/Ui/MainUi.cs
@@ -1,6 +1,6 @@
 /*
  * This file is part of Gnome Subtitles.
- * Copyright (C) 2006-2009 Pedro Castro
+ * Copyright (C) 2006-2010 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
@@ -102,7 +102,8 @@ public class MainUi {
     	if (args.Length > 0) {
     		string subtitleFile = args[0];
     		Uri videoUri = Base.Config.PrefsVideoAutoChooseFile ? VideoFiles.FindMatchingVideo(subtitleFile) : null;
-			Open(subtitleFile, -1, videoUri);
+			int codePage = GetFileOpenCodePageFromConfig();
+			Open(subtitleFile, codePage, videoUri);
 		}
     }
     
@@ -147,7 +148,7 @@ public class MainUi {
     	bool gotOpenResponse = dialog.WaitForResponse();
     	if (gotOpenResponse && ToOpenAfterWarning()) {
     		string filename = dialog.Filename;
-    		int codePage = (dialog.HasChosenEncoding ? dialog.ChosenEncoding.CodePage : -1);
+    		int codePage = (dialog.Encoding.Equals(EncodingDescription.Empty) ? -1 : dialog.Encoding.CodePage);
     		Uri videoUri = dialog.VideoUri;
     		Open(filename, codePage, videoUri);
     	}
@@ -217,7 +218,7 @@ public class MainUi {
     	bool toOpen = dialog.WaitForResponse();
     	if (toOpen && ToOpenTranslationAfterWarning()) {
     		string filename = dialog.Filename;
-    		int codePage = (dialog.HasChosenEncoding ? dialog.ChosenEncoding.CodePage : -1);
+    		int codePage = (dialog.Encoding.Equals(EncodingDescription.Empty) ? -1 : dialog.Encoding.CodePage);
     		OpenTranslation(filename, codePage);
     	}
     }
@@ -349,7 +350,7 @@ public class MainUi {
 			return null;
 		
 		string path = dialog.Filename;
-		Encoding encoding = Encoding.GetEncoding(dialog.ChosenEncoding.CodePage);
+		Encoding encoding = Encoding.GetEncoding(dialog.Encoding.CodePage);
 		SubtitleType subtitleType = dialog.SubtitleType;			
 		NewlineType newlineType = dialog.NewlineType;
 		TimingMode timingMode = Base.TimingMode;
@@ -445,7 +446,20 @@ public class MainUi {
 		}
 		else window.Title = Base.ExecutionContext.ApplicationName;
 	}
-	
+
+	private int GetFileOpenCodePageFromConfig () {
+		switch (Base.Config.PrefsDefaultsFileOpenEncoding) {
+			case ConfigFileOpenEncoding.CurrentLocale: return Encodings.SystemDefault.CodePage;
+			case ConfigFileOpenEncoding.Fixed:
+				string encodingName = Base.Config.PrefsDefaultsFileOpenEncodingFixed;
+				EncodingDescription encodingDescription = EncodingDescription.Empty;
+				Encodings.Find(encodingName, ref encodingDescription);
+				return encodingDescription.CodePage;
+			default: return -1; //Also accounts for Auto Detect
+		}
+	}
+
+
 	/* Event members */
 	
 	private void OnBaseInitFinished () {



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