[gnome-commander/gcmd-1-14] When sorting for size, ignore directories
- From: Uwe Scholz <uwescholz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-commander/gcmd-1-14] When sorting for size, ignore directories
- Date: Sun, 20 Mar 2022 16:30:32 +0000 (UTC)
commit 2ceab450e34a7b7426dafd25a9c894aae2b18b61
Author: Uwe Scholz <u scholz83 gmx de>
Date: Sun Mar 20 17:26:43 2022 +0100
When sorting for size, ignore directories
src/gnome-cmd-file-list.cc | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
---
diff --git a/src/gnome-cmd-file-list.cc b/src/gnome-cmd-file-list.cc
index da6b6dc3..cccac8ee 100644
--- a/src/gnome-cmd-file-list.cc
+++ b/src/gnome-cmd-file-list.cc
@@ -1012,6 +1012,22 @@ static gint sort_by_size (GnomeCmdFile *f1, GnomeCmdFile *f2, GnomeCmdFileList *
gboolean raising = fl->priv->sort_raising[fl->priv->current_col];
gboolean file_raising = fl->priv->sort_raising[1];
+ // Check if both items are directories. In this case, just compare their names.
+ if ((f1->GetGfileAttributeUInt32(G_FILE_ATTRIBUTE_STANDARD_TYPE) == G_FILE_TYPE_DIRECTORY)
+ && (f2->GetGfileAttributeUInt32(G_FILE_ATTRIBUTE_STANDARD_TYPE) == G_FILE_TYPE_DIRECTORY))
+ {
+ return my_strcmp (f1->get_collation_fname(), f2->get_collation_fname(), file_raising);
+ }
+ // If just one item is a directory, return a fixed value.
+ if (f1->GetGfileAttributeUInt32(G_FILE_ATTRIBUTE_STANDARD_TYPE) == G_FILE_TYPE_DIRECTORY)
+ {
+ return -1;
+ }
+ if (f2->GetGfileAttributeUInt32(G_FILE_ATTRIBUTE_STANDARD_TYPE) == G_FILE_TYPE_DIRECTORY)
+ {
+ return 1;
+ }
+
gint ret = my_intcmp (f1->GetGfileAttributeUInt32(G_FILE_ATTRIBUTE_STANDARD_TYPE),
f2->GetGfileAttributeUInt32(G_FILE_ATTRIBUTE_STANDARD_TYPE), TRUE);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]