[easytag/wip/gsettings] Store ID3v1 and ID3v2 iconv options in GSettings



commit 7ee0b8775c71f2ff932fead394acc3d6c5b298fb
Author: David King <amigadave amigadave com>
Date:   Wed Mar 27 15:49:43 2013 +0000

    Store ID3v1 and ID3v2 iconv options in GSettings

 data/org.gnome.EasyTAG.gschema.xml |    6 +--
 src/charset.c                      |   58 +++++++++++++++++++-------------
 src/id3_tag.c                      |   65 ++++++++++++++++++++++--------------
 src/id3v24_tag.c                   |   12 ++++--
 src/prefs.c                        |   58 +++++++++++++++++++++++++++-----
 src/setting.c                      |   36 --------------------
 src/setting.h                      |   31 +++++++++++------
 7 files changed, 154 insertions(+), 112 deletions(-)
---
diff --git a/data/org.gnome.EasyTAG.gschema.xml b/data/org.gnome.EasyTAG.gschema.xml
index 05e4821..455c601 100644
--- a/data/org.gnome.EasyTAG.gschema.xml
+++ b/data/org.gnome.EasyTAG.gschema.xml
@@ -324,6 +324,7 @@
       tags</description>
       <default>'ISO-8859-1'</default>
     </key>
+    -->
 
     <key name="id3v1-encoding-option" enum="org.gnome.EasyTAG.EtTagEncoding">
       <summary>Encoding options when writing ID3v1 tags</summary>
@@ -331,7 +332,6 @@
       between encodings when writing ID3v1 tags</description>
       <default>'none'</default>
     </key>
-    -->
 
     <key name="id3v2-enabled" type="b">
       <summary>Write ID3v2 tags</summary>
@@ -400,6 +400,7 @@
       writing ID3v2 tags</description>
       <default>'ISO-8859-1'</default>
     </key>
+    -->
 
     <key name="id3v2-encoding-option" enum="org.gnome.EasyTAG.EtTagEncoding">
       <summary>Encoding options when writing ID3v2 tags</summary>
@@ -407,7 +408,6 @@
       between encodings when writing ID3v2 tags</description>
       <default>'none'</default>
     </key>
-    -->
 
     <key name="tag-date-autocomplete" type="b">
       <summary>Automatically complete the date</summary>
@@ -778,7 +778,6 @@
       <default>'lower-case'</default>
     </key>
 
-    <!-- TODO: Generate enums with glib-mkenums.
     <key name="rename-encoding" enum="org.gnome.EasyTAG.EtRenameEncoding">
       <summary>Encoding options when renaming files</summary>
       <description>If the encoding of the filename does not match the
@@ -787,7 +786,6 @@
       characters</description>
       <default>'try-alternative'</default>
     </key>
-    -->
 
     <key name="rename-replace-illegal-chars" type="b">
       <summary>Replace illegal characters when renaming</summary>
