When sorting by name, Ristretto puts hyphens after spaces when the word before the space/hyphen ends in a number. In other programs like Thunar, name sorting puts hyphens before spaces for this case. Copy an image into a separate folder twice with the following names: test1-1.gif test1 test 1.gif What I expected: In Thunar, test1-1.gif comes first. The same order should happen in Ristretto. What happened: In Ristretto, test1 test 1.gif comes first.
While testing this, I also found it sorted other symbols differently as well. Here are some of my findings with a few symbols: Thunar order: test1|1.gif test1 1.gif test1_1.gif test1-1.gif test1+1.gif Ristretto order: test1 1.gif test1+1.gif test1-1.gif test1_1.gif test1|1.gif I'm not sure if this falls under the same bug as my other issue or if it's something separate.
Created attachment 5003 Use collate keys to handle filename sorting This proposed patch uses g_utf8_collate_key_for_filename to generate collate keys that the image list can use to compare files. This simplifies the comparison function and sorts files the same way Thunar does which should fix both issues presented above.
It would be very nice if ristretto matched thunar's behavior about case-sorting. One usage-case for me is to have ristretto and thunar open in parallel to organize photos, and having sorts match is essential for efficiency here. Maybe this should be a separate bug, however; I don't know. The following change on top of Eric's patch seems to work: --- a/src/image_list.c +++ b/src/image_list.c @@ -1358,7 +1358,7 @@ cb_rstto_image_list_image_name_compare_func (RsttoFile *a, const gchar *a_collate_key = rstto_file_get_collate_key (a); const gchar *b_collate_key = rstto_file_get_collate_key (b); - return g_strcmp0(a_collate_key, b_collate_key); + return g_ascii_strcasecmp(a_collate_key, b_collate_key); } I doubt the ascii compare is ideal but I'm not familiar with C/glib and that was the best I could find searching the documentation at https://developer.gnome.org/glib/2.28/glib-String-Utility-Functions.html.
g_strcmp0 should be sufficient after collating the files. g_utf8_casefold before calling the collate key might be useful. Do you have an example of some files that aren't being sorted the same as Thunar?
Eric, I'm assigning the bug to you as you seem to be working on it. Let me know if you have a working patch that needs testing! Thanks.
Created attachment 5919 0001-Use-collate-keys-to-handle-filename-sorting-Bug-9731 This adds the casefold to perform the case insensitive sorting. It should be exactly like Thunar now.
Patch tested, works for me with rmlipman's test set.
Thanks, pushed to master in: commit 788411a43227a0b8b2f31766b136bb9dc2e30030 Author: Eric Koegel <eric.koegel@gmail.com> Date: Mon Feb 9 11:18:50 2015 +0300 Use collate keys to handle filename sorting (Bug #9731) This uses g_utf8_casefold and g_utf8_collate_key_for_filename on the files to perform case insensitive sorting the same way Thunar and Xfdesktop do. http://git.xfce.org/apps/ristretto/commit/?id=788411a43227a0b8b2f31766b136bb9dc2e30030