[easytag] Make the sort options more complete



commit ccc920e4ac572211e44919173518902009305cff
Author: DarshanMn <darshan trin gmail com>
Date:   Mon Apr 8 23:23:59 2013 +0530

    Make the sort options more complete
    
    Some of the code has been reordered to match the order in the enum of
    sort modes. Also, the sorting function for the 'Disc Number' tag has
    been added. Partially fixes bug 697570.

 src/browser.c |   33 ++++++++++++++--------
 src/et_core.c |   86 +++++++++++++++++++++++++++++++++++++++++++++++++--------
 src/et_core.h |   14 ++++++--
 src/prefs.c   |   40 ++++++++++++++++++++++++--
 4 files changed, 141 insertions(+), 32 deletions(-)
---
diff --git a/src/browser.c b/src/browser.c
index 8718ae7..127ce70 100644
--- a/src/browser.c
+++ b/src/browser.c
@@ -1750,18 +1750,6 @@ Browser_List_Sort_Func (GtkTreeModel *model, GtkTreeIter *a, GtkTreeIter *b,
         case SORTING_BY_DESCENDING_FILENAME:
             result = ET_Comp_Func_Sort_File_By_Descending_Filename(ETFile1, ETFile2);
             break;
-        case SORTING_BY_ASCENDING_TRACK_NUMBER:
-            result = ET_Comp_Func_Sort_File_By_Ascending_Track_Number(ETFile1, ETFile2);
-            break;
-        case SORTING_BY_DESCENDING_TRACK_NUMBER:
-            result = ET_Comp_Func_Sort_File_By_Descending_Track_Number(ETFile1, ETFile2);
-            break;
-        case SORTING_BY_ASCENDING_CREATION_DATE:
-            result = ET_Comp_Func_Sort_File_By_Ascending_Creation_Date(ETFile1, ETFile2);
-            break;
-        case SORTING_BY_DESCENDING_CREATION_DATE:
-            result = ET_Comp_Func_Sort_File_By_Descending_Creation_Date(ETFile1, ETFile2);
-            break;
         case SORTING_BY_ASCENDING_TITLE:
             result = ET_Comp_Func_Sort_File_By_Ascending_Title(ETFile1, ETFile2);
             break;
@@ -1792,6 +1780,20 @@ Browser_List_Sort_Func (GtkTreeModel *model, GtkTreeIter *a, GtkTreeIter *b,
         case SORTING_BY_DESCENDING_YEAR:
             result = ET_Comp_Func_Sort_File_By_Descending_Year(ETFile1, ETFile2);
             break;
+        case SORTING_BY_ASCENDING_DISC_NUMBER:
+            result = et_comp_func_sort_file_by_ascending_disc_number (ETFile1,
+                                                                      ETFile2);
+            break;
+        case SORTING_BY_DESCENDING_DISC_NUMBER:
+            result = et_comp_func_sort_file_by_descending_disc_number (ETFile1,
+                                                                       ETFile2);
+            break;
+        case SORTING_BY_ASCENDING_TRACK_NUMBER:
+            result = ET_Comp_Func_Sort_File_By_Ascending_Track_Number (ETFile1, ETFile2);
+            break;
+        case SORTING_BY_DESCENDING_TRACK_NUMBER:
+            result = ET_Comp_Func_Sort_File_By_Descending_Track_Number (ETFile1, ETFile2);
+            break;
         case SORTING_BY_ASCENDING_GENRE:
             result = ET_Comp_Func_Sort_File_By_Ascending_Genre(ETFile1, ETFile2);
             break;
@@ -1834,6 +1836,13 @@ Browser_List_Sort_Func (GtkTreeModel *model, GtkTreeIter *a, GtkTreeIter *b,
         case SORTING_BY_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);
+            break;
+        case SORTING_BY_DESCENDING_CREATION_DATE:
+            result = ET_Comp_Func_Sort_File_By_Descending_Creation_Date (ETFile1,
+                                                                         ETFile2);
+            break;
         case SORTING_BY_ASCENDING_FILE_TYPE:
             result = ET_Comp_Func_Sort_File_By_Ascending_File_Type(ETFile1, ETFile2);
             break;
diff --git a/src/et_core.c b/src/et_core.c
index adc626f..0333a24 100644
--- a/src/et_core.c
+++ b/src/et_core.c
@@ -912,18 +912,6 @@ GList *ET_Sort_File_List (GList *ETFileList, ET_Sorting_Type Sorting_Type)
         case SORTING_BY_DESCENDING_FILENAME:
             etfilelist = g_list_sort(etfilelist,(GCompareFunc)ET_Comp_Func_Sort_File_By_Descending_Filename);
             break;
-        case SORTING_BY_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:
-            etfilelist = 
g_list_sort(etfilelist,(GCompareFunc)ET_Comp_Func_Sort_File_By_Descending_Track_Number);
-            break;
-        case SORTING_BY_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:
-            etfilelist = 
g_list_sort(etfilelist,(GCompareFunc)ET_Comp_Func_Sort_File_By_Descending_Creation_Date);
-            break;
         case SORTING_BY_ASCENDING_TITLE:
             etfilelist = g_list_sort(etfilelist,(GCompareFunc)ET_Comp_Func_Sort_File_By_Ascending_Title);
             break;
@@ -954,6 +942,22 @@ GList *ET_Sort_File_List (GList *ETFileList, ET_Sorting_Type Sorting_Type)
         case SORTING_BY_DESCENDING_YEAR:
             etfilelist = g_list_sort(etfilelist,(GCompareFunc)ET_Comp_Func_Sort_File_By_Descending_Year);
             break;
+        case SORTING_BY_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:
+            etfilelist = g_list_sort (etfilelist,
+                                      (GCompareFunc)et_comp_func_sort_file_by_descending_disc_number);
+            break;
+        case SORTING_BY_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:
+            etfilelist = g_list_sort (etfilelist,
+                                      (GCompareFunc)ET_Comp_Func_Sort_File_By_Descending_Track_Number);
+            break;
         case SORTING_BY_ASCENDING_GENRE:
             etfilelist = g_list_sort(etfilelist,(GCompareFunc)ET_Comp_Func_Sort_File_By_Ascending_Genre);
             break;
@@ -996,6 +1000,14 @@ GList *ET_Sort_File_List (GList *ETFileList, ET_Sorting_Type Sorting_Type)
         case SORTING_BY_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:
+            etfilelist = g_list_sort (etfilelist,
+                                      (GCompareFunc)ET_Comp_Func_Sort_File_By_Ascending_Creation_Date);
+            break;
+        case SORTING_BY_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:
             etfilelist = g_list_sort(etfilelist,(GCompareFunc)ET_Comp_Func_Sort_File_By_Ascending_File_Type);
             break;
@@ -1079,6 +1091,56 @@ gint ET_Comp_Func_Sort_File_By_Descending_Filename (ET_File *ETFile1, ET_File *E
 
 
 /*
+ * Comparison function for sorting by ascending disc number.
+ */
+gint
+et_comp_func_sort_file_by_ascending_disc_number (ET_File *ETFile1,
+                                                 ET_File *ETFile2)
+{
+    gint track1, track2;
+
+    if (!ETFile1->FileTag->data
+        || !((File_Tag *)ETFile1->FileTag->data)->disc_number)
+    {
+        track1 = 0;
+    }
+    else
+    {
+        track1 = atoi (((File_Tag *)ETFile1->FileTag->data)->disc_number);
+    }
+
+    if (!ETFile2->FileTag->data
+        || !((File_Tag *)ETFile2->FileTag->data)->disc_number)
+    {
+        track2 = 0;
+    }
+    else
+    {
+        track2 = atoi (((File_Tag *)ETFile2->FileTag->data)->disc_number);
+    }
+
+    /* Second criterion. */
+    if (track1 == track2)
+    {
+        return ET_Comp_Func_Sort_File_By_Ascending_Filename (ETFile1, ETFile2);
+    }
+
+    /* First criterion. */
+    return (track1 - track2);
+}
+
+/*
+ * Comparison function for sorting by descending disc number.
+ */
+gint
+et_comp_func_sort_file_by_descending_disc_number (ET_File *ETFile1,
+                                                  ET_File *ETFile2)
+{
+    return et_comp_func_sort_file_by_ascending_disc_number (ETFile2, ETFile1);
+}
+
+
+/*
  * Comparison function for sorting by ascending track number.
  */
 gint ET_Comp_Func_Sort_File_By_Ascending_Track_Number (ET_File *ETFile1, ET_File *ETFile2)
diff --git a/src/et_core.h b/src/et_core.h
index 524cd4a..5ab3d27 100644
--- a/src/et_core.h
+++ b/src/et_core.h
@@ -51,10 +51,6 @@ typedef enum
 {
     SORTING_BY_ASCENDING_FILENAME,
     SORTING_BY_DESCENDING_FILENAME,
-    SORTING_BY_ASCENDING_TRACK_NUMBER,
-    SORTING_BY_DESCENDING_TRACK_NUMBER,
-    SORTING_BY_ASCENDING_CREATION_DATE,
-    SORTING_BY_DESCENDING_CREATION_DATE,
     SORTING_BY_ASCENDING_TITLE,
     SORTING_BY_DESCENDING_TITLE,
     SORTING_BY_ASCENDING_ARTIST,
@@ -65,6 +61,10 @@ typedef enum
     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,
@@ -79,6 +79,8 @@ typedef enum
     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,
@@ -401,6 +403,10 @@ gint ET_Comp_Func_Sort_File_By_Ascending_Filename         (ET_File *ETFile1, ET_
 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);
 gint ET_Comp_Func_Sort_File_By_Descending_Creation_Date   (ET_File *ETFile1, ET_File *ETFile2);
+gint et_comp_func_sort_file_by_ascending_disc_number (ET_File *ETFile1,
+                                                      ET_File *ETFile2);
+gint et_comp_func_sort_file_by_descending_disc_number (ET_File *ETFile1,
+                                                       ET_File *ETFile2);
 gint ET_Comp_Func_Sort_File_By_Ascending_Track_Number     (ET_File *ETFile1, ET_File *ETFile2);
 gint ET_Comp_Func_Sort_File_By_Descending_Track_Number    (ET_File *ETFile1, ET_File *ETFile2);
 gint ET_Comp_Func_Sort_File_By_Ascending_Title            (ET_File *ETFile1, ET_File *ETFile2);
diff --git a/src/prefs.c b/src/prefs.c
index 9253fe9..48ee531 100644
--- a/src/prefs.c
+++ b/src/prefs.c
@@ -292,22 +292,54 @@ void Open_OptionsWindow (void)
     // Items of option menu
     gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(SortingFileCombo), _("Ascending file name"));
     gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(SortingFileCombo), _("Descending file name"));
-    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 creation date"));
-    gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(SortingFileCombo), _("Descending creation date"));
     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,


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