diff --git a/src/charset.c b/src/charset.c
index 07fd386..05d4f0a 100644
--- a/src/charset.c
+++ b/src/charset.c
@@ -550,32 +550,44 @@ gchar *filename_from_display (const gchar *string)
         char_encoding = char_encoding+1; // Skip the '.'
     if (char_encoding)
     {
+        EtRenameEncoding enc_option = g_settings_get_enum (ETSettings,
+                                                           "rename-encoding");
         error = NULL;
 
-        if (FILENAME_CHARACTER_SET_OTHER)
+        switch (enc_option)
         {
-            ret = g_convert(string, -1, char_encoding, "UTF-8", NULL, NULL, &error);
-
-        }else if (FILENAME_CHARACTER_SET_APPROXIMATE)
-        {
-            // iconv_open (3):
-            // When the string "//TRANSLIT" is appended to tocode, transliteration
-            // is activated. This means that when a character cannot be represented
-            // in the target character set, it can be approximated through one or
-            // several similarly looking characters.
-            gchar *enc = g_strconcat(char_encoding, "//TRANSLIT", NULL);
-            ret = g_convert(string, -1, enc, "UTF-8", NULL, NULL, &error);
-            g_free(enc);
-
-        }else if (FILENAME_CHARACTER_SET_DISCARD)
-        {
-            // iconv_open (3):
-            // When the string "//IGNORE" is appended to tocode, characters that
-            // cannot be represented in the target character set will be silently
-            // discarded.
-            gchar *enc = g_strconcat(char_encoding, "//IGNORE", NULL);
-            ret = g_convert(string, -1, enc, "UTF-8", NULL, NULL, &error);
-            g_free(enc);
+            case ET_RENAME_ENCODING_TRY_ALTERNATIVE:
+                ret = g_convert (string, -1, char_encoding, "UTF-8", NULL,
+                                 NULL, &error);
+                break;
+            case ET_RENAME_ENCODING_TRANSLITERATE:
+            {
+                /* iconv_open (3):
+                 * When the string "//TRANSLIT" is appended to tocode,
+                 * transliteration is activated. This means that when a
+                 * character cannot be represented in the target character set,
+                 * it can be approximated through one or several similarly
+                 * looking characters.
+                 */
+                gchar *enc = g_strconcat (char_encoding, "//TRANSLIT", NULL);
+                ret = g_convert (string, -1, enc, "UTF-8", NULL, NULL, &error);
+                g_free (enc);
+                break;
+            }
+            case ET_RENAME_ENCODING_IGNORE:
+            {
+                /* iconv_open (3):
+                 * When the string "//IGNORE" is appended to tocode, characters
+                 * that cannot be represented in the target character set will
+                 * be silently discarded.
+                 */
+                gchar *enc = g_strconcat(char_encoding, "//IGNORE", NULL);
+                ret = g_convert(string, -1, enc, "UTF-8", NULL, NULL, &error);
+                g_free (enc);
+                break;
+            }
+            default:
+                g_assert_not_reached ();
         }
     }
 
diff --git a/src/id3_tag.c b/src/id3_tag.c
index 59e340d..4f5277d 100644
--- a/src/id3_tag.c
+++ b/src/id3_tag.c
@@ -1160,37 +1160,52 @@ void Id3tag_Prepare_ID3v1 (ID3Tag *id3_tag)
  * We use specials functionalities of iconv : //TRANSLIT and //IGNORE (the last
  * one doesn't work on my system) to force conversion to the target encoding.
  */
