[easytag/wip/application-window: 13/70] Store the file list sorting mode in GSettings



commit ae1d8fb96b287a9aa9528f8c4b3f9bcf15ea90b0
Author: David King <amigadave amigadave com>
Date:   Thu May 8 08:26:21 2014 +0100

    Store the file list sorting mode in GSettings

 Makefile.am                        |    1 +
 data/org.gnome.EasyTAG.gschema.xml |    2 -
 src/application_window.c           |    8 +-
 src/bar.c                          |   80 ++++++++--------
 src/browser.c                      |  196 +++++++++++++++++++----------------
 src/et_core.c                      |  117 +++++++++++----------
 src/et_core.h                      |   94 ++++-------------
 src/preferences_dialog.c           |   75 +-------------
 src/preferences_dialog.h           |    1 -
 src/setting.c                      |  105 ++++++++++++-------
 src/setting.h                      |   89 +++++++++++++----
 11 files changed, 373 insertions(+), 395 deletions(-)
---
diff --git a/Makefile.am b/Makefile.am
index 12ce60e..9bdb5a0 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -22,6 +22,7 @@ localedir = $(prefix)/$(DATADIRNAME)/locale
 easytag_CPPFLAGS = \
        -I$(top_srcdir) \
        -I$(top_builddir) \
+       -I$(top_builddir)/src \
        $(DEPRECATED_CPPFLAGS) \
        -DLOCALEDIR=\"$(localedir)\"
 
diff --git a/data/org.gnome.EasyTAG.gschema.xml b/data/org.gnome.EasyTAG.gschema.xml
index 2822b98..ed13349 100644
--- a/data/org.gnome.EasyTAG.gschema.xml
+++ b/data/org.gnome.EasyTAG.gschema.xml
@@ -199,13 +199,11 @@
       <default>true</default>
     </key>
 
-    <!-- TODO: Generate enums with glib-mkenums.
     <key name="sort-mode" enum="org.gnome.EasyTAG.EtSortMode">
       <summary>How to sort audio files in the file list</summary>
       <description>Sort files in ascending or descending order for the selected type</description>
       <default>'ascending-track-number'</default>
     </key>
-    -->
 
     <key name="log-lines" type="u">
       <summary>Number of log lines</summary>
diff --git a/src/application_window.c b/src/application_window.c
index 4cc47e3..4a60151 100644
--- a/src/application_window.c
+++ b/src/application_window.c
@@ -640,6 +640,7 @@ Mini_Button_Clicked (GObject *object)
          * So we must browse the whole 'etfilelistfull' to get position of each selected file.
          * Note : 'etfilelistfull' and 'etfilelist' must be sorted in the same order */
         GList *etfilelistfull = NULL;
+        gint sort_mode;
         gchar *path = NULL;
         gchar *path1 = NULL;
         gint i = 0;
@@ -647,9 +648,10 @@ Mini_Button_Clicked (GObject *object)
         /* FIX ME!: see to fill also the Total Track (it's a good idea?) */
         etfilelistfull = g_list_first(ETCore->ETFileList);
 
