[gnome-builder] project-tree: sort directories before regular files
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] project-tree: sort directories before regular files
- Date: Wed, 16 Jan 2019 19:36:47 +0000 (UTC)
commit 03e7f03ad8294ba5d7b06cffc59565545363da42
Author: Daniel Buch <boogiewasthere gmail com>
Date: Wed Jan 16 12:02:44 2019 +0100
project-tree: sort directories before regular files
src/plugins/project-tree/gbp-project-tree-addin.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
---
diff --git a/src/plugins/project-tree/gbp-project-tree-addin.c
b/src/plugins/project-tree/gbp-project-tree-addin.c
index 7c23a996c..2c20dd9a3 100644
--- a/src/plugins/project-tree/gbp-project-tree-addin.c
+++ b/src/plugins/project-tree/gbp-project-tree-addin.c
@@ -359,6 +359,18 @@ node_compare (IdeTreeNode *node,
g_assert (IDE_IS_TREE_NODE (node));
g_assert (IDE_IS_TREE_NODE (child));
+ /* Child is a directory and *must* be last in line at this point
+ * given that node is a regular file.
+ * Hence break comparation for subsequent ide_tree_node_insert_before() */
+ if (ide_tree_node_get_children_possible (child) &&
+ !ide_tree_node_get_children_possible (node))
+ return 0;
+
+ /* Skip directories if child is a regular file */
+ if (!ide_tree_node_get_children_possible (child) &&
+ ide_tree_node_get_children_possible (node))
+ return 1;
+
child_name = ide_tree_node_get_display_name (child);
node_name = ide_tree_node_get_display_name (node);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]