-gchar *Id3tag_Rules_For_ISO_Fields (const gchar *string, const gchar *from_codeset, const gchar *to_codeset)
+gchar *
+Id3tag_Rules_For_ISO_Fields (const gchar *string, const gchar *from_codeset,
+                             const gchar *to_codeset)
 {
     gchar *string_converted = NULL;
+    EtTagEncoding iconv_option;
 
-    if (!string || !from_codeset || !to_codeset)
-        return NULL;
+    g_return_val_if_fail (string || from_codeset || to_codeset, NULL);
 
-    if (FILE_WRITING_ID3V1_ICONV_OPTIONS_NO)
-    {
-        string_converted = convert_string(string,from_codeset,to_codeset,TRUE);
+    iconv_option = g_settings_get_enum (ETSettings, "id3v1-encoding-option");
 
-    }else if (FILE_WRITING_ID3V1_ICONV_OPTIONS_TRANSLIT)
-    {
-        // iconv_open (3):
-        // When the string "//TRANSLIT" is appended to tocode, transliteration
-        // is activated. This means that when a character cannot be represented
-        // in the target character set, it can be approximated through one or
-        // several similarly looking characters.
-        gchar *to_enc = g_strconcat(to_codeset, "//TRANSLIT", NULL);
-        string_converted = convert_string(string,from_codeset,to_enc,TRUE);
-        g_free(to_enc);
-
-    }else if (FILE_WRITING_ID3V1_ICONV_OPTIONS_IGNORE)
+    switch (iconv_option)
     {
-        // iconv_open (3):
-        // When the string "//IGNORE" is appended to tocode, characters that
-        // cannot be represented in the target character set will be silently
-        // discarded.
-        gchar *to_enc = g_strconcat(to_codeset, "//IGNORE", NULL);
-        string_converted = convert_string(string,from_codeset,to_enc,TRUE);
-        g_free(to_enc);
+        default:
+        case ET_TAG_ENCODING_NONE:
+            string_converted = convert_string (string, from_codeset,
+                                               to_codeset, TRUE);
+            break;
+        case ET_TAG_ENCODING_TRANSLITERATE:
+        {
+            /* iconv_open (3):
+             * When the string "//TRANSLIT" is appended to tocode,
+             * transliteration is activated. This means that when a character
+             * cannot be represented in the target character set, it can be
+             * approximated through one or several similarly looking
+             * characters.
+             */
+            gchar *to_enc = g_strconcat (to_codeset, "//TRANSLIT", NULL);
+            string_converted = convert_string (string, from_codeset, to_enc,
+                                               TRUE);
+            g_free (to_enc);
+            break;
+        }
+        case ET_TAG_ENCODING_IGNORE:
+        {
+            /* iconv_open (3):
+             * When the string "//IGNORE" is appended to tocode, characters
+             * that cannot be represented in the target character set will be
+             * silently discarded.
+             */
+            gchar *to_enc = g_strconcat (to_codeset, "//IGNORE", NULL);
+            string_converted = convert_string (string, from_codeset, to_enc,
+                                               TRUE);
+            g_free (to_enc);
+            break;
+        }
     }
 
     return string_converted;
diff --git a/src/id3v24_tag.c b/src/id3v24_tag.c
index 5da025d..05f5633 100644
--- a/src/id3v24_tag.c
+++ b/src/id3v24_tag.c
@@ -1152,10 +1152,12 @@ id3taglib_set_field(struct id3_frame *frame,
             /* id3v1 fields converted using its own character set and iconv options */
             if ( id3v1 )
             {
-                if ( !FILE_WRITING_ID3V1_ICONV_OPTIONS_NO )
+                EtTagEncoding iconv_option = g_settings_get_enum (ETSettings,
+                                                                  "id3v1-encoding-option");
+                if (iconv_option != ET_TAG_ENCODING_NONE)
                     encname = g_strconcat(
                         FILE_WRITING_ID3V1_CHARACTER_SET,
-                        FILE_WRITING_ID3V1_ICONV_OPTIONS_TRANSLIT ? "//TRANSLIT" : "//IGNORE",
+                        iconv_option == ET_TAG_ENCODING_TRANSLITERATE ? "//TRANSLIT" : "//IGNORE",
                         NULL);
                 else
                     encname = g_strdup(FILE_WRITING_ID3V1_CHARACTER_SET);
@@ -1164,10 +1166,12 @@ id3taglib_set_field(struct id3_frame *frame,
                 /* latin1 fields (such as URL) always converted with ISO-8859-1*/
                 if ((type != ID3_FIELD_TYPE_LATIN1) && (type != ID3_FIELD_TYPE_LATIN1FULL))
                 {
-                    if ( FILE_WRITING_ID3V2_ICONV_OPTIONS_NO == 0)
+                    EtTagEncoding iconv_option = g_settings_get_enum (ETSettings,
+                                                                      "id3v2-encoding-option");
+                    if (iconv_option != ET_TAG_ENCODING_NONE)
                         encname = g_strconcat(
                             FILE_WRITING_ID3V2_NO_UNICODE_CHARACTER_SET,
-                            FILE_WRITING_ID3V2_ICONV_OPTIONS_TRANSLIT ? "//TRANSLIT" : "//IGNORE",
+                            iconv_option == ET_TAG_ENCODING_TRANSLITERATE ? "//TRANSLIT" : "//IGNORE",
                             NULL);
                     else
                         encname = g_strdup(FILE_WRITING_ID3V2_NO_UNICODE_CHARACTER_SET);
diff --git a/src/prefs.c b/src/prefs.c
index 78e8fc8..8703ba3 100644
--- a/src/prefs.c
+++ b/src/prefs.c
@@ -543,7 +543,7 @@ void Open_OptionsWindow (void)
     FilenameCharacterSetOther = gtk_radio_button_new_with_label(NULL,_("Try another "
         "character encoding"));
     gtk_grid_attach (GTK_GRID (Table), FilenameCharacterSetOther, 1, 1, 1, 1);
-    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(FilenameCharacterSetOther),FILENAME_CHARACTER_SET_OTHER);
+    gtk_widget_set_name (FilenameCharacterSetOther, "try-alternative");
     gtk_widget_set_tooltip_text(FilenameCharacterSetOther,_("With this option, it will "
         "try the conversion to the encoding associated to your locale (for example: "
         "ISO-8859-1 for 'fr', KOI8-R for 'ru', ISO-8859-2 for 'ro'). If it fails, it "
@@ -554,7 +554,7 @@ void Open_OptionsWindow (void)
         _("Force using the system character encoding and activate the transliteration"));
     gtk_grid_attach (GTK_GRID (Table), FilenameCharacterSetApproximate, 1, 2,
                      1, 1);
-    
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(FilenameCharacterSetApproximate),FILENAME_CHARACTER_SET_APPROXIMATE);
+    gtk_widget_set_name (FilenameCharacterSetApproximate, "transliterate");
     gtk_widget_set_tooltip_text(FilenameCharacterSetApproximate,_("With this option, when "
         "a character cannot be represented in the target character set, it can be "
         "approximated through one or several similarly looking characters."));
@@ -564,7 +564,7 @@ void Open_OptionsWindow (void)
         _("Force using the system character encoding and silently discard some characters"));
     gtk_grid_attach (GTK_GRID (Table), FilenameCharacterSetDiscard, 1, 3, 1,
                      1);
-    
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(FilenameCharacterSetDiscard),FILENAME_CHARACTER_SET_DISCARD);
+    gtk_widget_set_name (FilenameCharacterSetDiscard, "ignore");
     gtk_widget_set_tooltip_text(FilenameCharacterSetDiscard,_("With this option, when "
         "a character cannot be represented in the target character set, it will "
         "be silently discarded."));
@@ -869,7 +869,7 @@ void Open_OptionsWindow (void)
         _("No"));
     gtk_grid_attach (GTK_GRID (Table), FileWritingId3v2IconvOptionsNo, 2, 6, 1,
                      1);
-    
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(FileWritingId3v2IconvOptionsNo),FILE_WRITING_ID3V2_ICONV_OPTIONS_NO);
+    gtk_widget_set_name (FileWritingId3v2IconvOptionsNo, "none");
     gtk_widget_set_tooltip_text(FileWritingId3v2IconvOptionsNo,_("With this option, when "
         "a character cannot be represented in the target character set, it isn't changed. "
         "But note that an error message will be displayed for information."));