-        // Sort 'etfilelistfull' and 'etfilelist' in the same order
-        etfilelist     = ET_Sort_File_List(etfilelist,SORTING_FILE_MODE);
-        etfilelistfull = ET_Sort_File_List(etfilelistfull,SORTING_FILE_MODE);
+        /* Sort 'etfilelistfull' and 'etfilelist' in the same order. */
+        sort_mode = g_settings_get_enum (MainSettings, "sort-mode");
+        etfilelist = ET_Sort_File_List (etfilelist, sort_mode);
+        etfilelistfull = ET_Sort_File_List (etfilelistfull, sort_mode);
 
         while (etfilelist && etfilelistfull)
         {
diff --git a/src/bar.c b/src/bar.c
index 5065420..55a8735 100644
--- a/src/bar.c
+++ b/src/bar.c
@@ -96,46 +96,46 @@ Menu_Sort_Action (GtkAction *item, gpointer data)
     const gchar *action = gtk_action_get_name(item);
     GQuark quark = g_quark_from_string(action);
 
-    QCASE_DATA(AM_SORT_ASCENDING_FILENAME,         ET_Sort_Displayed_File_List_And_Update_UI, 
SORTING_BY_ASCENDING_FILENAME);
-    QCASE_DATA(AM_SORT_DESCENDING_FILENAME,        ET_Sort_Displayed_File_List_And_Update_UI, 
SORTING_BY_DESCENDING_FILENAME);
-    QCASE_DATA(AM_SORT_ASCENDING_CREATION_DATE,    ET_Sort_Displayed_File_List_And_Update_UI, 
SORTING_BY_ASCENDING_CREATION_DATE);
-    QCASE_DATA(AM_SORT_DESCENDING_CREATION_DATE,   ET_Sort_Displayed_File_List_And_Update_UI, 
SORTING_BY_DESCENDING_CREATION_DATE);
-    QCASE_DATA(AM_SORT_ASCENDING_TRACK_NUMBER,     ET_Sort_Displayed_File_List_And_Update_UI, 
SORTING_BY_ASCENDING_TRACK_NUMBER);
-    QCASE_DATA(AM_SORT_DESCENDING_TRACK_NUMBER,    ET_Sort_Displayed_File_List_And_Update_UI, 
SORTING_BY_DESCENDING_TRACK_NUMBER);
-    QCASE_DATA(AM_SORT_ASCENDING_TITLE,            ET_Sort_Displayed_File_List_And_Update_UI, 
SORTING_BY_ASCENDING_TITLE);
-    QCASE_DATA(AM_SORT_DESCENDING_TITLE,           ET_Sort_Displayed_File_List_And_Update_UI, 
SORTING_BY_DESCENDING_TITLE);
-    QCASE_DATA(AM_SORT_ASCENDING_ARTIST,           ET_Sort_Displayed_File_List_And_Update_UI, 
SORTING_BY_ASCENDING_ARTIST);
-    QCASE_DATA(AM_SORT_DESCENDING_ARTIST,          ET_Sort_Displayed_File_List_And_Update_UI, 
SORTING_BY_DESCENDING_ARTIST);
-    QCASE_DATA(AM_SORT_ASCENDING_ALBUM_ARTIST,     ET_Sort_Displayed_File_List_And_Update_UI, 
SORTING_BY_ASCENDING_ALBUM_ARTIST);
-    QCASE_DATA(AM_SORT_DESCENDING_ALBUM_ARTIST,    ET_Sort_Displayed_File_List_And_Update_UI, 
SORTING_BY_DESCENDING_ALBUM_ARTIST);
-    QCASE_DATA(AM_SORT_ASCENDING_ALBUM,            ET_Sort_Displayed_File_List_And_Update_UI, 
SORTING_BY_ASCENDING_ALBUM);
-    QCASE_DATA(AM_SORT_DESCENDING_ALBUM,           ET_Sort_Displayed_File_List_And_Update_UI, 
SORTING_BY_DESCENDING_ALBUM);
-    QCASE_DATA(AM_SORT_ASCENDING_YEAR,             ET_Sort_Displayed_File_List_And_Update_UI, 
SORTING_BY_ASCENDING_YEAR);
-    QCASE_DATA(AM_SORT_DESCENDING_YEAR,            ET_Sort_Displayed_File_List_And_Update_UI, 
SORTING_BY_DESCENDING_YEAR);
-    QCASE_DATA(AM_SORT_ASCENDING_GENRE,            ET_Sort_Displayed_File_List_And_Update_UI, 
SORTING_BY_ASCENDING_GENRE);
-    QCASE_DATA(AM_SORT_DESCENDING_GENRE,           ET_Sort_Displayed_File_List_And_Update_UI, 
SORTING_BY_DESCENDING_GENRE);
-    QCASE_DATA(AM_SORT_ASCENDING_COMMENT,          ET_Sort_Displayed_File_List_And_Update_UI, 
SORTING_BY_ASCENDING_COMMENT);
-    QCASE_DATA(AM_SORT_DESCENDING_COMMENT,         ET_Sort_Displayed_File_List_And_Update_UI, 
SORTING_BY_DESCENDING_COMMENT);
-    QCASE_DATA(AM_SORT_ASCENDING_COMPOSER,         ET_Sort_Displayed_File_List_And_Update_UI, 
SORTING_BY_ASCENDING_COMPOSER);
-    QCASE_DATA(AM_SORT_DESCENDING_COMPOSER,        ET_Sort_Displayed_File_List_And_Update_UI, 
SORTING_BY_DESCENDING_COMPOSER);
-    QCASE_DATA(AM_SORT_ASCENDING_ORIG_ARTIST,      ET_Sort_Displayed_File_List_And_Update_UI, 
SORTING_BY_ASCENDING_ORIG_ARTIST);
-    QCASE_DATA(AM_SORT_DESCENDING_ORIG_ARTIST,     ET_Sort_Displayed_File_List_And_Update_UI, 
SORTING_BY_DESCENDING_ORIG_ARTIST);
-    QCASE_DATA(AM_SORT_ASCENDING_COPYRIGHT,        ET_Sort_Displayed_File_List_And_Update_UI, 
SORTING_BY_ASCENDING_COPYRIGHT);
-    QCASE_DATA(AM_SORT_DESCENDING_COPYRIGHT,       ET_Sort_Displayed_File_List_And_Update_UI, 
SORTING_BY_DESCENDING_COPYRIGHT);
-    QCASE_DATA(AM_SORT_ASCENDING_URL,              ET_Sort_Displayed_File_List_And_Update_UI, 
SORTING_BY_ASCENDING_URL);
-    QCASE_DATA(AM_SORT_DESCENDING_URL,             ET_Sort_Displayed_File_List_And_Update_UI, 
SORTING_BY_DESCENDING_URL);
-    QCASE_DATA(AM_SORT_ASCENDING_ENCODED_BY,       ET_Sort_Displayed_File_List_And_Update_UI, 
SORTING_BY_ASCENDING_ENCODED_BY);
-    QCASE_DATA(AM_SORT_DESCENDING_ENCODED_BY,      ET_Sort_Displayed_File_List_And_Update_UI, 
SORTING_BY_DESCENDING_ENCODED_BY);
-    QCASE_DATA(AM_SORT_ASCENDING_FILE_TYPE,        ET_Sort_Displayed_File_List_And_Update_UI, 
SORTING_BY_ASCENDING_FILE_TYPE);
-    QCASE_DATA(AM_SORT_DESCENDING_FILE_TYPE,       ET_Sort_Displayed_File_List_And_Update_UI, 
SORTING_BY_DESCENDING_FILE_TYPE);
-    QCASE_DATA(AM_SORT_ASCENDING_FILE_SIZE,        ET_Sort_Displayed_File_List_And_Update_UI, 
SORTING_BY_ASCENDING_FILE_SIZE);
-    QCASE_DATA(AM_SORT_DESCENDING_FILE_SIZE,       ET_Sort_Displayed_File_List_And_Update_UI, 
SORTING_BY_DESCENDING_FILE_SIZE);
-    QCASE_DATA(AM_SORT_ASCENDING_FILE_DURATION,    ET_Sort_Displayed_File_List_And_Update_UI, 
SORTING_BY_ASCENDING_FILE_DURATION);
-    QCASE_DATA(AM_SORT_DESCENDING_FILE_DURATION,   ET_Sort_Displayed_File_List_And_Update_UI, 
SORTING_BY_DESCENDING_FILE_DURATION);
-    QCASE_DATA(AM_SORT_ASCENDING_FILE_BITRATE,     ET_Sort_Displayed_File_List_And_Update_UI, 
SORTING_BY_ASCENDING_FILE_BITRATE);
-    QCASE_DATA(AM_SORT_DESCENDING_FILE_BITRATE,    ET_Sort_Displayed_File_List_And_Update_UI, 
SORTING_BY_DESCENDING_FILE_BITRATE);
-    QCASE_DATA(AM_SORT_ASCENDING_FILE_SAMPLERATE,  ET_Sort_Displayed_File_List_And_Update_UI, 
SORTING_BY_ASCENDING_FILE_SAMPLERATE);
-    QCASE_DATA(AM_SORT_DESCENDING_FILE_SAMPLERATE, ET_Sort_Displayed_File_List_And_Update_UI, 
SORTING_BY_DESCENDING_FILE_SAMPLERATE);
+    QCASE_DATA(AM_SORT_ASCENDING_FILENAME,         ET_Sort_Displayed_File_List_And_Update_UI, 
ET_SORT_MODE_ASCENDING_FILENAME);
+    QCASE_DATA(AM_SORT_DESCENDING_FILENAME,        ET_Sort_Displayed_File_List_And_Update_UI, 
ET_SORT_MODE_DESCENDING_FILENAME);
+    QCASE_DATA(AM_SORT_ASCENDING_CREATION_DATE,    ET_Sort_Displayed_File_List_And_Update_UI, 
ET_SORT_MODE_ASCENDING_CREATION_DATE);
+    QCASE_DATA(AM_SORT_DESCENDING_CREATION_DATE,   ET_Sort_Displayed_File_List_And_Update_UI, 
ET_SORT_MODE_DESCENDING_CREATION_DATE);
+    QCASE_DATA(AM_SORT_ASCENDING_TRACK_NUMBER,     ET_Sort_Displayed_File_List_And_Update_UI, 
ET_SORT_MODE_ASCENDING_TRACK_NUMBER);
+    QCASE_DATA(AM_SORT_DESCENDING_TRACK_NUMBER,    ET_Sort_Displayed_File_List_And_Update_UI, 
ET_SORT_MODE_DESCENDING_TRACK_NUMBER);
+    QCASE_DATA(AM_SORT_ASCENDING_TITLE,            ET_Sort_Displayed_File_List_And_Update_UI, 
ET_SORT_MODE_ASCENDING_TITLE);
+    QCASE_DATA(AM_SORT_DESCENDING_TITLE,           ET_Sort_Displayed_File_List_And_Update_UI, 
ET_SORT_MODE_DESCENDING_TITLE);
+    QCASE_DATA(AM_SORT_ASCENDING_ARTIST,           ET_Sort_Displayed_File_List_And_Update_UI, 
ET_SORT_MODE_ASCENDING_ARTIST);
+    QCASE_DATA(AM_SORT_DESCENDING_ARTIST,          ET_Sort_Displayed_File_List_And_Update_UI, 
ET_SORT_MODE_DESCENDING_ARTIST);
+    QCASE_DATA(AM_SORT_ASCENDING_ALBUM_ARTIST,     ET_Sort_Displayed_File_List_And_Update_UI, 
ET_SORT_MODE_ASCENDING_ALBUM_ARTIST);
+    QCASE_DATA(AM_SORT_DESCENDING_ALBUM_ARTIST,    ET_Sort_Displayed_File_List_And_Update_UI, 
ET_SORT_MODE_DESCENDING_ALBUM_ARTIST);
+    QCASE_DATA(AM_SORT_ASCENDING_ALBUM,            ET_Sort_Displayed_File_List_And_Update_UI, 
ET_SORT_MODE_ASCENDING_ALBUM);
+    QCASE_DATA(AM_SORT_DESCENDING_ALBUM,           ET_Sort_Displayed_File_List_And_Update_UI, 
ET_SORT_MODE_DESCENDING_ALBUM);
+    QCASE_DATA(AM_SORT_ASCENDING_YEAR,             ET_Sort_Displayed_File_List_And_Update_UI, 
ET_SORT_MODE_ASCENDING_YEAR);
+    QCASE_DATA(AM_SORT_DESCENDING_YEAR,            ET_Sort_Displayed_File_List_And_Update_UI, 
ET_SORT_MODE_DESCENDING_YEAR);
+    QCASE_DATA(AM_SORT_ASCENDING_GENRE,            ET_Sort_Displayed_File_List_And_Update_UI, 
ET_SORT_MODE_ASCENDING_GENRE);
+    QCASE_DATA(AM_SORT_DESCENDING_GENRE,           ET_Sort_Displayed_File_List_And_Update_UI, 
ET_SORT_MODE_DESCENDING_GENRE);
+    QCASE_DATA(AM_SORT_ASCENDING_COMMENT,          ET_Sort_Displayed_File_List_And_Update_UI, 
ET_SORT_MODE_ASCENDING_COMMENT);
+    QCASE_DATA(AM_SORT_DESCENDING_COMMENT,         ET_Sort_Displayed_File_List_And_Update_UI, 
ET_SORT_MODE_DESCENDING_COMMENT);
+    QCASE_DATA(AM_SORT_ASCENDING_COMPOSER,         ET_Sort_Displayed_File_List_And_Update_UI, 
ET_SORT_MODE_ASCENDING_COMPOSER);
+    QCASE_DATA(AM_SORT_DESCENDING_COMPOSER,        ET_Sort_Displayed_File_List_And_Update_UI, 
ET_SORT_MODE_DESCENDING_COMPOSER);
+    QCASE_DATA(AM_SORT_ASCENDING_ORIG_ARTIST,      ET_Sort_Displayed_File_List_And_Update_UI, 
ET_SORT_MODE_ASCENDING_ORIG_ARTIST);
+    QCASE_DATA(AM_SORT_DESCENDING_ORIG_ARTIST,     ET_Sort_Displayed_File_List_And_Update_UI, 
ET_SORT_MODE_DESCENDING_ORIG_ARTIST);
+    QCASE_DATA(AM_SORT_ASCENDING_COPYRIGHT,        ET_Sort_Displayed_File_List_And_Update_UI, 
ET_SORT_MODE_ASCENDING_COPYRIGHT);
+    QCASE_DATA(AM_SORT_DESCENDING_COPYRIGHT,       ET_Sort_Displayed_File_List_And_Update_UI, 
ET_SORT_MODE_DESCENDING_COPYRIGHT);
+    QCASE_DATA(AM_SORT_ASCENDING_URL,              ET_Sort_Displayed_File_List_And_Update_UI, 
ET_SORT_MODE_ASCENDING_URL);
+    QCASE_DATA(AM_SORT_DESCENDING_URL,             ET_Sort_Displayed_File_List_And_Update_UI, 
ET_SORT_MODE_DESCENDING_URL);
+    QCASE_DATA(AM_SORT_ASCENDING_ENCODED_BY,       ET_Sort_Displayed_File_List_And_Update_UI, 
ET_SORT_MODE_ASCENDING_ENCODED_BY);
+    QCASE_DATA(AM_SORT_DESCENDING_ENCODED_BY,      ET_Sort_Displayed_File_List_And_Update_UI, 
ET_SORT_MODE_DESCENDING_ENCODED_BY);
+    QCASE_DATA(AM_SORT_ASCENDING_FILE_TYPE,        ET_Sort_Displayed_File_List_And_Update_UI, 
ET_SORT_MODE_ASCENDING_FILE_TYPE);
+    QCASE_DATA(AM_SORT_DESCENDING_FILE_TYPE,       ET_Sort_Displayed_File_List_And_Update_UI, 
ET_SORT_MODE_DESCENDING_FILE_TYPE);
+    QCASE_DATA(AM_SORT_ASCENDING_FILE_SIZE,        ET_Sort_Displayed_File_List_And_Update_UI, 
ET_SORT_MODE_ASCENDING_FILE_SIZE);
+    QCASE_DATA(AM_SORT_DESCENDING_FILE_SIZE,       ET_Sort_Displayed_File_List_And_Update_UI, 
ET_SORT_MODE_DESCENDING_FILE_SIZE);
+    QCASE_DATA(AM_SORT_ASCENDING_FILE_DURATION,    ET_Sort_Displayed_File_List_And_Update_UI, 
ET_SORT_MODE_ASCENDING_FILE_DURATION);
+    QCASE_DATA(AM_SORT_DESCENDING_FILE_DURATION,   ET_Sort_Displayed_File_List_And_Update_UI, 
ET_SORT_MODE_DESCENDING_FILE_DURATION);
+    QCASE_DATA(AM_SORT_ASCENDING_FILE_BITRATE,     ET_Sort_Displayed_File_List_And_Update_UI, 
ET_SORT_MODE_ASCENDING_FILE_BITRATE);
+    QCASE_DATA(AM_SORT_DESCENDING_FILE_BITRATE,    ET_Sort_Displayed_File_List_And_Update_UI, 
ET_SORT_MODE_DESCENDING_FILE_BITRATE);
+    QCASE_DATA(AM_SORT_ASCENDING_FILE_SAMPLERATE,  ET_Sort_Displayed_File_List_And_Update_UI, 
ET_SORT_MODE_ASCENDING_FILE_SAMPLERATE);
+    QCASE_DATA(AM_SORT_DESCENDING_FILE_SAMPLERATE, ET_Sort_Displayed_File_List_And_Update_UI, 
ET_SORT_MODE_DESCENDING_FILE_SAMPLERATE);
     QCASE_DATA(AM_INITIALIZE_TREE, reload_browser, data);
     et_application_window_browser_refresh_sort (ET_APPLICATION_WINDOW (data));
 }
