[gnome-builder] tree: rename gb_tree_node_rebuild() to gb_tree_node_invalidate()



commit 5fb216de43125902a7d6c11d8828c12adc918aa6
Author: Christian Hergert <christian hergert me>
Date:   Sun Jun 14 15:14:59 2015 -0700

    tree: rename gb_tree_node_rebuild() to gb_tree_node_invalidate()
    
    Now that we are lazy about building children nodes, rebuild() is not
    quite accurate as to what is happening underneath.

 src/project-tree/gb-project-tree-actions.c |    4 ++--
 src/tree/gb-tree-node.c                    |   10 +++-------
 src/tree/gb-tree-node.h                    |    4 ++--
 src/tree/gb-tree-private.h                 |    2 +-
 src/tree/gb-tree.c                         |   12 +++++++++---
 5 files changed, 17 insertions(+), 15 deletions(-)
---
diff --git a/src/project-tree/gb-project-tree-actions.c b/src/project-tree/gb-project-tree-actions.c
index 09ad861..ebda763 100644
--- a/src/project-tree/gb-project-tree-actions.c
+++ b/src/project-tree/gb-project-tree-actions.c
@@ -454,7 +454,7 @@ gb_project_tree_actions__make_directory_cb (GObject      *object,
   project_file = create_file (context, file, G_FILE_TYPE_DIRECTORY);
   ide_project_add_file (project, project_file);
 
-  gb_tree_node_rebuild (node);
+  gb_tree_node_invalidate (node);
   gb_tree_node_expand (node, FALSE);
 
   created = gb_tree_find_item (GB_TREE (self), G_OBJECT (project_file));
@@ -506,7 +506,7 @@ gb_project_tree_actions__create_cb (GObject      *object,
 
   gb_workbench_open (workbench, file);
 
-  gb_tree_node_rebuild (node);
+  gb_tree_node_invalidate (node);
   gb_tree_node_expand (node, FALSE);
 
   created = gb_tree_find_item (GB_TREE (self), G_OBJECT (project_file));
diff --git a/src/tree/gb-tree-node.c b/src/tree/gb-tree-node.c
index b7a9f44..dd9ec3f 100644
--- a/src/tree/gb-tree-node.c
+++ b/src/tree/gb-tree-node.c
@@ -85,8 +85,6 @@ gb_tree_node_get_tree (GbTreeNode *node)
 {
   g_return_val_if_fail (GB_IS_TREE_NODE (node), NULL);
 
-  for (; node->parent; node = node->parent) { }
-
   return node->tree;
 }
 
@@ -434,14 +432,12 @@ gb_tree_node_get_area (GbTreeNode   *node,
 }
 
 void
-gb_tree_node_rebuild (GbTreeNode *self)
+gb_tree_node_invalidate (GbTreeNode *self)
 {
-  GbTree *tree;
-
   g_return_if_fail (GB_IS_TREE_NODE (self));
 
-  tree = gb_tree_node_get_tree (self);
-  _gb_tree_rebuild_node (tree, self);
+  if (self->tree != NULL)
+    _gb_tree_invalidate (self->tree, self);
 }
 
 gboolean
diff --git a/src/tree/gb-tree-node.h b/src/tree/gb-tree-node.h
index be5b5b4..b9f7488 100644
--- a/src/tree/gb-tree-node.h
+++ b/src/tree/gb-tree-node.h
@@ -44,14 +44,14 @@ void           gb_tree_node_collapse      (GbTreeNode   *node);
 void           gb_tree_node_select        (GbTreeNode   *node);
 void           gb_tree_node_get_area      (GbTreeNode   *node,
                                            GdkRectangle *area);
-void           gb_tree_node_rebuild       (GbTreeNode   *node);
+void           gb_tree_node_invalidate    (GbTreeNode   *node);
 gboolean       gb_tree_node_get_expanded  (GbTreeNode   *node);
 void           gb_tree_node_show_popover  (GbTreeNode   *node,
                                            GtkPopover   *popover);
 const gchar   *gb_tree_node_get_text      (GbTreeNode   *node);
 void           gb_tree_node_set_text      (GbTreeNode   *node,
                                            const gchar  *text);
-GbTree       *gb_tree_node_get_tree       (GbTreeNode   *node);
+GbTree        *gb_tree_node_get_tree      (GbTreeNode   *node);
 
 G_END_DECLS
 
diff --git a/src/tree/gb-tree-private.h b/src/tree/gb-tree-private.h
index ff9114c..d9d20a6 100644
--- a/src/tree/gb-tree-private.h
+++ b/src/tree/gb-tree-private.h
@@ -23,7 +23,7 @@
 
 G_BEGIN_DECLS
 
-void         _gb_tree_rebuild_node            (GbTree        *tree,
+void         _gb_tree_invalidate              (GbTree        *tree,
                                                GbTreeNode    *node);
 GtkTreePath *_gb_tree_get_path                (GbTree        *tree,
                                                GList         *list);
diff --git a/src/tree/gb-tree.c b/src/tree/gb-tree.c
index d000378..8931dfe 100644
--- a/src/tree/gb-tree.c
+++ b/src/tree/gb-tree.c
@@ -1408,12 +1408,13 @@ gb_tree_prepend (GbTree     *self,
 }
 
 void
-_gb_tree_rebuild_node (GbTree     *self,
-                       GbTreeNode *node)
+_gb_tree_invalidate (GbTree     *self,
+                     GbTreeNode *node)
 {
   GbTreePrivate *priv = gb_tree_get_instance_private (self);
   GtkTreeModel *model;
   GtkTreePath *path;
+  GbTreeNode *parent;
   GtkTreeIter iter;
   GtkTreeIter child;
 
@@ -1431,7 +1432,12 @@ _gb_tree_rebuild_node (GbTree     *self,
         }
     }
 
-  gb_tree_build_node (self, node);
+  _gb_tree_node_set_needs_build (node, TRUE);
+
+  parent = gb_tree_node_get_parent (node);
+
+  if ((parent == NULL) || gb_tree_node_get_expanded (parent))
+    gb_tree_build_node (self, node);
 
   gtk_tree_path_free (path);
 }


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