[gnome-builder] project-tree: improve sorting



commit 78b7062242f3df8be036c198a1f8991e8cd58c17
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]