[easytag/wip/application-window: 24/70] Store case sensitive sorting mode in GSettings



commit 325ca07444a589e4c83dbb8d71a13cf5e859425b
Author: David King <amigadave amigadave com>
Date:   Sat May 10 20:49:46 2014 +0100

    Store case sensitive sorting mode in GSettings

 src/cddb_dialog.c        |    4 +++-
 src/et_core.c            |   34 ++++++++++++++++++----------------
 src/preferences_dialog.c |   16 +++++-----------
 src/preferences_dialog.h |    6 ------
 src/setting.c            |    9 ---------
 src/setting.h            |    2 --
 6 files changed, 26 insertions(+), 45 deletions(-)
---
diff --git a/src/cddb_dialog.c b/src/cddb_dialog.c
index 1187bd4..8bffeef 100644
--- a/src/cddb_dialog.c
+++ b/src/cddb_dialog.c
@@ -3745,7 +3745,9 @@ Cddb_Track_List_Sort_Func (GtkTreeModel *model, GtkTreeIter *a, GtkTreeIter *b,
             text2cp = g_utf8_collate_key_for_filename(text2, -1);
             // Must be the same rules as "ET_Comp_Func_Sort_File_By_Ascending_Filename" to be
             // able to sort in the same order files in cddb and in the file list.
-            ret = SORTING_FILE_CASE_SENSITIVE ? strcmp(text1cp,text2cp) : strcasecmp(text1cp,text2cp);
+            ret = g_settings_get_boolean (MainSettings,
+                                          "sort-case-sensitive") ? strcmp (text1cp, text2cp)
+                                                                 : strcasecmp (text1cp, text2cp);
 
             g_free(text1);
             g_free(text2);
diff --git a/src/et_core.c b/src/et_core.c
index dd2fe4e..41a07f4 100644
--- a/src/et_core.c
+++ b/src/et_core.c
@@ -1194,7 +1194,9 @@ gint ET_Comp_Func_Sort_File_By_Ascending_Filename (ET_File *ETFile1, ET_File *ET
     gchar *file2_ck   = ((File_Name *)((GList *)ETFile2->FileNameCur)->data)->value_ck;
     // !!!! : Must be the same rules as "Cddb_Track_List_Sort_Func" to be
     // able to sort in the same order files in cddb and in the file list.
-    return SORTING_FILE_CASE_SENSITIVE ? strcmp(file1_ck,file2_ck) : strcasecmp(file1_ck,file2_ck);
+    return g_settings_get_boolean (MainSettings,
+                                   "sort-case-sensitive") ? strcmp (file1_ck, file2_ck)
+                                                          : strcasecmp (file1_ck, file2_ck);
 }
 
 /*
@@ -1361,7 +1363,7 @@ gint ET_Comp_Func_Sort_File_By_Ascending_Title (ET_File *ETFile1, ET_File *ETFil
     if ( !ETFile2->FileTag->data || !((File_Tag *)ETFile2->FileTag->data)->title )
         return 1;
 
-    if (SORTING_FILE_CASE_SENSITIVE)
+    if (g_settings_get_boolean (MainSettings, "sort-case-sensitive"))
     {
         if ( strcmp(((File_Tag *)ETFile1->FileTag->data)->title,((File_Tag *)ETFile2->FileTag->data)->title) 
== 0 )
             // Second criterion
@@ -1404,7 +1406,7 @@ gint ET_Comp_Func_Sort_File_By_Ascending_Artist (ET_File *ETFile1, ET_File *ETFi
     if ( !ETFile2->FileTag->data || !((File_Tag *)ETFile2->FileTag->data)->artist )
         return 1;
 
-    if (SORTING_FILE_CASE_SENSITIVE)
+    if (g_settings_get_boolean (MainSettings, "sort-case-sensitive"))
     {
         if ( strcmp(((File_Tag *)ETFile1->FileTag->data)->artist,((File_Tag 
*)ETFile2->FileTag->data)->artist) == 0 )
             // Second criterion
@@ -1446,7 +1448,7 @@ gint ET_Comp_Func_Sort_File_By_Ascending_Album_Artist (ET_File *ETFile1, ET_File
     if ( !ETFile2->FileTag->data || !((File_Tag *)ETFile2->FileTag->data)->album_artist )
         return 1;
 
-    if (SORTING_FILE_CASE_SENSITIVE)
+    if (g_settings_get_boolean (MainSettings, "sort-case-sensitive"))
     {
         if ( strcmp(((File_Tag *)ETFile1->FileTag->data)->album_artist,((File_Tag 
*)ETFile2->FileTag->data)->album_artist) == 0 )
             // Second criterion
@@ -1488,7 +1490,7 @@ gint ET_Comp_Func_Sort_File_By_Ascending_Album (ET_File *ETFile1, ET_File *ETFil
     if ( !ETFile2->FileTag->data || !((File_Tag *)ETFile2->FileTag->data)->album )
         return 1;
 
-    if (SORTING_FILE_CASE_SENSITIVE)
+    if (g_settings_get_boolean (MainSettings, "sort-case-sensitive"))
     {
         if ( strcmp(((File_Tag *)ETFile1->FileTag->data)->album,((File_Tag *)ETFile2->FileTag->data)->album) 
== 0 )
             // Second criterion
@@ -1563,7 +1565,7 @@ gint ET_Comp_Func_Sort_File_By_Ascending_Genre (ET_File *ETFile1, ET_File *ETFil
     if ( !ETFile1->FileTag->data || !((File_Tag *)ETFile1->FileTag->data)->genre ) return -1;
     if ( !ETFile2->FileTag->data || !((File_Tag *)ETFile2->FileTag->data)->genre ) return 1;
 
-    if (SORTING_FILE_CASE_SENSITIVE)
+    if (g_settings_get_boolean (MainSettings, "sort-case-sensitive"))
     {
         if ( strcmp(((File_Tag *)ETFile1->FileTag->data)->genre,((File_Tag *)ETFile2->FileTag->data)->genre) 
== 0 )
             // Second criterion
@@ -1606,7 +1608,7 @@ gint ET_Comp_Func_Sort_File_By_Ascending_Comment (ET_File *ETFile1, ET_File *ETF
     if ( !ETFile2->FileTag->data || !((File_Tag *)ETFile2->FileTag->data)->comment )
         return 1;
 
-    if (SORTING_FILE_CASE_SENSITIVE)
+    if (g_settings_get_boolean (MainSettings, "sort-case-sensitive"))
     {
         if ( strcmp(((File_Tag *)ETFile1->FileTag->data)->comment,((File_Tag 
*)ETFile2->FileTag->data)->comment) == 0 )
             // Second criterion
@@ -1649,7 +1651,7 @@ gint ET_Comp_Func_Sort_File_By_Ascending_Composer (ET_File *ETFile1, ET_File *ET
     if ( !ETFile2->FileTag->data || !((File_Tag *)ETFile2->FileTag->data)->composer )
         return 1;
 
-    if (SORTING_FILE_CASE_SENSITIVE)
+    if (g_settings_get_boolean (MainSettings, "sort-case-sensitive"))
     {
         if ( strcmp(((File_Tag *)ETFile1->FileTag->data)->composer,((File_Tag 
*)ETFile2->FileTag->data)->composer) == 0 )
             // Second criterion
@@ -1692,7 +1694,7 @@ gint ET_Comp_Func_Sort_File_By_Ascending_Orig_Artist (ET_File *ETFile1, ET_File
     if ( !ETFile2->FileTag->data || !((File_Tag *)ETFile2->FileTag->data)->orig_artist )
         return 1;
 
-    if (SORTING_FILE_CASE_SENSITIVE)
+    if (g_settings_get_boolean (MainSettings, "sort-case-sensitive"))
     {
         if ( strcmp(((File_Tag *)ETFile1->FileTag->data)->orig_artist,((File_Tag 
*)ETFile2->FileTag->data)->orig_artist) == 0 )
             // Second criterion
@@ -1735,7 +1737,7 @@ gint ET_Comp_Func_Sort_File_By_Ascending_Copyright (ET_File *ETFile1, ET_File *E
     if ( !ETFile2->FileTag->data || !((File_Tag *)ETFile2->FileTag->data)->copyright )
         return 1;
 
-    if (SORTING_FILE_CASE_SENSITIVE)
+    if (g_settings_get_boolean (MainSettings, "sort-case-sensitive"))
     {
         if ( strcmp(((File_Tag *)ETFile1->FileTag->data)->copyright,((File_Tag 
*)ETFile2->FileTag->data)->copyright) == 0 )
             // Second criterion
@@ -1778,7 +1780,7 @@ gint ET_Comp_Func_Sort_File_By_Ascending_Url (ET_File *ETFile1, ET_File *ETFile2
     if ( !ETFile2->FileTag->data || !((File_Tag *)ETFile2->FileTag->data)->url )
         return 1;
 
-    if (SORTING_FILE_CASE_SENSITIVE)
+    if (g_settings_get_boolean (MainSettings, "sort-case-sensitive"))
     {
         if ( strcmp(((File_Tag *)ETFile1->FileTag->data)->url,((File_Tag *)ETFile2->FileTag->data)->url) == 
0 )
             // Second criterion
@@ -1821,7 +1823,7 @@ gint ET_Comp_Func_Sort_File_By_Ascending_Encoded_By (ET_File *ETFile1, ET_File *
     if ( !ETFile2->FileTag->data || !((File_Tag *)ETFile2->FileTag->data)->encoded_by )
         return 1;
 
-    if (SORTING_FILE_CASE_SENSITIVE)
+    if (g_settings_get_boolean (MainSettings, "sort-case-sensitive"))
     {
         if ( strcmp(((File_Tag *)ETFile1->FileTag->data)->encoded_by,((File_Tag 
*)ETFile2->FileTag->data)->encoded_by) == 0 )
             // Second criterion
@@ -1996,8 +1998,8 @@ static gint ET_Comp_Func_Sort_Artist_Item_By_Ascending_Artist (GList *AlbumList1
     || !(etfile2_artist = ((File_Tag *)etfile2->FileTag->data)->artist) )
         return 1;
 
-    //if (SORTING_FILE_CASE_SENSITIVE)
-    //    return strcmp(etfile1_artist,etfile2_artist);
+    /*if (g_settings_get_boolean (MainSettings, "sort-case-sensitive"))
+     *    return strcmp(etfile1_artist,etfile2_artist); */
     //else
         return strcasecmp(etfile1_artist,etfile2_artist);
 }
