[vlc-commits] Change --directory-version-sort boolean config option to a --directory-sort multiple choice option . This makes more sense and makes it possible to provide more sort options if needed without breaking backwards compatibility . The description strings are a bit long but they more or less fit in the prefs dialog here .

Antoine Cellerier git at videolan.org
Sat Feb 11 21:02:08 CET 2012


vlc | branch: master | Antoine Cellerier <dionoea at videolan.org> | Sat Feb 11 20:57:58 2012 +0100| [936199ff7f3ddf52a0650177ec00625aa093cee5] | committer: Antoine Cellerier

Change --directory-version-sort boolean config option to a --directory-sort multiple choice option. This makes more sense and makes it possible to provide more sort options if needed without breaking backwards compatibility. The description strings are a bit long but they more or less fit in the prefs dialog here.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=936199ff7f3ddf52a0650177ec00625aa093cee5
---

 modules/access/directory.c |    8 +++++++-
 modules/access/fs.c        |   19 +++++++++++--------
 2 files changed, 18 insertions(+), 9 deletions(-)

diff --git a/modules/access/directory.c b/modules/access/directory.c
index 9bffe05..4f9d44b 100644
--- a/modules/access/directory.c
+++ b/modules/access/directory.c
@@ -144,10 +144,16 @@ int DirInit (access_t *p_access, DIR *handle)
         goto error;
     }
 
-    if (var_InheritBool (p_access, "directory-version-sort"))
+    char *psz_sort = var_InheritString (p_access, "directory-sort");
+    if (!psz_sort)
+        p_sys->compar = collate;
+    else if (!strcasecmp (psz_sort, "version"))
         p_sys->compar = version;
+    else if (!strcasecmp (psz_sort, "none"))
+        p_sys->compar = NULL;
     else
         p_sys->compar = collate;
+    free(psz_sort);
 
     root->parent = NULL;
     root->handle = handle;
diff --git a/modules/access/fs.c b/modules/access/fs.c
index 9913b22..dad02a4 100644
--- a/modules/access/fs.c
+++ b/modules/access/fs.c
@@ -48,12 +48,15 @@ static const char *const psz_recursive_list_text[] = {
         "This is useful if you add directories that contain playlist files " \
         "for instance. Use a comma-separated list of extensions." )
 
-#define VERSION_SORT_TEXT N_("Use version sort")
-#define VERSION_SORT_LONGTEXT N_( \
-        "When opening a directory, add items in a natural order. " \
-        "For example, track-1.ogg track-2.ogg track-10.ogg will be sorted " \
-        "as expected while the default method would sort them as " \
-        "track-1.ogg track-10.ogg track-2.ogg." )
+static const char *const psz_sort_list[] = { "collate", "version", "none" };
+static const char *const psz_sort_list_text[] = {
+    N_("Sort alphabetically according to the current language's collation rules."),
+    N_("Sort items in a natural order (for example: 1.ogg 2.ogg 10.ogg). This method does not take the current language's collation rules into account."),
+    N_("Do not sort the items.") };
+
+#define SORT_TEXT N_("Directory sort order")
+#define SORT_LONGTEXT N_( \
+    "Define the sort algorithm used when adding items from a directory." )
 
 vlc_module_begin ()
     set_description( N_("File input") )
@@ -73,8 +76,8 @@ vlc_module_begin ()
       change_string_list( psz_recursive_list, psz_recursive_list_text, 0 )
     add_string( "ignore-filetypes", "m3u,db,nfo,ini,jpg,jpeg,ljpg,gif,png,pgm,pgmyuv,pbm,pam,tga,bmp,pnm,xpm,xcf,pcx,tif,tiff,lbm,sfv,txt,sub,idx,srt,cue,ssa",
                 IGNORE_TEXT, IGNORE_LONGTEXT, false )
-    add_bool( "directory-version-sort", false,
-              VERSION_SORT_TEXT, VERSION_SORT_LONGTEXT, false );
+    add_string( "directory-sort", "collate", SORT_TEXT, SORT_LONGTEXT, false )
+      change_string_list( psz_sort_list, psz_sort_list_text, 0 )
 #ifndef HAVE_FDOPENDIR
     add_shortcut( "file", "directory", "dir" )
 #else



More information about the vlc-commits mailing list