[Geany-devel] [patch] Improved documents list sorting

Colomban Wendling lists.ban at xxxxx
Mon Apr 26 13:42:25 UTC 2010


Hi!

As some of you might have noticed, the sorting in the "Documents" side
panel is not perfect when extensions are involved. For example, if you
have the three files a.c, a.h and a-b.c, they will be sorted in the
following order [1]:
  a.c, a-b.c, a.h
rather than [2]:
  a.c, a.h, a-b.c
This is a little annoying to find the a.h file.

As you expected, I've written a patch to fix this, an I propose it here.
Hum, well no: I've written two different patches. Why? Both have
advantages and inconveniences over the other.
Both use g_utf8_collate_key_for_filename() to get a clever sort, which
fixes the problem I spoken above, and also sorts 1, 2 and 10 numerically
rather than alphabetically - thus we have 1, 2, 10 and not 1, 10, 2.

The difference between the two patches is the way thy integrate in Geany.

0001-improved-documents-sorting.diff:
This one is small, almost no code changes, and don't persistently use
more memory. But OTHO, it computes the collate key of both names to
compare each and every time the sort function is called.

0001-improved-documents-sorting-2.diff:
This one is probably faster, but persistently use a little more memory:
it computes the collate key only when adding the item, and stores it in
the tree model.
Another "advantage" of it is that it easily allow to use different
collate functions for files and directories - not sure it is useful.

Then, there are the two patches, I let you chose/discuss the one is the
better if you're interested.

Regards,
Colomban

[1] without the patch,
http://ban.free-h.net/geany/improved-documents-sorting/before.png
[2] with the patch:
http://ban.free-h.net/geany/improved-documents-sorting/after.png
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-improved-documents-sorting.diff
Type: text/x-patch
Size: 1312 bytes
Desc: not available
URL: <http://lists.geany.org/pipermail/devel/attachments/20100426/07e8f7ba/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-improved-documents-sorting-2.diff
Type: text/x-patch
Size: 3743 bytes
Desc: not available
URL: <http://lists.geany.org/pipermail/devel/attachments/20100426/07e8f7ba/attachment-0001.bin>


More information about the Devel mailing list