@@ -878,7 +878,8 @@ void Open_OptionsWindow (void)
         _("//TRANSLIT"));
     gtk_grid_attach (GTK_GRID (Table), FileWritingId3v2IconvOptionsTranslit, 3,
                      6, 1, 1);
-    
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(FileWritingId3v2IconvOptionsTranslit),FILE_WRITING_ID3V2_ICONV_OPTIONS_TRANSLIT);
+    gtk_widget_set_name (FileWritingId3v2IconvOptionsTranslit,
+                         "transliterate");
     gtk_widget_set_tooltip_text(FileWritingId3v2IconvOptionsTranslit,_("With this option, when "
         "a character cannot be represented in the target character set, it can be "
         "approximated through one or several similarly looking characters."));
@@ -888,11 +889,30 @@ void Open_OptionsWindow (void)
         _("//IGNORE"));
     gtk_grid_attach (GTK_GRID (Table), FileWritingId3v2IconvOptionsIgnore, 4,
                      6, 1, 1);
-    
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(FileWritingId3v2IconvOptionsIgnore),FILE_WRITING_ID3V2_ICONV_OPTIONS_IGNORE);
+    gtk_widget_set_name (FileWritingId3v2IconvOptionsIgnore, "ignore");
     gtk_widget_set_tooltip_text(FileWritingId3v2IconvOptionsIgnore,_("With this option, when "
         "a character cannot be represented in the target character set, it will "
         "be silently discarded."));
 
