#64 Default Sorting Descending (in addition to Ascending)

open
nobody
None
5
2 days ago
2014-07-31
No

As a user, I would like to set the default sorting in descending order.

This appears to be impossible both in the user interface and in ~/.configure/rox.sourceforge.net/ROX-Filer/Options.

User interface-wise this can be solved by adding four new items to display_sort_by to ROX-Filer/Options.xml (roxAlt1.png) a new checkmark that controls whether sorting is ascending or descending, for example after xattr_show (roxAlt2.png)

I prefer extending display_sort_by, as this would not add more strings to translate (not sure if there is i18n available or planned).

Programming wise, it looks like changing some stuff inside the else block around ROX-Filer/src/filer.c line 1532 could do it. For example the following code changes (public domain/cc0, feel free to add without attribution under your own copyright):

$ git diff
diff --git a/ROX-Filer/Options.xml b/ROX-Filer/Options.xml
index efa3db6..3d74250 100644
--- a/ROX-Filer/Options.xml
+++ b/ROX-Filer/Options.xml
@@ -40,6 +40,10 @@
               <item label='Type' value='1'/>
               <item label='Date' value='2'/>
               <item label='Size' value='3'/>
+              <item label='Name Desc' value='4'/>
+              <item label='Type Desc' value='5'/>
+              <item label='Date Desc' value='6'/>
+              <item label='Size Desc' value='7'/>
             </menu>
           </vbox><vbox>
             <toggle name='display_show_hidden' label='Show hidden files'>If this is o
diff --git a/ROX-Filer/src/filer.c b/ROX-Filer/src/filer.c
index b5e2e52..d492cb9 100644
--- a/ROX-Filer/src/filer.c
+++ b/ROX-Filer/src/filer.c
@@ -1529,8 +1529,16 @@ FilerWindow *filer_opendir(const char *path, FilerWindow *src_w
        }
        else
        {
-               s_type = o_display_sort_by.int_value;
-               s_order = GTK_SORT_ASCENDING;
+    if (o_display_sort_by.int_value > 3)
+    {
+                 s_type = o_display_sort_by.int_value - 4;
+      s_order = GTK_SORT_DESCENDING;
+    }
+    else
+    {
+                 s_type = o_display_sort_by.int_value;
+      s_order = GTK_SORT_ASCENDING;
+    }
                dstyle = o_display_size.int_value;
                dtype = o_display_details.int_value;
                filer_window->show_hidden = o_display_show_hidden.int_value;

Note that this can lead to ~/.configure/rox.sourceforge.net/ROX-Filer/Options' display_sort_by to contain a value that is illegal without this patch, making it impossible to start ROX-Filer:

ERROR:/build/rox/src/rox-filer-2.11/ROX-Filer/src/view_collection.c:1040:sort_fn: code should not be reached
2 Attachments

Discussion

  • Thomas Leonard
    Thomas Leonard
    2014-08-03

    The extra checkbox in alt2 seems more logical (since it's already an check menu option). If you call it "Reversed" then no extra translations are needed at all, because we already translate the existing menu item.

     
  • What does "it's already an check menu option" mean? Did I miss an option?

    The only way to change ascending/descending sort that I know of is clicking the toolbar icon, which loops through the options.

    Toolbar icon loops through the options, having one control for all options in the option (options menu with both ascending and descending) would mean symmetric UI design which is probably a good thing.

    Alternatively, it could be possible to make right click on the toolbar icon change the sorting category (type, name, date, size) and right click switch between ascending/descending. Then having two controls for sorting category and ascending/descending would seem logical as well.

    Unfortunately I can't write C. I seem to be able to guess some functions and operators but I wouldn't trust myself to adding new variables unfortunately.

    I could come up with some pseudocode for your preferred solution, if that would be of any use.

    Is anybody available to write C code and/or commit changes?

     
  • Thomas Leonard
    Thomas Leonard
    2014-08-04

    In the main menu (right click), you can go to Display -> Reversed. So it would make sense to use the same label in the options box I think.