@@ -2022,8 +2024,8 @@ ET_Comp_Func_Sort_Album_Item_By_Ascending_Album (GList *etfilelist1,
     || !(etfile2_album  = ((File_Tag *)etfile2->FileTag->data)->album) )
         return 1;
 
-    //if (SORTING_FILE_CASE_SENSITIVE)
-    //    return strcmp(etfile1_album,etfile2_album);
+    /*if (g_settings_get_boolean (MainSettings, "sort-case-sensitive"))
+     *    return strcmp(etfile1_album,etfile2_album); */
     //else
         return strcasecmp(etfile1_album,etfile2_album);
 }
diff --git a/src/preferences_dialog.c b/src/preferences_dialog.c
index 25c6c73..eb140b5 100644
--- a/src/preferences_dialog.c
+++ b/src/preferences_dialog.c
@@ -179,9 +179,11 @@ create_preferences_dialog (EtPreferencesDialog *self)
     GtkWidget *LoadOnStartup;
     GtkWidget *BrowseSubdir;
     GtkWidget *OpenSelectedBrowserNode;
+    GtkWidget *BrowseHiddendir;
     GtkWidget *ShowHeaderInfos;
     GtkWidget *ChangedFilesDisplayedToRed;
     GtkWidget *ChangedFilesDisplayedToBold;