diff --git a/src/browser.c b/src/browser.c
index f2c4803..a8922ca 100644
--- a/src/browser.c
+++ b/src/browser.c
@@ -70,6 +70,7 @@ struct _EtBrowserPrivate
     GtkListStore *file_model;
     GtkWidget *file_view;
     guint file_selected_handler;
+    EtSortMode file_sort_mode;
 
     GtkWidget *album_list;
     GtkListStore *album_model;
@@ -255,8 +256,8 @@ static void et_run_program_list_on_response (GtkDialog *dialog,
                                              gint response_id,
                                              gpointer user_data);
 
-static void et_browser_set_sorting_file_mode (GtkTreeViewColumn *column,
-                                              gpointer data);
+static void et_browser_on_column_clicked (GtkTreeViewColumn *column,
+                                          gpointer data);
 
 
 /*************
@@ -2081,7 +2082,7 @@ et_browser_clear (EtBrowser *self)
 }
 
 /*
- * Refresh the list sorting (call me after SORTING_FILE_MODE has changed)
+ * Refresh the list sorting (call me after sort-mode has changed)
  */
 void
 et_browser_refresh_sort (EtBrowser *self)
@@ -2111,136 +2112,136 @@ Browser_List_Sort_Func (GtkTreeModel *model, GtkTreeIter *a, GtkTreeIter *b,
     gtk_tree_model_get(model, a, LIST_FILE_POINTER, &ETFile1, -1);
     gtk_tree_model_get(model, b, LIST_FILE_POINTER, &ETFile2, -1);
 
-    switch (SORTING_FILE_MODE)
+    switch (g_settings_get_enum (MainSettings, "sort-mode"))
     {
-        case SORTING_UNKNOWN:
-        case SORTING_BY_ASCENDING_FILENAME:
+        case ET_SORT_MODE_ASCENDING_FILENAME:
             result = ET_Comp_Func_Sort_File_By_Ascending_Filename(ETFile1, ETFile2);
             break;
-        case SORTING_BY_DESCENDING_FILENAME:
+        case ET_SORT_MODE_DESCENDING_FILENAME:
             result = ET_Comp_Func_Sort_File_By_Descending_Filename(ETFile1, ETFile2);
             break;
-        case SORTING_BY_ASCENDING_TITLE:
+        case ET_SORT_MODE_ASCENDING_TITLE:
             result = ET_Comp_Func_Sort_File_By_Ascending_Title(ETFile1, ETFile2);
             break;
-        case SORTING_BY_DESCENDING_TITLE:
+        case ET_SORT_MODE_DESCENDING_TITLE:
             result = ET_Comp_Func_Sort_File_By_Descending_Title(ETFile1, ETFile2);
             break;
-        case SORTING_BY_ASCENDING_ARTIST:
+        case ET_SORT_MODE_ASCENDING_ARTIST:
             result = ET_Comp_Func_Sort_File_By_Ascending_Artist(ETFile1, ETFile2);
             break;
-        case SORTING_BY_DESCENDING_ARTIST:
+        case ET_SORT_MODE_DESCENDING_ARTIST:
             result = ET_Comp_Func_Sort_File_By_Descending_Artist(ETFile1, ETFile2);
             break;
-        case SORTING_BY_ASCENDING_ALBUM_ARTIST:
+        case ET_SORT_MODE_ASCENDING_ALBUM_ARTIST:
             result = ET_Comp_Func_Sort_File_By_Ascending_Album_Artist(ETFile1, ETFile2);
             break;
-        case SORTING_BY_DESCENDING_ALBUM_ARTIST:
+        case ET_SORT_MODE_DESCENDING_ALBUM_ARTIST:
             result = ET_Comp_Func_Sort_File_By_Descending_Album_Artist(ETFile1, ETFile2);
             break;
-        case SORTING_BY_ASCENDING_ALBUM:
+        case ET_SORT_MODE_ASCENDING_ALBUM:
             result = ET_Comp_Func_Sort_File_By_Ascending_Album(ETFile1, ETFile2);
             break;
-        case SORTING_BY_DESCENDING_ALBUM:
+        case ET_SORT_MODE_DESCENDING_ALBUM:
             result = ET_Comp_Func_Sort_File_By_Descending_Album(ETFile1, ETFile2);
             break;
-        case SORTING_BY_ASCENDING_YEAR:
+        case ET_SORT_MODE_ASCENDING_YEAR:
             result = ET_Comp_Func_Sort_File_By_Ascending_Year(ETFile1, ETFile2);
             break;
-        case SORTING_BY_DESCENDING_YEAR:
+        case ET_SORT_MODE_DESCENDING_YEAR:
             result = ET_Comp_Func_Sort_File_By_Descending_Year(ETFile1, ETFile2);
             break;
-        case SORTING_BY_ASCENDING_DISC_NUMBER:
+        case ET_SORT_MODE_ASCENDING_DISC_NUMBER:
             result = et_comp_func_sort_file_by_ascending_disc_number (ETFile1,
                                                                       ETFile2);
             break;
-        case SORTING_BY_DESCENDING_DISC_NUMBER:
+        case ET_SORT_MODE_DESCENDING_DISC_NUMBER:
             result = et_comp_func_sort_file_by_descending_disc_number (ETFile1,
                                                                        ETFile2);
             break;
-        case SORTING_BY_ASCENDING_TRACK_NUMBER:
+        case ET_SORT_MODE_ASCENDING_TRACK_NUMBER:
             result = ET_Comp_Func_Sort_File_By_Ascending_Track_Number (ETFile1, ETFile2);
             break;
-        case SORTING_BY_DESCENDING_TRACK_NUMBER:
+        case ET_SORT_MODE_DESCENDING_TRACK_NUMBER:
             result = ET_Comp_Func_Sort_File_By_Descending_Track_Number (ETFile1, ETFile2);
             break;
-        case SORTING_BY_ASCENDING_GENRE:
+        case ET_SORT_MODE_ASCENDING_GENRE:
             result = ET_Comp_Func_Sort_File_By_Ascending_Genre(ETFile1, ETFile2);
             break;
-        case SORTING_BY_DESCENDING_GENRE:
+        case ET_SORT_MODE_DESCENDING_GENRE:
             result = ET_Comp_Func_Sort_File_By_Descending_Genre(ETFile1, ETFile2);
             break;
-        case SORTING_BY_ASCENDING_COMMENT:
+        case ET_SORT_MODE_ASCENDING_COMMENT:
             result = ET_Comp_Func_Sort_File_By_Ascending_Comment(ETFile1, ETFile2);
             break;
-        case SORTING_BY_DESCENDING_COMMENT:
+        case ET_SORT_MODE_DESCENDING_COMMENT:
             result = ET_Comp_Func_Sort_File_By_Descending_Comment(ETFile1, ETFile2);
             break;
-        case SORTING_BY_ASCENDING_COMPOSER:
+        case ET_SORT_MODE_ASCENDING_COMPOSER:
             result = ET_Comp_Func_Sort_File_By_Ascending_Composer(ETFile1, ETFile2);
             break;
-        case SORTING_BY_DESCENDING_COMPOSER:
+        case ET_SORT_MODE_DESCENDING_COMPOSER:
             result = ET_Comp_Func_Sort_File_By_Descending_Composer(ETFile1, ETFile2);
             break;
-        case SORTING_BY_ASCENDING_ORIG_ARTIST:
+        case ET_SORT_MODE_ASCENDING_ORIG_ARTIST:
             result = ET_Comp_Func_Sort_File_By_Ascending_Orig_Artist(ETFile1, ETFile2);
             break;
-        case SORTING_BY_DESCENDING_ORIG_ARTIST:
+        case ET_SORT_MODE_DESCENDING_ORIG_ARTIST:
             result = ET_Comp_Func_Sort_File_By_Descending_Orig_Artist(ETFile1, ETFile2);
             break;
-        case SORTING_BY_ASCENDING_COPYRIGHT:
+        case ET_SORT_MODE_ASCENDING_COPYRIGHT:
             result = ET_Comp_Func_Sort_File_By_Ascending_Copyright(ETFile1, ETFile2);
             break;
-        case SORTING_BY_DESCENDING_COPYRIGHT:
+        case ET_SORT_MODE_DESCENDING_COPYRIGHT:
             result = ET_Comp_Func_Sort_File_By_Descending_Copyright(ETFile1, ETFile2);
             break;
-        case SORTING_BY_ASCENDING_URL:
+        case ET_SORT_MODE_ASCENDING_URL:
             result = ET_Comp_Func_Sort_File_By_Ascending_Url(ETFile1, ETFile2);
             break;
-        case SORTING_BY_DESCENDING_URL:
+        case ET_SORT_MODE_DESCENDING_URL:
             result = ET_Comp_Func_Sort_File_By_Descending_Url(ETFile1, ETFile2);
             break;
-        case SORTING_BY_ASCENDING_ENCODED_BY:
+        case ET_SORT_MODE_ASCENDING_ENCODED_BY:
             result = ET_Comp_Func_Sort_File_By_Ascending_Encoded_By(ETFile1, ETFile2);
             break;
-        case SORTING_BY_DESCENDING_ENCODED_BY:
+        case ET_SORT_MODE_DESCENDING_ENCODED_BY:
             result = ET_Comp_Func_Sort_File_By_Descending_Encoded_By(ETFile1, ETFile2);
             break;
-        case SORTING_BY_ASCENDING_CREATION_DATE:
-            result = ET_Comp_Func_Sort_File_By_Ascending_Creation_Date (ETFile1,                             
                                           ETFile2);
+        case ET_SORT_MODE_ASCENDING_CREATION_DATE:
+            result = ET_Comp_Func_Sort_File_By_Ascending_Creation_Date (ETFile1,
+                                                                        ETFile2);
             break;
-        case SORTING_BY_DESCENDING_CREATION_DATE:
+        case ET_SORT_MODE_DESCENDING_CREATION_DATE:
             result = ET_Comp_Func_Sort_File_By_Descending_Creation_Date (ETFile1,
                                                                          ETFile2);
             break;
-        case SORTING_BY_ASCENDING_FILE_TYPE:
+        case ET_SORT_MODE_ASCENDING_FILE_TYPE:
             result = ET_Comp_Func_Sort_File_By_Ascending_File_Type(ETFile1, ETFile2);
             break;
-        case SORTING_BY_DESCENDING_FILE_TYPE:
+        case ET_SORT_MODE_DESCENDING_FILE_TYPE:
             result = ET_Comp_Func_Sort_File_By_Descending_File_Type(ETFile1, ETFile2);
             break;
-        case SORTING_BY_ASCENDING_FILE_SIZE:
+        case ET_SORT_MODE_ASCENDING_FILE_SIZE:
             result = ET_Comp_Func_Sort_File_By_Ascending_File_Size(ETFile1, ETFile2);
             break;
-        case SORTING_BY_DESCENDING_FILE_SIZE:
+        case ET_SORT_MODE_DESCENDING_FILE_SIZE:
             result = ET_Comp_Func_Sort_File_By_Descending_File_Size(ETFile1, ETFile2);
             break;
-        case SORTING_BY_ASCENDING_FILE_DURATION:
+        case ET_SORT_MODE_ASCENDING_FILE_DURATION:
             result = ET_Comp_Func_Sort_File_By_Ascending_File_Duration(ETFile1, ETFile2);
             break;
-        case SORTING_BY_DESCENDING_FILE_DURATION:
+        case ET_SORT_MODE_DESCENDING_FILE_DURATION:
             result = ET_Comp_Func_Sort_File_By_Descending_File_Duration(ETFile1, ETFile2);
             break;
-        case SORTING_BY_ASCENDING_FILE_BITRATE:
+        case ET_SORT_MODE_ASCENDING_FILE_BITRATE:
             result = ET_Comp_Func_Sort_File_By_Ascending_File_Bitrate(ETFile1, ETFile2);
             break;
-        case SORTING_BY_DESCENDING_FILE_BITRATE:
+        case ET_SORT_MODE_DESCENDING_FILE_BITRATE:
             result = ET_Comp_Func_Sort_File_By_Descending_File_Bitrate(ETFile1, ETFile2);
             break;
-        case SORTING_BY_ASCENDING_FILE_SAMPLERATE:
+        case ET_SORT_MODE_ASCENDING_FILE_SAMPLERATE:
             result = ET_Comp_Func_Sort_File_By_Ascending_File_Samplerate(ETFile1, ETFile2);
             break;
-        case SORTING_BY_DESCENDING_FILE_SAMPLERATE:
+        case ET_SORT_MODE_DESCENDING_FILE_SAMPLERATE:
             result = ET_Comp_Func_Sort_File_By_Descending_File_Samplerate(ETFile1, ETFile2);
             break;
     }
@@ -3575,6 +3576,52 @@ collapse_cb (EtBrowser *self, GtkTreeIter *iter, GtkTreePath *treePath, GtkTreeV
     g_object_unref (icon);
 }
 
+static void
+on_sort_mode_changed (EtBrowser *self, gchar *key, GSettings *settings)
+{
+    EtBrowserPrivate *priv;
+    EtSortMode sort_mode;
+    GtkTreeViewColumn *column;
+
+    priv = et_browser_get_instance_private (self);
+
+    sort_mode = g_settings_get_enum (MainSettings, key);
+    column = et_browser_get_column_for_column_id (self, sort_mode / 2);
+
+    /* If the column to sort is different than the old sorted column. */
+    if (sort_mode / 2 != priv->file_sort_mode / 2)
+    {
+        GtkTreeViewColumn *old_column;
+
+        old_column = et_browser_get_column_for_column_id (self,
+                                                          priv->file_sort_mode / 2);
+
+        /* Reset the sort order of the old sort column. */
+        if (gtk_tree_view_column_get_sort_order (old_column)
+            == GTK_SORT_DESCENDING)
+        {
+            gtk_tree_view_column_set_sort_order (old_column,
+                                                 GTK_SORT_ASCENDING);
+        }
+
+        gtk_tree_view_column_set_sort_indicator (old_column, FALSE);
+    }
+
+    /* New sort mode is for a column with a visible counterpart. */
+    if (sort_mode / 2 < ET_SORT_MODE_ASCENDING_CREATION_DATE)
+    {
+        gtk_tree_view_column_set_sort_indicator (column, TRUE);
+    }
+
+    /* Even is GTK_SORT_ASCENDING, odd is GTK_SORT_DESCENDING. */
+    gtk_tree_view_column_set_sort_order (column, sort_mode % 2);
+
+    /* Store the new sort mode. */
+    priv->file_sort_mode = sort_mode;
+
+    et_browser_refresh_sort (self);
+}
+
 /*
  * Create item of the browser (Entry + Tree + List).
  */
@@ -3951,10 +3998,12 @@ create_browser (EtBrowser *self)
         gtk_tree_view_column_set_clickable (column, TRUE);
         g_object_set_data (G_OBJECT (column), "browser", self);
         g_signal_connect (column, "clicked",
-                          G_CALLBACK (et_browser_set_sorting_file_mode),
+                          G_CALLBACK (et_browser_on_column_clicked),
                           GINT_TO_POINTER (ascending_sort));
     }
 
