[nautilus/636-default-sort-order-settings-not-respected-in-3-30-no-docs-no-ui-regression-since-3-26: 1/4] file: Sync sort types with settings



commit deac2178b9177cd2ef3156cc7d21442e4870d291
Author: António Fernandes <antoniof gnome org>
Date:   Mon Nov 26 17:49:10 2018 +0000

    file: Sync sort types with settings
    
    The org.gnome.nautilus.preferences default-sort-order key is a currently
    hidden-from-UI preference that should be honored by all views, if no
    custom order is specified in the current location's metadata.
    
    However, for this to work, two enums must be kept in sync between the
    code and the schemas. This has not been happening since the introduction
    of the Starred files feature.
    
    To fix this, restore the sort order according to settings, and make
    starred take the place of trash-time, which is non-sensical as default
    for all folders.
    
    Forthermore, to prevent this from breaking again, add documentation to
    both enums.
    
    Fixes https://gitlab.gnome.org/GNOME/nautilus/issues/636

 data/org.gnome.nautilus.gschema.xml |  6 +++++-
 src/nautilus-file.h                 | 22 +++++++++++++++-------
 2 files changed, 20 insertions(+), 8 deletions(-)
---
diff --git a/data/org.gnome.nautilus.gschema.xml b/data/org.gnome.nautilus.gschema.xml
index 4b393f83f..f33f014af 100644
--- a/data/org.gnome.nautilus.gschema.xml
+++ b/data/org.gnome.nautilus.gschema.xml
@@ -23,13 +23,17 @@
   </enum>
 
   <enum id="org.gnome.nautilus.SortOrder">
+    <!--
+      When touching this, make sure to keep the values in sync with the
+      #NautilusFileSortType enum in the `src/nautilus-file.h` code header file.
+    -->
     <value value="0" nick="manually"/>
     <value value="1" nick="name"/>
     <value value="2" nick="size"/>
     <value value="3" nick="type"/>
     <value value="4" nick="mtime"/>
     <value value="5" nick="atime"/>
-    <value value="6" nick="trash-time"/>
+    <value value="6" nick="starred"/>
   </enum>
 
   <enum id="org.gnome.nautilus.CanvasZoomLevel">
diff --git a/src/nautilus-file.h b/src/nautilus-file.h
index 8fce62505..ce5f57846 100644
--- a/src/nautilus-file.h
+++ b/src/nautilus-file.h
@@ -50,13 +50,21 @@ typedef struct NautilusFile NautilusFile;
   (G_TYPE_INSTANCE_GET_CLASS ((obj), NAUTILUS_TYPE_FILE, NautilusFileClass))
 
 typedef enum {
-       NAUTILUS_FILE_SORT_NONE,
-       NAUTILUS_FILE_SORT_BY_DISPLAY_NAME,
-       NAUTILUS_FILE_SORT_BY_SIZE,
-       NAUTILUS_FILE_SORT_BY_TYPE,
-       NAUTILUS_FILE_SORT_BY_STARRED,
-       NAUTILUS_FILE_SORT_BY_MTIME,
-        NAUTILUS_FILE_SORT_BY_ATIME,
+       /* These may be set as default-sort-order. When touching this, make sure to
+        * keep the values in sync with the "org.gnome.nautilus.SortOrder" enum in the
+        * `data/org.gnome.nautilus.gschema.xml` schemas file.
+        */
+       NAUTILUS_FILE_SORT_NONE = 0, /* Formerly used for "manual" sorting. */
+       NAUTILUS_FILE_SORT_BY_DISPLAY_NAME = 1,
+       NAUTILUS_FILE_SORT_BY_SIZE = 2,
+       NAUTILUS_FILE_SORT_BY_TYPE = 3,
+       NAUTILUS_FILE_SORT_BY_MTIME = 4,
+       NAUTILUS_FILE_SORT_BY_ATIME = 5,
+       NAUTILUS_FILE_SORT_BY_STARRED = 6,
+
+       /* The following are specific to special locations and as such are not to be
+        * included in the "org.gnome.nautilus.SortOrder" enum.
+        */
        NAUTILUS_FILE_SORT_BY_TRASHED_TIME,
        NAUTILUS_FILE_SORT_BY_SEARCH_RELEVANCE,
        NAUTILUS_FILE_SORT_BY_RECENCY


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