+    GtkWidget *SortingFileCaseSensitive;
     GtkWidget *ShowLogView;
     GtkWidget *LogMaxLinesSpinButton;
     GtkWidget *ReplaceIllegalCharactersInFilename;
@@ -340,9 +342,6 @@ create_preferences_dialog (EtPreferencesDialog *self)
 
     /* Browse hidden directories */
     BrowseHiddendir = gtk_check_button_new_with_label(_("Search hidden directories"));
-#ifndef G_OS_WIN32 /* Always true and not user modifiable on win32 */
-    gtk_box_pack_start(GTK_BOX(vbox),BrowseHiddendir,FALSE,FALSE,0);
-#endif /* !G_OS_WIN32 */
     g_settings_bind (MainSettings, "browse-show-hidden", BrowseHiddendir,
                      "active", G_SETTINGS_BIND_DEFAULT);
     gtk_widget_set_tooltip_text(BrowseHiddendir,_("Search hidden directories for files "
@@ -398,15 +397,10 @@ create_preferences_dialog (EtPreferencesDialog *self)
     gtk_box_pack_start(GTK_BOX(VBox),Frame,FALSE,FALSE,0);
 
     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),
-        SORTING_FILE_CASE_SENSITIVE);
+    g_settings_bind (MainSettings, "sort-case-sensitive",
+                     SortingFileCaseSensitive, "active",
+                     G_SETTINGS_BIND_DEFAULT);
     gtk_widget_set_tooltip_text(SortingFileCaseSensitive,_("If activated, the "
         "sorting of the list will be dependent on the case."));
 