+    g_signal_connect_swapped (MainSettings, "changed::sort-mode",
+                              G_CALLBACK (on_sort_mode_changed), self);
     gtk_tree_view_set_reorderable(GTK_TREE_VIEW(priv->file_view), FALSE);
     
gtk_tree_selection_set_mode(gtk_tree_view_get_selection(GTK_TREE_VIEW(priv->file_view)),GTK_SELECTION_MULTIPLE);
     /* When selecting a line. */
@@ -4010,61 +4059,28 @@ create_browser (EtBrowser *self)
 }
 
 /*
- * et_browser_set_sorting_file_mode:
+ * et_browser_on_column_clicked:
  * @column: the tree view column to sort
  * @data: the (required) #ET_Sorting_Type, converted to a pointer with
  * #GINT_TO_POINTER
  *
- * Set the #SORTING_FILE_MODE and display appropriate sort indicator when
+ * Set the sort mode and display appropriate sort indicator when
  * column is clicked.
  */
 static void
-et_browser_set_sorting_file_mode (GtkTreeViewColumn *column, gpointer data)
+et_browser_on_column_clicked (GtkTreeViewColumn *column, gpointer data)
 {
-    EtBrowser *self;
-    gint column_id = SORTING_FILE_MODE / 2;
-
-    self = ET_BROWSER (g_object_get_data (G_OBJECT (column), "browser"));
-
-    if (gtk_tree_view_column_get_sort_indicator (column) == FALSE
-        && SORTING_FILE_MODE < SORTING_BY_ASCENDING_CREATION_DATE)
-    {
-        if (et_browser_get_sort_order_for_column_id (self, SORTING_FILE_MODE / 2) == GTK_SORT_DESCENDING)
-        {
-            gtk_tree_view_column_set_sort_order (et_browser_get_column_for_column_id (self, column_id),
-                                                 GTK_SORT_ASCENDING);
-        }
-        gtk_tree_view_column_set_sort_indicator (et_browser_get_column_for_column_id (self, column_id),
-                                                 FALSE);
-    }
-    else if (gtk_tree_view_column_get_sort_order (column) == GTK_SORT_ASCENDING)
-    {
-        gtk_tree_view_column_set_sort_order (column, GTK_SORT_DESCENDING);
-    }
-    else
-    {
-        gtk_tree_view_column_set_sort_order (column, GTK_SORT_ASCENDING);
-    }
-
-    if (SORTING_FILE_MODE > SORTING_BY_DESCENDING_ENCODED_BY)
-    {
-        gtk_tree_view_column_set_sort_indicator (column, TRUE);
-        gtk_tree_view_column_set_sort_order (column, GTK_SORT_ASCENDING);
-    }
-
+    /* Flip to a descing sort mode if the row is already sorted ascending. */
     if (gtk_tree_view_column_get_sort_order (column) == GTK_SORT_ASCENDING)
     {
-        SORTING_FILE_MODE = GPOINTER_TO_INT (data);
+        g_settings_set_enum (MainSettings, "sort-mode",
+                             GPOINTER_TO_INT (data) + 1);
     }
     else
     {
-        SORTING_FILE_MODE = GPOINTER_TO_INT (data) + 1;
+        g_settings_set_enum (MainSettings, "sort-mode",
+                             GPOINTER_TO_INT (data));
     }
-
-    gtk_tree_view_column_set_sort_indicator (column, TRUE);
-
-    /* FIXME! */
-    et_application_window_browser_refresh_sort (ET_APPLICATION_WINDOW (MainWindow));
 }
 
 /*******************************
diff --git a/src/et_core.c b/src/et_core.c
index bb3a0d2..681facc 100644
--- a/src/et_core.c
+++ b/src/et_core.c
@@ -196,7 +196,7 @@ static gchar *ET_File_Name_Format_Extension (ET_File *ETFile);
 
 static void set_sort_order_for_column_id (gint column_id,
                                           GtkTreeViewColumn *column,
-                                          ET_Sorting_Type sort_type);
+                                          EtSortMode sort_type);
 
 
 /*******************
@@ -987,14 +987,16 @@ ET_Remove_File_From_Artist_Album_List (ET_File *ETFile)
  * Note : Add also new sorting in 'Browser_List_Sort_Func'
  */
 static void