+    g_settings_bind_with_mapping (ETSettings, "id3v2-encoding-option",
+                                  FileWritingId3v2IconvOptionsNo, "active",
+                                  G_SETTINGS_BIND_DEFAULT,
+                                  et_settings_enum_radio_get,
+                                  et_settings_enum_radio_set,
+                                  FileWritingId3v2IconvOptionsNo, NULL);
+    g_settings_bind_with_mapping (ETSettings, "id3v2-encoding-option",
+                                  FileWritingId3v2IconvOptionsTranslit,
+                                  "active", G_SETTINGS_BIND_DEFAULT,
+                                  et_settings_enum_radio_get,
+                                  et_settings_enum_radio_set,
+                                  FileWritingId3v2IconvOptionsTranslit, NULL);
+    g_settings_bind_with_mapping (ETSettings, "id3v2-encoding-option",
+                                  FileWritingId3v2IconvOptionsIgnore, "active",
+                                  G_SETTINGS_BIND_DEFAULT,
+                                  et_settings_enum_radio_get,
+                                  et_settings_enum_radio_set,
+                                  FileWritingId3v2IconvOptionsIgnore, NULL);
+
     // ID3v1 tags
     Frame = gtk_frame_new (_("ID3v1 tags"));
     gtk_box_pack_start(GTK_BOX(id3v1v2hbox),Frame,FALSE,FALSE,2);
@@ -942,7 +962,7 @@ void Open_OptionsWindow (void)
         _("No"));
     gtk_grid_attach (GTK_GRID (Table), FileWritingId3v1IconvOptionsNo, 1, 4, 1,
                      1);
-    
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(FileWritingId3v1IconvOptionsNo),FILE_WRITING_ID3V1_ICONV_OPTIONS_NO);
+    gtk_widget_set_name (FileWritingId3v1IconvOptionsNo, "none");
     gtk_widget_set_tooltip_text(FileWritingId3v1IconvOptionsNo,_("With this option, when "
         "a character cannot be represented in the target character set, it isn't changed. "
         "But note that an error message will be displayed for information."));
@@ -951,7 +971,8 @@ void Open_OptionsWindow (void)
         _("//TRANSLIT"));
     gtk_grid_attach (GTK_GRID (Table), FileWritingId3v1IconvOptionsTranslit, 2,
                      4, 1, 1);
-    
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(FileWritingId3v1IconvOptionsTranslit),FILE_WRITING_ID3V1_ICONV_OPTIONS_TRANSLIT);
+    gtk_widget_set_name (FileWritingId3v1IconvOptionsTranslit,
+                         "transliterate");
     gtk_widget_set_tooltip_text(FileWritingId3v1IconvOptionsTranslit,_("With this option, when "
         "a character cannot be represented in the target character set, it can be "
         "approximated through one or several similarly looking characters."));
@@ -961,11 +982,30 @@ void Open_OptionsWindow (void)
         _("//IGNORE"));
     gtk_grid_attach (GTK_GRID (Table), FileWritingId3v1IconvOptionsIgnore, 3,
                      4, 1, 1);
