[gnome-builder/wip/large-project] project-tree: improve sorting
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/wip/large-project] project-tree: improve sorting
- Date: Mon, 15 Jun 2015 08:55:22 +0000 (UTC)
commit e0e25ac25a0c45a1c95a623cf7d2d0858c977afb
Author: Christian Hergert <christian hergert me>
Date: Mon Jun 15 01:51:36 2015 -0700
project-tree: improve sorting
src/project-tree/gb-project-file.c | 10 +++++++---
1 files changed, 7 insertions(+), 3 deletions(-)
---
diff --git a/src/project-tree/gb-project-file.c b/src/project-tree/gb-project-file.c
index 203648b..6ee4486 100644
--- a/src/project-tree/gb-project-file.c
+++ b/src/project-tree/gb-project-file.c
@@ -68,11 +68,15 @@ gb_project_file_compare_directories_first (GbProjectFile *a,
{
GFileType file_type_a = g_file_info_get_file_type (a->file_info);
GFileType file_type_b = g_file_info_get_file_type (b->file_info);
+ gint dir_a = (file_type_a == G_FILE_TYPE_DIRECTORY);
+ gint dir_b = (file_type_b == G_FILE_TYPE_DIRECTORY);
+ gint ret;
- if (file_type_a != file_type_b)
- return (file_type_a == G_FILE_TYPE_DIRECTORY) ? -1 : 1;
+ ret = dir_b - dir_a;
+ if (ret == 0)
+ ret = gb_project_file_compare (a, b);
- return gb_project_file_compare (a, b);
+ return ret;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]