-ET_Sort_Displayed_File_List (ET_Sorting_Type Sorting_Type)
+ET_Sort_Displayed_File_List (EtSortMode Sorting_Type)
 {
     ETCore->ETFileDisplayedList = ET_Sort_File_List(ETCore->ETFileDisplayedList,Sorting_Type);
 }
+
 /*
  * Sort an 'ETFileList'
  */
-GList *ET_Sort_File_List (GList *ETFileList, ET_Sorting_Type Sorting_Type)
+GList *
+ET_Sort_File_List (GList *ETFileList, EtSortMode Sorting_Type)
 {
     EtApplicationWindow *window;
     GtkTreeViewColumn *column;
@@ -1008,147 +1010,147 @@ GList *ET_Sort_File_List (GList *ETFileList, ET_Sorting_Type Sorting_Type)
     /* Important to rewind before. */
     etfilelist = g_list_first (ETFileList);
 
+    /* FIXME: Port to sort-mode? */
     set_sort_order_for_column_id (column_id, column, Sorting_Type);
 
-    // Sort...
+    /* Sort... */
     switch (Sorting_Type)
     {
-        case SORTING_UNKNOWN:
-        case SORTING_BY_ASCENDING_FILENAME:
+        case ET_SORT_MODE_ASCENDING_FILENAME:
             etfilelist = g_list_sort(etfilelist,(GCompareFunc)ET_Comp_Func_Sort_File_By_Ascending_Filename);
             break;
-        case SORTING_BY_DESCENDING_FILENAME:
+        case ET_SORT_MODE_DESCENDING_FILENAME:
             etfilelist = g_list_sort(etfilelist,(GCompareFunc)ET_Comp_Func_Sort_File_By_Descending_Filename);
             break;
-        case SORTING_BY_ASCENDING_TITLE:
+        case ET_SORT_MODE_ASCENDING_TITLE:
             etfilelist = g_list_sort(etfilelist,(GCompareFunc)ET_Comp_Func_Sort_File_By_Ascending_Title);
             break;
-        case SORTING_BY_DESCENDING_TITLE:
+        case ET_SORT_MODE_DESCENDING_TITLE:
             etfilelist = g_list_sort(etfilelist,(GCompareFunc)ET_Comp_Func_Sort_File_By_Descending_Title);
             break;
-        case SORTING_BY_ASCENDING_ARTIST:
+        case ET_SORT_MODE_ASCENDING_ARTIST:
             etfilelist = g_list_sort(etfilelist,(GCompareFunc)ET_Comp_Func_Sort_File_By_Ascending_Artist);
             break;
-        case SORTING_BY_DESCENDING_ARTIST:
+        case ET_SORT_MODE_DESCENDING_ARTIST:
             etfilelist = g_list_sort(etfilelist,(GCompareFunc)ET_Comp_Func_Sort_File_By_Descending_Artist);
             break;
-        case SORTING_BY_ASCENDING_ALBUM_ARTIST:
+        case ET_SORT_MODE_ASCENDING_ALBUM_ARTIST:
             etfilelist = 
g_list_sort(etfilelist,(GCompareFunc)ET_Comp_Func_Sort_File_By_Ascending_Album_Artist);
             break;
-        case SORTING_BY_DESCENDING_ALBUM_ARTIST:
+        case ET_SORT_MODE_DESCENDING_ALBUM_ARTIST:
             etfilelist = 
g_list_sort(etfilelist,(GCompareFunc)ET_Comp_Func_Sort_File_By_Descending_Album_Artist);
             break;
-               case SORTING_BY_ASCENDING_ALBUM:
+               case ET_SORT_MODE_ASCENDING_ALBUM:
             etfilelist = g_list_sort(etfilelist,(GCompareFunc)ET_Comp_Func_Sort_File_By_Ascending_Album);
             break;
-        case SORTING_BY_DESCENDING_ALBUM:
+        case ET_SORT_MODE_DESCENDING_ALBUM:
             etfilelist = g_list_sort(etfilelist,(GCompareFunc)ET_Comp_Func_Sort_File_By_Descending_Album);
             break;
-        case SORTING_BY_ASCENDING_YEAR:
+        case ET_SORT_MODE_ASCENDING_YEAR:
             etfilelist = g_list_sort(etfilelist,(GCompareFunc)ET_Comp_Func_Sort_File_By_Ascending_Year);
             break;
-        case SORTING_BY_DESCENDING_YEAR:
+        case ET_SORT_MODE_DESCENDING_YEAR:
             etfilelist = g_list_sort(etfilelist,(GCompareFunc)ET_Comp_Func_Sort_File_By_Descending_Year);
             break;
-        case SORTING_BY_ASCENDING_DISC_NUMBER:
+        case ET_SORT_MODE_ASCENDING_DISC_NUMBER:
             etfilelist = g_list_sort (etfilelist,
                                       (GCompareFunc)et_comp_func_sort_file_by_ascending_disc_number);
             break;
-        case SORTING_BY_DESCENDING_DISC_NUMBER:
+        case ET_SORT_MODE_DESCENDING_DISC_NUMBER:
             etfilelist = g_list_sort (etfilelist,
                                       (GCompareFunc)et_comp_func_sort_file_by_descending_disc_number);
             break;
-        case SORTING_BY_ASCENDING_TRACK_NUMBER:
+        case ET_SORT_MODE_ASCENDING_TRACK_NUMBER:
             etfilelist = g_list_sort (etfilelist,
                                       (GCompareFunc)ET_Comp_Func_Sort_File_By_Ascending_Track_Number);
             break;
-        case SORTING_BY_DESCENDING_TRACK_NUMBER:
+        case ET_SORT_MODE_DESCENDING_TRACK_NUMBER:
             etfilelist = g_list_sort (etfilelist,
                                       (GCompareFunc)ET_Comp_Func_Sort_File_By_Descending_Track_Number);
             break;
-        case SORTING_BY_ASCENDING_GENRE:
+        case ET_SORT_MODE_ASCENDING_GENRE:
             etfilelist = g_list_sort(etfilelist,(GCompareFunc)ET_Comp_Func_Sort_File_By_Ascending_Genre);
             break;
-        case SORTING_BY_DESCENDING_GENRE:
+        case ET_SORT_MODE_DESCENDING_GENRE:
             etfilelist = g_list_sort(etfilelist,(GCompareFunc)ET_Comp_Func_Sort_File_By_Descending_Genre);
             break;
-        case SORTING_BY_ASCENDING_COMMENT:
+        case ET_SORT_MODE_ASCENDING_COMMENT:
             etfilelist = g_list_sort(etfilelist,(GCompareFunc)ET_Comp_Func_Sort_File_By_Ascending_Comment);
             break;
-        case SORTING_BY_DESCENDING_COMMENT:
+        case ET_SORT_MODE_DESCENDING_COMMENT:
             etfilelist = g_list_sort(etfilelist,(GCompareFunc)ET_Comp_Func_Sort_File_By_Descending_Comment);
             break;
-        case SORTING_BY_ASCENDING_COMPOSER:
+        case ET_SORT_MODE_ASCENDING_COMPOSER:
             etfilelist = g_list_sort(etfilelist,(GCompareFunc)ET_Comp_Func_Sort_File_By_Ascending_Composer);
             break;
-        case SORTING_BY_DESCENDING_COMPOSER:
+        case ET_SORT_MODE_DESCENDING_COMPOSER:
             etfilelist = g_list_sort(etfilelist,(GCompareFunc)ET_Comp_Func_Sort_File_By_Descending_Composer);
             break;
-        case SORTING_BY_ASCENDING_ORIG_ARTIST:
+        case ET_SORT_MODE_ASCENDING_ORIG_ARTIST:
             etfilelist = 
g_list_sort(etfilelist,(GCompareFunc)ET_Comp_Func_Sort_File_By_Ascending_Orig_Artist);
             break;
-        case SORTING_BY_DESCENDING_ORIG_ARTIST:
+        case ET_SORT_MODE_DESCENDING_ORIG_ARTIST:
             etfilelist = 
g_list_sort(etfilelist,(GCompareFunc)ET_Comp_Func_Sort_File_By_Descending_Orig_Artist);
             break;
-        case SORTING_BY_ASCENDING_COPYRIGHT:
+        case ET_SORT_MODE_ASCENDING_COPYRIGHT:
             etfilelist = g_list_sort(etfilelist,(GCompareFunc)ET_Comp_Func_Sort_File_By_Ascending_Copyright);
             break;
-        case SORTING_BY_DESCENDING_COPYRIGHT:
+        case ET_SORT_MODE_DESCENDING_COPYRIGHT:
             etfilelist = 
g_list_sort(etfilelist,(GCompareFunc)ET_Comp_Func_Sort_File_By_Descending_Copyright);
             break;
-        case SORTING_BY_ASCENDING_URL:
+        case ET_SORT_MODE_ASCENDING_URL:
             etfilelist = g_list_sort(etfilelist,(GCompareFunc)ET_Comp_Func_Sort_File_By_Ascending_Url);
             break;
-        case SORTING_BY_DESCENDING_URL:
+        case ET_SORT_MODE_DESCENDING_URL:
             etfilelist = g_list_sort(etfilelist,(GCompareFunc)ET_Comp_Func_Sort_File_By_Descending_Url);
             break;
-        case SORTING_BY_ASCENDING_ENCODED_BY:
+        case ET_SORT_MODE_ASCENDING_ENCODED_BY:
             etfilelist = 
g_list_sort(etfilelist,(GCompareFunc)ET_Comp_Func_Sort_File_By_Ascending_Encoded_By);
             break;
-        case SORTING_BY_DESCENDING_ENCODED_BY:
+        case ET_SORT_MODE_DESCENDING_ENCODED_BY:
             etfilelist = 
g_list_sort(etfilelist,(GCompareFunc)ET_Comp_Func_Sort_File_By_Descending_Encoded_By);
             break;
-        case SORTING_BY_ASCENDING_CREATION_DATE:
+        case ET_SORT_MODE_ASCENDING_CREATION_DATE:
             etfilelist = g_list_sort (etfilelist,
                                       (GCompareFunc)ET_Comp_Func_Sort_File_By_Ascending_Creation_Date);
             break;
-        case SORTING_BY_DESCENDING_CREATION_DATE:
+        case ET_SORT_MODE_DESCENDING_CREATION_DATE:
             etfilelist = g_list_sort (etfilelist,
                                       (GCompareFunc)ET_Comp_Func_Sort_File_By_Descending_Creation_Date);
             break;
-        case SORTING_BY_ASCENDING_FILE_TYPE:
+        case ET_SORT_MODE_ASCENDING_FILE_TYPE:
             etfilelist = g_list_sort(etfilelist,(GCompareFunc)ET_Comp_Func_Sort_File_By_Ascending_File_Type);
             break;
-        case SORTING_BY_DESCENDING_FILE_TYPE:
+        case ET_SORT_MODE_DESCENDING_FILE_TYPE:
             etfilelist = 
g_list_sort(etfilelist,(GCompareFunc)ET_Comp_Func_Sort_File_By_Descending_File_Type);
             break;
-        case SORTING_BY_ASCENDING_FILE_SIZE:
+        case ET_SORT_MODE_ASCENDING_FILE_SIZE:
             etfilelist = g_list_sort(etfilelist,(GCompareFunc)ET_Comp_Func_Sort_File_By_Ascending_File_Size);
             break;
-        case SORTING_BY_DESCENDING_FILE_SIZE:
+        case ET_SORT_MODE_DESCENDING_FILE_SIZE:
             etfilelist = 
g_list_sort(etfilelist,(GCompareFunc)ET_Comp_Func_Sort_File_By_Descending_File_Size);
             break;
-        case SORTING_BY_ASCENDING_FILE_DURATION:
+        case ET_SORT_MODE_ASCENDING_FILE_DURATION:
             etfilelist = 
g_list_sort(etfilelist,(GCompareFunc)ET_Comp_Func_Sort_File_By_Ascending_File_Duration);
             break;
-        case SORTING_BY_DESCENDING_FILE_DURATION:
+        case ET_SORT_MODE_DESCENDING_FILE_DURATION:
             etfilelist = 
g_list_sort(etfilelist,(GCompareFunc)ET_Comp_Func_Sort_File_By_Descending_File_Duration);
             break;
-        case SORTING_BY_ASCENDING_FILE_BITRATE:
+        case ET_SORT_MODE_ASCENDING_FILE_BITRATE:
             etfilelist = 
g_list_sort(etfilelist,(GCompareFunc)ET_Comp_Func_Sort_File_By_Ascending_File_Bitrate);
             break;
-        case SORTING_BY_DESCENDING_FILE_BITRATE:
+        case ET_SORT_MODE_DESCENDING_FILE_BITRATE:
             etfilelist = 
g_list_sort(etfilelist,(GCompareFunc)ET_Comp_Func_Sort_File_By_Descending_File_Bitrate);
             break;
-        case SORTING_BY_ASCENDING_FILE_SAMPLERATE:
+        case ET_SORT_MODE_ASCENDING_FILE_SAMPLERATE:
             etfilelist = 
g_list_sort(etfilelist,(GCompareFunc)ET_Comp_Func_Sort_File_By_Ascending_File_Samplerate);
             break;
-        case SORTING_BY_DESCENDING_FILE_SAMPLERATE:
+        case ET_SORT_MODE_DESCENDING_FILE_SAMPLERATE:
             etfilelist = 
g_list_sort(etfilelist,(GCompareFunc)ET_Comp_Func_Sort_File_By_Descending_File_Samplerate);
             break;
     }
     /* Save sorting mode (note: needed when called from UI). */
-    SORTING_FILE_MODE = Sorting_Type;
+    g_settings_set_enum (MainSettings, "sort-mode", Sorting_Type);
 
     //ETFileList = g_list_first(etfilelist);
     return g_list_first(etfilelist);
@@ -1158,7 +1160,8 @@ GList *ET_Sort_File_List (GList *ETFileList, ET_Sorting_Type Sorting_Type)
 /*
  * Sort the list of files following the 'Sorting_Type' value. The new sorting is displayed in the UI.
  */
-void ET_Sort_Displayed_File_List_And_Update_UI (ET_Sorting_Type Sorting_Type)
+void
+ET_Sort_Displayed_File_List_And_Update_UI (EtSortMode Sorting_Type)
 {
     g_return_if_fail (ETCore->ETFileList != NULL);
 
@@ -2171,8 +2174,9 @@ gboolean ET_Set_Displayed_File_List (GList *ETFileList)
         ETCore->ETFileDisplayedList_TotalDuration += ((ET_File_Info *)((ET_File 
*)l->data)->ETFileInfo)->duration;
     }
 
-    // Sort the file list
-    ET_Sort_Displayed_File_List(SORTING_FILE_MODE);
+    /* Sort the file list. */
+    ET_Sort_Displayed_File_List (g_settings_get_enum (MainSettings,
+                                 "sort-mode"));
 
     // Should renums ETCore->ETFileDisplayedList only!
     ET_Displayed_File_List_Number();
@@ -5064,21 +5068,24 @@ ET_Get_Number_Of_Files_In_Directory (const gchar *path_utf8)
  */
 static void
 set_sort_order_for_column_id (gint column_id, GtkTreeViewColumn *column,
-                              ET_Sorting_Type sort_type)
+                              EtSortMode sort_type)
 {
     EtApplicationWindow *window;
+    EtSortMode current_mode;
 
     window = ET_APPLICATION_WINDOW (MainWindow);
 
     /* Removing the sort indicator for the currently selected treeview
      * column. */
-    if (SORTING_FILE_MODE < SORTING_BY_ASCENDING_CREATION_DATE)
+    current_mode = g_settings_get_enum (MainSettings, "sort-mode");
+
+    if (current_mode < ET_SORT_MODE_ASCENDING_CREATION_DATE)
     {
-        gtk_tree_view_column_set_sort_indicator (et_application_window_browser_get_column_for_column_id 
(window, SORTING_FILE_MODE / 2),
+        gtk_tree_view_column_set_sort_indicator (et_application_window_browser_get_column_for_column_id 
(window, current_mode / 2),
                                                  FALSE);
     }
 
-    if (sort_type < SORTING_BY_ASCENDING_CREATION_DATE)
+    if (sort_type < ET_SORT_MODE_ASCENDING_CREATION_DATE)
     {
         gtk_tree_view_column_clicked (et_application_window_browser_get_column_for_column_id (window, 
column_id));
 
diff --git a/src/et_core.h b/src/et_core.h
index 7fb051b..5216181 100644
--- a/src/et_core.h
+++ b/src/et_core.h
@@ -1,31 +1,31 @@
-/* et_core.h - 2001/10/21 */
-/*
- *  EasyTAG - Tag editor for MP3 and Ogg Vorbis files
- *  Copyright (C) 2000-2003  Jerome Couderc <easytag gmail com>
+/* EasyTAG - Tag editor for audio files
+ * Copyright (C) 2014  David King <amigadave amigadave com>
+ * Copyright (C) 2000-2003  Jerome Couderc <easytag gmail com>
  *
- *  This program 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.
+ * This program 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.
  *
- *  This program 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.
+ * This program 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 Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * 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 Street, Fifth Floor, Boston, MA 02110-1301, USA.
  */
 
+#ifndef ET_CORE_H_
+#define ET_CORE_H_
 
-#ifndef __ET_CORE_H__
-#define __ET_CORE_H__
+#include "config.h" /* For definition of ENABLE_OGG and so on. */
 
+#include "setting.h"
 
 #include <glib.h>
 #include <gdk/gdk.h>
-#include <config.h> // For definition of ENABLE_OGG, ...
 
 G_BEGIN_DECLS
 
@@ -34,58 +34,6 @@ G_BEGIN_DECLS
  */
 extern GdkRGBA RED;
 
-
-/*
- * Types of sorting (discontinuous value to avoid separators in SortingFileOptionMenu).
- */
-typedef enum
-{
-    SORTING_BY_ASCENDING_FILENAME,
-    SORTING_BY_DESCENDING_FILENAME,
-    SORTING_BY_ASCENDING_TITLE,
-    SORTING_BY_DESCENDING_TITLE,
-    SORTING_BY_ASCENDING_ARTIST,
-    SORTING_BY_DESCENDING_ARTIST,
-    SORTING_BY_ASCENDING_ALBUM_ARTIST,
-    SORTING_BY_DESCENDING_ALBUM_ARTIST,
-    SORTING_BY_ASCENDING_ALBUM,
-    SORTING_BY_DESCENDING_ALBUM,
-    SORTING_BY_ASCENDING_YEAR,
-    SORTING_BY_DESCENDING_YEAR,
-    SORTING_BY_ASCENDING_DISC_NUMBER,
-    SORTING_BY_DESCENDING_DISC_NUMBER,
-    SORTING_BY_ASCENDING_TRACK_NUMBER,
-    SORTING_BY_DESCENDING_TRACK_NUMBER,
-    SORTING_BY_ASCENDING_GENRE,
-    SORTING_BY_DESCENDING_GENRE,
-    SORTING_BY_ASCENDING_COMMENT,
-    SORTING_BY_DESCENDING_COMMENT,
-    SORTING_BY_ASCENDING_COMPOSER,
-    SORTING_BY_DESCENDING_COMPOSER,
-    SORTING_BY_ASCENDING_ORIG_ARTIST,
-    SORTING_BY_DESCENDING_ORIG_ARTIST,
-    SORTING_BY_ASCENDING_COPYRIGHT,
-    SORTING_BY_DESCENDING_COPYRIGHT,
-    SORTING_BY_ASCENDING_URL,
-    SORTING_BY_DESCENDING_URL,
-    SORTING_BY_ASCENDING_ENCODED_BY,
-    SORTING_BY_DESCENDING_ENCODED_BY,
-    SORTING_BY_ASCENDING_CREATION_DATE,
-    SORTING_BY_DESCENDING_CREATION_DATE,
-    SORTING_BY_ASCENDING_FILE_TYPE,
-    SORTING_BY_DESCENDING_FILE_TYPE,
-    SORTING_BY_ASCENDING_FILE_SIZE,
-    SORTING_BY_DESCENDING_FILE_SIZE,
-    SORTING_BY_ASCENDING_FILE_DURATION,
-    SORTING_BY_DESCENDING_FILE_DURATION,
-    SORTING_BY_ASCENDING_FILE_BITRATE,
-    SORTING_BY_DESCENDING_FILE_BITRATE,
-    SORTING_BY_ASCENDING_FILE_SAMPLERATE,
-    SORTING_BY_DESCENDING_FILE_SAMPLERATE,
-    SORTING_UNKNOWN
-} ET_Sorting_Type;
-
-
 /*
  * Types of files
  */
@@ -358,8 +306,8 @@ guint ET_Get_Number_Of_Files_In_Directory (const gchar *path_utf8);
 
 gboolean ET_Detect_Changes_Of_File_Tag          (File_Tag  *FileTag1,  File_Tag  *FileTag2);
 
-GList *ET_Sort_File_List                                  (GList *ETFileList, ET_Sorting_Type Sorting_Type);
-void   ET_Sort_Displayed_File_List_And_Update_UI          (ET_Sorting_Type Sorting_Type);
+GList *ET_Sort_File_List (GList *ETFileList, EtSortMode Sorting_Type);
+void ET_Sort_Displayed_File_List_And_Update_UI (EtSortMode Sorting_Type);
 gint ET_Comp_Func_Sort_File_By_Ascending_Filename         (ET_File *ETFile1, ET_File *ETFile2);
 gint ET_Comp_Func_Sort_File_By_Descending_Filename        (ET_File *ETFile1, ET_File *ETFile2);
 gint ET_Comp_Func_Sort_File_By_Ascending_Creation_Date    (ET_File *ETFile1, ET_File *ETFile2);
@@ -408,4 +356,4 @@ gint ET_Comp_Func_Sort_File_By_Descending_File_Samplerate (ET_File *ETFile1, ET_
 
 G_END_DECLS
 
-#endif /* __ET_CORE_H__ */
+#endif /* ET_CORE_H_ */
diff --git a/src/preferences_dialog.c b/src/preferences_dialog.c
index f0a59d7..9b19ac9 100644
--- a/src/preferences_dialog.c
+++ b/src/preferences_dialog.c
@@ -37,6 +37,7 @@
 #include "misc.h"
 #include "scan_dialog.h"
 #include "easytag.h"
+#include "enums.h"
 #include "browser.h"
 #include "cddb_dialog.h"
 #include "charset.h"
@@ -340,85 +341,13 @@ create_preferences_dialog (EtPreferencesDialog *self)
     /* Sorting List Options */
     Frame = gtk_frame_new (_("Sorting List Options"));
     gtk_box_pack_start(GTK_BOX(VBox),Frame,FALSE,FALSE,0);
-    vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, BOX_SPACING);
-    gtk_container_add(GTK_CONTAINER(Frame),vbox);
-    gtk_container_set_border_width (GTK_CONTAINER(vbox), BOX_SPACING);
-
-    hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
-    gtk_box_pack_start(GTK_BOX(vbox),hbox,FALSE,FALSE,0);
-    /* Sorting method */
-    Label = gtk_label_new(_("Sort the file list by:"));
-    gtk_box_pack_start(GTK_BOX(hbox),Label,FALSE,FALSE,0);
-
-    SortingFileCombo = gtk_combo_box_text_new();
-    gtk_box_pack_start (GTK_BOX (hbox), SortingFileCombo, FALSE, FALSE, 2);
-    gtk_widget_set_size_request(GTK_WIDGET(SortingFileCombo), 260, -1);
-    gtk_combo_box_set_wrap_width(GTK_COMBO_BOX(SortingFileCombo),2); // Two columns
-
-    // Items of option menu
-    gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (SortingFileCombo),
-                                    _("Ascending filename"));
-    gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (SortingFileCombo),
-                                    _("Descending filename"));
-    gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(SortingFileCombo), _("Ascending title"));
-    gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(SortingFileCombo), _("Descending title"));
-    gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(SortingFileCombo), _("Ascending artist"));
-    gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(SortingFileCombo), _("Descending artist"));
-    gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (SortingFileCombo),
-                                    _("Ascending album artist"));
-    gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (SortingFileCombo),
-                                    _("Descending album artist"));
-    gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(SortingFileCombo), _("Ascending album"));
-    gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(SortingFileCombo), _("Descending album"));
-    gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(SortingFileCombo), _("Ascending year"));
-    gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(SortingFileCombo), _("Descending year"));
-    gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (SortingFileCombo),
-                                    _("Ascending disc number"));
-    gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (SortingFileCombo),
-                                    _("Descending disc number"));
-    gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (SortingFileCombo),
-                                    _("Ascending track number"));
-    gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (SortingFileCombo),
-                                    _("Descending track number"));
-    gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(SortingFileCombo), _("Ascending genre"));
-    gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(SortingFileCombo), _("Descending genre"));
-    gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(SortingFileCombo), _("Ascending comment"));
-    gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(SortingFileCombo), _("Descending comment"));
-    gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (SortingFileCombo),
-                                    _("Ascending composer"));
-    gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (SortingFileCombo),
-                                    _("Descending composer"));
-    gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (SortingFileCombo),
-                                    _("Ascending original artist"));
-    gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (SortingFileCombo),
-                                    _("Descending original artist"));
-    gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (SortingFileCombo),
-                                    _("Ascending copyright"));
-    gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (SortingFileCombo),
-                                    _("Descending copyright"));
-    gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (SortingFileCombo),
-                                    _("Ascending URL"));
-    gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (SortingFileCombo),
-                                    _("Descending URL"));
-    gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (SortingFileCombo),
-                                    _("Ascending encoded by"));
-    gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (SortingFileCombo),
-                                    _("Descending encoded by"));
-    gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (SortingFileCombo),
-                                    _("Ascending creation date"));
-    gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (SortingFileCombo),
-                                    _("Descending creation date"));
-
-    gtk_combo_box_set_active(GTK_COMBO_BOX(SortingFileCombo), SORTING_FILE_MODE);
-    gtk_widget_set_tooltip_text(SortingFileCombo,
-                                _("Select the type of file sorting when "
-                                "loading a directory."));
 
     SortingFileCaseSensitive = gtk_check_button_new_with_label(_("Case sensitive"));
 #ifndef G_OS_WIN32
     /* Always true and not user modifiable on win32, as strncasecmp() does not
      * work correctly with g_utf8_collate_key().
      */