-    
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(FileWritingId3v1IconvOptionsIgnore),FILE_WRITING_ID3V1_ICONV_OPTIONS_IGNORE);
+    gtk_widget_set_name (FileWritingId3v1IconvOptionsIgnore, "ignore");
     gtk_widget_set_tooltip_text(FileWritingId3v1IconvOptionsIgnore,_("With this option, when "
         "a character cannot be represented in the target character set, it will "
         "be silently discarded."));
 
+    g_settings_bind_with_mapping (ETSettings, "id3v1-encoding-option",
+                                  FileWritingId3v1IconvOptionsNo, "active",
+                                  G_SETTINGS_BIND_DEFAULT,
+                                  et_settings_enum_radio_get,
+                                  et_settings_enum_radio_set,
+                                  FileWritingId3v1IconvOptionsNo, NULL);
+    g_settings_bind_with_mapping (ETSettings, "id3v1-encoding-option",
+                                  FileWritingId3v1IconvOptionsTranslit,
+                                  "active", G_SETTINGS_BIND_DEFAULT,
+                                  et_settings_enum_radio_get,
+                                  et_settings_enum_radio_set,
+                                  FileWritingId3v1IconvOptionsTranslit, NULL);
+    g_settings_bind_with_mapping (ETSettings, "id3v1-encoding-option",
+                                  FileWritingId3v1IconvOptionsIgnore, "active",
+                                  G_SETTINGS_BIND_DEFAULT,
+                                  et_settings_enum_radio_get,
+                                  et_settings_enum_radio_set,
+                                  FileWritingId3v1IconvOptionsIgnore, NULL);
+
     /* Character Set for reading tag */
     Frame = gtk_frame_new (_("Character Set for reading ID3 tags"));
     gtk_box_pack_start(GTK_BOX(VBox),Frame,FALSE,FALSE,0);
diff --git a/src/setting.c b/src/setting.c
index 65c02e2..46cd010 100644
--- a/src/setting.c
+++ b/src/setting.c
@@ -113,21 +113,11 @@ tConfigVariable Config_Variables[] =
 
     {"sorting_file_case_sensitive",          CV_TYPE_BOOL,    &SORTING_FILE_CASE_SENSITIVE              },
 
-    {"filename_character_set_other",                   CV_TYPE_BOOL,    &FILENAME_CHARACTER_SET_OTHER        
     },
-    {"filename_character_set_approximate",             CV_TYPE_BOOL,    &FILENAME_CHARACTER_SET_APPROXIMATE  
     },
-    {"filename_character_set_discard",                 CV_TYPE_BOOL,    &FILENAME_CHARACTER_SET_DISCARD      
     },
-
     {"file_reading_id3v1v2_character_set",             CV_TYPE_STRING,&FILE_READING_ID3V1V2_CHARACTER_SET},
     {"file_writing_id3v2_version_4",                   CV_TYPE_BOOL,  &FILE_WRITING_ID3V2_VERSION_4   },
     {"file_writing_id3v2_unicode_character_set",       
CV_TYPE_STRING,&FILE_WRITING_ID3V2_UNICODE_CHARACTER_SET},
     {"file_writing_id3v2_no_unicode_character_set",    
CV_TYPE_STRING,&FILE_WRITING_ID3V2_NO_UNICODE_CHARACTER_SET},
-    {"file_writing_id3v2_iconv_options_no",            CV_TYPE_BOOL,  &FILE_WRITING_ID3V2_ICONV_OPTIONS_NO},
-    {"file_writing_id3v2_iconv_options_translit",      CV_TYPE_BOOL,  
&FILE_WRITING_ID3V2_ICONV_OPTIONS_TRANSLIT},
-    {"file_writing_id3v2_iconv_options_ignore",        CV_TYPE_BOOL,  
&FILE_WRITING_ID3V2_ICONV_OPTIONS_IGNORE},
     {"file_writing_id3v1_character_set",               CV_TYPE_STRING,&FILE_WRITING_ID3V1_CHARACTER_SET},