diff --git a/src/preferences_dialog.h b/src/preferences_dialog.h
index 12c4d6b..6ae3836 100644
--- a/src/preferences_dialog.h
+++ b/src/preferences_dialog.h
@@ -53,13 +53,7 @@ void et_preferences_dialog_show_scanner (EtPreferencesDialog *self);
 G_END_DECLS
 
 /* FIXME: Remove widget declarations when switching to GSettings. */
-/* Widgets included in config */
-/* Common */
-GtkWidget *BrowseHiddendir;
-
 /* Misc */
-GtkWidget *SortingFileCaseSensitive;
-
 GtkWidget *FilePlayerCombo;
 
 /* Tag Settings */
diff --git a/src/setting.c b/src/setting.c
index 337bd27..907a67c 100644
--- a/src/setting.c
+++ b/src/setting.c
@@ -107,7 +107,6 @@ static gboolean Create_Easytag_Directory (void);
  ********************/
 static const tConfigVariable Config_Variables[] =
 {
-    {"sorting_file_case_sensitive",          CV_TYPE_BOOL,    &SORTING_FILE_CASE_SENSITIVE              },
 
     {"file_reading_id3v1v2_character_set",             CV_TYPE_STRING,&FILE_READING_ID3V1V2_CHARACTER_SET},
     {"file_writing_id3v2_unicode_character_set",       
CV_TYPE_STRING,&FILE_WRITING_ID3V2_UNICODE_CHARACTER_SET},
@@ -198,12 +197,6 @@ void Init_Config_Variables (void)
      * Misc
      */
 #ifdef G_OS_WIN32
-    SORTING_FILE_CASE_SENSITIVE             = 1;
-#else /* !G_OS_WIN32 */
-    SORTING_FILE_CASE_SENSITIVE             = 0;
-#endif /* !G_OS_WIN32 */
-
-#ifdef G_OS_WIN32
     AUDIO_FILE_PLAYER                       = ET_Win32_Get_Audio_File_Player();
 #else /* !G_OS_WIN32 */
     AUDIO_FILE_PLAYER                       = g_strdup("xdg-open");
@@ -293,8 +286,6 @@ Apply_Changes_Of_Preferences_Window (void)
     if (dialog)
     {
         /* Misc */
-        SORTING_FILE_CASE_SENSITIVE            = 
gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(SortingFileCaseSensitive));
-
         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)))));
 
diff --git a/src/setting.h b/src/setting.h
index a85fac0..1fe9c43 100644
--- a/src/setting.h
+++ b/src/setting.h
@@ -164,8 +164,6 @@ typedef enum
 GSettings *MainSettings;
 
 /* Misc */
-gint    SORTING_FILE_CASE_SENSITIVE;
-
 gchar  *AUDIO_FILE_PLAYER;
 
 /* Tag Settings */


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