+    gtk_container_add (GTK_CONTAINER (Frame), SortingFileCaseSensitive);
     gtk_box_pack_start(GTK_BOX(hbox),SortingFileCaseSensitive,FALSE,FALSE,0);
 #endif /* !G_OS_WIN32 */
     gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(SortingFileCaseSensitive),
diff --git a/src/preferences_dialog.h b/src/preferences_dialog.h
index a24cb17..7ceb231 100644
--- a/src/preferences_dialog.h
+++ b/src/preferences_dialog.h
@@ -59,7 +59,6 @@ GtkWidget *DefaultPathToMp3;
 GtkWidget *BrowseHiddendir;
 
 /* Misc */
-GtkWidget *SortingFileCombo;
 GtkWidget *SortingFileCaseSensitive;
 
 GtkWidget *FilePlayerCombo;
diff --git a/src/setting.c b/src/setting.c
index d32bd0e..e1acb31 100644
--- a/src/setting.c
+++ b/src/setting.c
@@ -101,10 +101,6 @@ static const gchar CDDB_LOCAL_PATH_HISTORY_FILE[] = "cddb_local_path.history";
 
 static void Save_Config_To_File (void);
 static gboolean Create_Easytag_Directory (void);
-static void set_sorting_indicator_for_column_id (EtApplicationWindow *self,
-                                                 gint column_id,
-                                                 ET_Sorting_Type temp_sort,
-                                                 GtkTreeViewColumn *column);
 
 
 