-    {"file_writing_id3v1_iconv_options_no",            CV_TYPE_BOOL,  &FILE_WRITING_ID3V1_ICONV_OPTIONS_NO},
-    {"file_writing_id3v1_iconv_options_translit",      CV_TYPE_BOOL,  
&FILE_WRITING_ID3V1_ICONV_OPTIONS_TRANSLIT},
-    {"file_writing_id3v1_iconv_options_ignore",        CV_TYPE_BOOL,  
&FILE_WRITING_ID3V1_ICONV_OPTIONS_IGNORE},
 
     {"audio_file_player",                       CV_TYPE_STRING,&AUDIO_FILE_PLAYER                        },
 
@@ -227,13 +217,6 @@ void Init_Config_Variables (void)
 #endif /* !G_OS_WIN32 */
 
     /*
-     * File Settings
-     */
-    FILENAME_CHARACTER_SET_OTHER                = 1;
-    FILENAME_CHARACTER_SET_APPROXIMATE          = 0;
-    FILENAME_CHARACTER_SET_DISCARD              = 0;
-
-    /*
      * Tag Settings
      */
     FILE_READING_ID3V1V2_CHARACTER_SET              = g_strdup("UTF-8");
@@ -248,13 +231,7 @@ void Init_Config_Variables (void)
     FILE_WRITING_ID3V2_UNICODE_CHARACTER_SET        = g_strdup("UTF-8");
 #endif /* !G_OS_WIN32 */
     FILE_WRITING_ID3V2_NO_UNICODE_CHARACTER_SET     = g_strdup("ISO-8859-1");
-    FILE_WRITING_ID3V2_ICONV_OPTIONS_NO             = 1;
-    FILE_WRITING_ID3V2_ICONV_OPTIONS_TRANSLIT       = 0;
-    FILE_WRITING_ID3V2_ICONV_OPTIONS_IGNORE         = 0;
     FILE_WRITING_ID3V1_CHARACTER_SET                = g_strdup("ISO-8859-1");
-    FILE_WRITING_ID3V1_ICONV_OPTIONS_NO             = 0;
-    FILE_WRITING_ID3V1_ICONV_OPTIONS_TRANSLIT       = 1;
-    FILE_WRITING_ID3V1_ICONV_OPTIONS_IGNORE         = 0;
 
     /*
      * Scanner
@@ -358,11 +335,6 @@ Apply_Changes_Of_Preferences_Window (void)
         if (AUDIO_FILE_PLAYER) g_free(AUDIO_FILE_PLAYER);
         AUDIO_FILE_PLAYER                       = 
g_strdup(gtk_entry_get_text(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(FilePlayerCombo)))));
 
-        /* File Settings */
-        FILENAME_CHARACTER_SET_OTHER              = 
gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(FilenameCharacterSetOther));
-        FILENAME_CHARACTER_SET_APPROXIMATE        = 
gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(FilenameCharacterSetApproximate));
-        FILENAME_CHARACTER_SET_DISCARD            = 
gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(FilenameCharacterSetDiscard));
-
         /* Tag Settings */
 #ifdef ENABLE_ID3LIB
         active = gtk_combo_box_get_active(GTK_COMBO_BOX(FileWritingId3v2VersionCombo));
@@ -381,18 +353,10 @@ Apply_Changes_Of_Preferences_Window (void)
         FILE_WRITING_ID3V2_NO_UNICODE_CHARACTER_SET  = Charset_Get_Name_From_Title(temp);
         g_free(temp);
 
