[gnome-builder] project-tree: remove empty node when inserting new child
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] project-tree: remove empty node when inserting new child
- Date: Wed, 6 Feb 2019 23:25:52 +0000 (UTC)
commit 92698699709300466c255ee81f7480a98e1c7970
Author: Christian Hergert <chergert redhat com>
Date: Wed Feb 6 15:25:23 2019 -0800
project-tree: remove empty node when inserting new child
Fixes #800
src/plugins/project-tree/gbp-project-tree-addin.c | 11 +++++++++++
1 file changed, 11 insertions(+)
---
diff --git a/src/plugins/project-tree/gbp-project-tree-addin.c
b/src/plugins/project-tree/gbp-project-tree-addin.c
index 2c20dd9a3..b7d22d695 100644
--- a/src/plugins/project-tree/gbp-project-tree-addin.c
+++ b/src/plugins/project-tree/gbp-project-tree-addin.c
@@ -425,9 +425,17 @@ gbp_project_tree_addin_add_file (GbpProjectTreeAddin *self,
if ((parent = find_file_node (self->tree, item)))
{
+ IdeTreeNode *child;
+
if (!ide_tree_node_expanded (self->tree, parent))
IDE_EXIT;
+ /* Remove empty children if necessary */
+ if (ide_tree_node_get_n_children (parent) == 1 &&
+ (child = ide_tree_node_get_nth_child (parent, 0)) &&
+ ide_tree_node_is_empty (child))
+ ide_tree_node_remove (parent, child);
+
continue;
}
@@ -446,6 +454,9 @@ gbp_project_tree_addin_add_file (GbpProjectTreeAddin *self,
node = create_file_node (project_file);
ide_tree_node_insert_sorted (parent, node, node_compare);
+
+ if (!ide_tree_node_expanded (self->tree, parent))
+ ide_tree_expand_node (self->tree, parent);
}
IDE_EXIT;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]