@@ -117,7 +113,6 @@ static const tConfigVariable Config_Variables[] =
 
     {"pad_disc_number", CV_TYPE_BOOL, &PAD_DISC_NUMBER },
     {"pad_disc_number_digits", CV_TYPE_INT, &PAD_DISC_NUMBER_DIGITS },
-    {"sorting_file_mode",                    CV_TYPE_INT,     &SORTING_FILE_MODE                        },
     {"sorting_file_case_sensitive",          CV_TYPE_BOOL,    &SORTING_FILE_CASE_SENSITIVE              },
 
     {"filename_extension_lower_case",                  CV_TYPE_BOOL,    &FILENAME_EXTENSION_LOWER_CASE       
     },
@@ -230,7 +225,6 @@ void Init_Config_Variables (void)
      */
     PAD_DISC_NUMBER = 1;
     PAD_DISC_NUMBER_DIGITS = 1;
-    SORTING_FILE_MODE                       = SORTING_BY_ASCENDING_FILENAME;
 #ifdef G_OS_WIN32
     SORTING_FILE_CASE_SENSITIVE             = 1;
 #else /* !G_OS_WIN32 */
@@ -366,9 +360,6 @@ Apply_Changes_Of_Preferences_Window (void)
     GtkWidget *dialog;
     gchar *temp;
     int active;