-        FILE_WRITING_ID3V2_ICONV_OPTIONS_NO          = 
gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(FileWritingId3v2IconvOptionsNo));
-        FILE_WRITING_ID3V2_ICONV_OPTIONS_TRANSLIT    = 
gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(FileWritingId3v2IconvOptionsTranslit));
-        FILE_WRITING_ID3V2_ICONV_OPTIONS_IGNORE      = 
gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(FileWritingId3v2IconvOptionsIgnore));
-
         temp = Get_Active_Combo_Box_Item(GTK_COMBO_BOX(FileWritingId3v1CharacterSetCombo));
         FILE_WRITING_ID3V1_CHARACTER_SET             = Charset_Get_Name_From_Title(temp);
         g_free(temp);
 
-        FILE_WRITING_ID3V1_ICONV_OPTIONS_NO          = 
gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(FileWritingId3v1IconvOptionsNo));
-        FILE_WRITING_ID3V1_ICONV_OPTIONS_TRANSLIT    = 
gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(FileWritingId3v1IconvOptionsTranslit));
-        FILE_WRITING_ID3V1_ICONV_OPTIONS_IGNORE      = 
gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(FileWritingId3v1IconvOptionsIgnore));
-
         /* Scanner */
         // Fill Tag Scanner
         FTS_CONVERT_UNDERSCORE_AND_P20_INTO_SPACE = 
gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(FTSConvertUnderscoreAndP20IntoSpace));
diff --git a/src/setting.h b/src/setting.h
index 55b96e9..8c0e086 100644
--- a/src/setting.h
+++ b/src/setting.h
@@ -62,6 +62,16 @@ typedef enum
 } EtPlaylistContent;
 
 /*
+ * Encoding options when renaming files.
+ */
+typedef enum
+{
+    ET_RENAME_ENCODING_TRY_ALTERNATIVE,
+    ET_RENAME_ENCODING_TRANSLITERATE,
+    ET_RENAME_ENCODING_IGNORE
+} EtRenameEncoding;
+
+/*
  * The mode for the scanner window. See the GSettings key "scanner-type".
  */
 typedef enum
@@ -118,6 +128,16 @@ typedef enum
     ET_SORT_MODE_DESCENDING_FILE_SAMPLERATE
 } EtSortMode;
 
+/*
+ * Additional options to be passed to iconv().
+ */
+typedef enum
+{
+    ET_TAG_ENCODING_NONE,
+    ET_TAG_ENCODING_TRANSLITERATE,
+    ET_TAG_ENCODING_IGNORE
+} EtTagEncoding;
+
 
 /*
  * Config variables
@@ -133,25 +153,14 @@ gint    SORTING_FILE_CASE_SENSITIVE;
 
 gchar  *AUDIO_FILE_PLAYER;
 
-/* File Settings */
-gint    FILENAME_CHARACTER_SET_OTHER;
-gint    FILENAME_CHARACTER_SET_APPROXIMATE;
-gint    FILENAME_CHARACTER_SET_DISCARD;
-
 /* Tag Settings */
 gint    FILE_WRITING_ID3V2_VERSION_4;
 gchar  *FILE_READING_ID3V1V2_CHARACTER_SET;
 
 gchar  *FILE_WRITING_ID3V2_UNICODE_CHARACTER_SET;
 gchar  *FILE_WRITING_ID3V2_NO_UNICODE_CHARACTER_SET;
-gint    FILE_WRITING_ID3V2_ICONV_OPTIONS_NO;
-gint    FILE_WRITING_ID3V2_ICONV_OPTIONS_TRANSLIT;
-gint    FILE_WRITING_ID3V2_ICONV_OPTIONS_IGNORE;
 
 gchar  *FILE_WRITING_ID3V1_CHARACTER_SET;
-gint    FILE_WRITING_ID3V1_ICONV_OPTIONS_NO;
-gint    FILE_WRITING_ID3V1_ICONV_OPTIONS_TRANSLIT;
-gint    FILE_WRITING_ID3V1_ICONV_OPTIONS_IGNORE;
 
 /* Scanner */
 gint    FTS_CONVERT_UNDERSCORE_AND_P20_INTO_SPACE;


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