[gnome-builder] project-tree: add Empty node back when necessary



commit c8209de78a210b4fb253bec3356db69099b22a20
Author: Christian Hergert <chergert redhat com>
Date:   Tue Feb 12 13:19:15 2019 -0800

    project-tree: add Empty node back when necessary
    
    If we remove the last child of a directory, we might need to add back an
    Empty node.
    
    Long term, we probably want to handle this at the tree-node level.
    
    Fixes #809

 src/plugins/project-tree/gbp-project-tree-addin.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)
---
diff --git a/src/plugins/project-tree/gbp-project-tree-addin.c 
b/src/plugins/project-tree/gbp-project-tree-addin.c
index b7d22d695..470c784ce 100644
--- a/src/plugins/project-tree/gbp-project-tree-addin.c
+++ b/src/plugins/project-tree/gbp-project-tree-addin.c
@@ -29,6 +29,8 @@
 #include <libide-tree.h>
 #include <libide-vcs.h>
 
+#include "ide-tree-private.h"
+
 #include "gbp-project-tree-addin.h"
 
 struct _GbpProjectTreeAddin
@@ -482,7 +484,16 @@ gbp_project_tree_addin_remove_file (GbpProjectTreeAddin *self,
 #endif
 
   if ((selected = find_file_node (self->tree, file)))
-    ide_tree_node_remove (ide_tree_node_get_parent (selected), selected);
+    {
+      IdeTreeNode *parent = ide_tree_node_get_parent (selected);
+
+      ide_tree_node_remove (parent, selected);
+
+      /* Force the parent node to re-add the Empty child */
+      if (ide_tree_node_get_children_possible (parent) &&
+          ide_tree_node_get_n_children (parent) == 0)
+        _ide_tree_node_remove_all (parent);
+    }
 
   IDE_EXIT;
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]