-    ET_Sorting_Type temp_sort;
-    gint column_id;
-    GtkTreeViewColumn * column;
 
     window = ET_APPLICATION_WINDOW (MainWindow);
     dialog = et_application_window_get_preferences_dialog (window);
@@ -388,22 +379,6 @@ Apply_Changes_Of_Preferences_Window (void)
         PAD_DISC_NUMBER_DIGITS = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON 
(pad_disc_number_spinbutton));
         SORTING_FILE_CASE_SENSITIVE            = 
gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(SortingFileCaseSensitive));
 
-        temp_sort = gtk_combo_box_get_active (GTK_COMBO_BOX (SortingFileCombo));
-        column_id = temp_sort / 2;
-        if (SORTING_FILE_MODE < SORTING_BY_ASCENDING_CREATION_DATE)
-        {
-            gtk_tree_view_column_set_sort_indicator (et_application_window_browser_get_column_for_column_id 
(window, SORTING_FILE_MODE / 2),
-                                                     FALSE);
-        }
-        if (temp_sort < SORTING_BY_ASCENDING_CREATION_DATE)
-        {
-            column = et_application_window_browser_get_column_for_column_id (window, column_id);
-            set_sorting_indicator_for_column_id (window, column_id, temp_sort,
-                                                 column);
-        }
-        SORTING_FILE_MODE = temp_sort;
-        et_application_window_browser_refresh_sort (ET_APPLICATION_WINDOW (MainWindow));
-
         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)))));
 
@@ -1245,24 +1220,78 @@ Create_Easytag_Directory (void)
     }
 }
 
-static void
-set_sorting_indicator_for_column_id (EtApplicationWindow *window,
-                                     gint column_id,
-                                     ET_Sorting_Type temp_sort,
-                                     GtkTreeViewColumn *column)
+/*
+ * et_settings_enum_get:
+ * @value: the property value to be set (active item on combo box)
+ * @variant: the variant to set the @value from
+ * @user_data: the #GType of the #GSettings enum
+ *
+ * Wrapper function to convert an enum-type GSettings key into an integer
+ * value.
+ *
+ * Returns: %TRUE if the mapping was successful, %FALSE otherwise
+ */
+gboolean
+et_settings_enum_get (GValue *value, GVariant *variant, gpointer user_data)
 {
-    GtkSortType current_sort;
-    GtkSortType sort_type;
+    GType enum_type;
+    GEnumClass *enum_class;
+    GEnumValue *enum_value;
+    const gchar *nick;
 
-    gtk_tree_view_column_clicked (column);
+    g_return_val_if_fail (user_data != NULL, FALSE);
 
-    current_sort = et_application_window_browser_get_sort_order_for_column_id (window,
-                                                                               column_id);
+    enum_type = (GType)GPOINTER_TO_SIZE (user_data);
+    enum_class = g_type_class_ref (enum_type);
+    nick = g_variant_get_string (variant, NULL);
+    enum_value = g_enum_get_value_by_nick (enum_class, nick);
+    g_type_class_unref (enum_class);
 
-    sort_type = temp_sort % 2 == 0 ? GTK_SORT_ASCENDING : GTK_SORT_DESCENDING;
+    if (!enum_value)
+    {
+        g_warning ("Unable to lookup %s enum nick '%s' from GType",
+                   g_type_name (enum_type),
+                   nick);
+        return FALSE;
+    }
 
-    if (sort_type != current_sort)
+    g_value_set_int (value, enum_value->value);
+    return TRUE;
+}
+
+/*
+ * et_settings_enum_set:
+ * @value: the property value to set the @variant from
+ * @expected_type: the expected type of the returned variant
+ * @user_data: the #GType of the #GSettings enum
+ *
+ * Wrapper function to convert an integer value into a string suitable for
+ * storing into an enum-type GSettings key.
+ *
+ * Returns: a new GVariant containing the mapped value, or %NULL upon failure
+ */
+GVariant *
+et_settings_enum_set (const GValue *value, const GVariantType *expected_type,
+                      gpointer user_data)
+{
+    GType enum_type;
+    GEnumClass *enum_class;
+    GEnumValue *enum_value;
+
+    g_return_val_if_fail (user_data != NULL, NULL);
+
+    enum_type = (GType)GPOINTER_TO_SIZE (user_data);
+    enum_class = g_type_class_ref (enum_type);
+    enum_value = g_enum_get_value (enum_class, g_value_get_int (value));
+    g_type_class_unref (enum_class);
+
+    if (!enum_value)
     {
-        gtk_tree_view_column_clicked (column);
+        g_warning ("Unable to lookup %s enum value '%d' from GType",
+                   g_type_name (enum_type), g_value_get_int (value));
+        return NULL;
     }
+
+    return g_variant_new (g_variant_type_peek_string (expected_type),
+                          enum_value->value_nick);
 }
diff --git a/src/setting.h b/src/setting.h
index eeba9ea..1f7b0cb 100644
--- a/src/setting.h
+++ b/src/setting.h
@@ -1,26 +1,25 @@
-/* config.h - 2000/06/21 */
-/*
- *  EasyTAG - Tag editor for MP3 and Ogg Vorbis files
- *  Copyright (C) 2000-2003  Jerome Couderc <easytag gmail com>
+/* EasyTAG - Tag editor for audio files
+ * Copyright (C) 2014  David King <amigadave amigadave com>
+ * Copyright (C) 2000-2003  Jerome Couderc <easytag gmail com>
  *
- *  This program 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.
+ * This program 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.
  *
- *  This program 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.
+ * This program 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 Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * 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 Street, Fifth Floor, Boston, MA 02110-1301, USA.
  */
 
 
-#ifndef __CONFIG_H__
-#define __CONFIG_H__
+#ifndef ET_SETTINGS_H_
+#define ET_SETTINGS_H_
 
 #include <gtk/gtk.h>
 
@@ -45,6 +44,53 @@ struct _tConfigVariable
 };
 
 
+/* Types of sorting. See the GSettings key "sort-mode". */
+typedef enum
+{
+    ET_SORT_MODE_ASCENDING_FILENAME,
+    ET_SORT_MODE_DESCENDING_FILENAME,
+    ET_SORT_MODE_ASCENDING_TITLE,
+    ET_SORT_MODE_DESCENDING_TITLE,
+    ET_SORT_MODE_ASCENDING_ARTIST,
+    ET_SORT_MODE_DESCENDING_ARTIST,
+    ET_SORT_MODE_ASCENDING_ALBUM_ARTIST,
+    ET_SORT_MODE_DESCENDING_ALBUM_ARTIST,
+    ET_SORT_MODE_ASCENDING_ALBUM,
+    ET_SORT_MODE_DESCENDING_ALBUM,
+    ET_SORT_MODE_ASCENDING_YEAR,
+    ET_SORT_MODE_DESCENDING_YEAR,
+    ET_SORT_MODE_ASCENDING_DISC_NUMBER,
+    ET_SORT_MODE_DESCENDING_DISC_NUMBER,
+    ET_SORT_MODE_ASCENDING_TRACK_NUMBER,
+    ET_SORT_MODE_DESCENDING_TRACK_NUMBER,
+    ET_SORT_MODE_ASCENDING_GENRE,
+    ET_SORT_MODE_DESCENDING_GENRE,
+    ET_SORT_MODE_ASCENDING_COMMENT,
+    ET_SORT_MODE_DESCENDING_COMMENT,
+    ET_SORT_MODE_ASCENDING_COMPOSER,
+    ET_SORT_MODE_DESCENDING_COMPOSER,
+    ET_SORT_MODE_ASCENDING_ORIG_ARTIST,
+    ET_SORT_MODE_DESCENDING_ORIG_ARTIST,
+    ET_SORT_MODE_ASCENDING_COPYRIGHT,
+    ET_SORT_MODE_DESCENDING_COPYRIGHT,
+    ET_SORT_MODE_ASCENDING_URL,
+    ET_SORT_MODE_DESCENDING_URL,
+    ET_SORT_MODE_ASCENDING_ENCODED_BY,
+    ET_SORT_MODE_DESCENDING_ENCODED_BY,
+    ET_SORT_MODE_ASCENDING_CREATION_DATE,
+    ET_SORT_MODE_DESCENDING_CREATION_DATE,
+    ET_SORT_MODE_ASCENDING_FILE_TYPE,
+    ET_SORT_MODE_DESCENDING_FILE_TYPE,
+    ET_SORT_MODE_ASCENDING_FILE_SIZE,
+    ET_SORT_MODE_DESCENDING_FILE_SIZE,
+    ET_SORT_MODE_ASCENDING_FILE_DURATION,
+    ET_SORT_MODE_DESCENDING_FILE_DURATION,
+    ET_SORT_MODE_ASCENDING_FILE_BITRATE,
+    ET_SORT_MODE_DESCENDING_FILE_BITRATE,
+    ET_SORT_MODE_ASCENDING_FILE_SAMPLERATE,
+    ET_SORT_MODE_DESCENDING_FILE_SAMPLERATE
+} EtSortMode;
+
 /*
  * Config variables
  */
@@ -55,7 +101,6 @@ GSettings *MainSettings;
 gchar  *DEFAULT_PATH_TO_MP3;
 
 /* Misc */
-gint    SORTING_FILE_MODE;
 gint    SORTING_FILE_CASE_SENSITIVE;
 
 gchar  *AUDIO_FILE_PLAYER;
@@ -231,6 +276,10 @@ void Save_Cddb_Search_String_In_Result_List (GtkListStore *liststore, gint colnu
 void Load_Cddb_Local_Path_List (GtkListStore *liststore, gint colnum);
 void Save_Cddb_Local_Path_List (GtkListStore *liststore, gint colnum);
 
+gboolean et_settings_enum_get (GValue *value, GVariant *variant,
+                               gpointer user_data);
+GVariant *et_settings_enum_set (const GValue *value,
+                                const GVariantType *expected_type,
+                                gpointer user_data);
 
-
-#endif /* __CONFIG_H__ */
+#endif /* ET_SETTINGS_H_ */


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