[gnome-builder/wip/libide: 23/153] tree: add root getter and setters



commit 9afe0861c92003c6d14899c01727d055440f72c1
Author: Christian Hergert <christian hergert me>
Date:   Sat Feb 7 18:25:54 2015 -0800

    tree: add root getter and setters

 src/tree/gb-tree.c |   22 +++++++++++++++++++---
 src/tree/gb-tree.h |    3 +++
 2 files changed, 22 insertions(+), 3 deletions(-)
---
diff --git a/src/tree/gb-tree.c b/src/tree/gb-tree.c
index b542776..9916980 100644
--- a/src/tree/gb-tree.c
+++ b/src/tree/gb-tree.c
@@ -490,6 +490,22 @@ gb_tree_remove_builder (GbTree        *tree,
 }
 
 /**
+ * gb_tree_get_root:
+ *
+ * Retrieves the root node of the tree. The root node is not a visible node
+ * in the tree, but a placeholder for all other builders to build upon.
+ *
+ * Returns: (transfer none) (nullable): A #GbTreeNode or %NULL.
+ */
+GbTreeNode *
+gb_tree_get_root (GbTree *tree)
+{
+  g_return_val_if_fail (GB_IS_TREE (tree), NULL);
+
+  return tree->priv->root;
+}
+
+/**
  * gb_tree_set_root:
  * @tree: (in): A #GbTree.
  * @node: (in): A #GbTreeNode.
@@ -498,7 +514,7 @@ gb_tree_remove_builder (GbTree        *tree,
  * the items within the treeview. The item itself will not be added
  * to the tree, but the direct children will be.
  */
-static void
+void
 gb_tree_set_root (GbTree     *tree,
                   GbTreeNode *root)
 {
@@ -888,7 +904,7 @@ gb_tree_class_init (GbTreeClass *klass)
                          _ ("Root"),
                          _ ("The root object of the tree."),
                          GB_TYPE_TREE_NODE,
-                         G_PARAM_READWRITE);
+                         G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
   g_object_class_install_property (object_class, PROP_ROOT,
                                    gParamSpecs[PROP_ROOT]);
 
@@ -897,7 +913,7 @@ gb_tree_class_init (GbTreeClass *klass)
                          _ ("Selection"),
                          _ ("The node selection."),
                          GB_TYPE_TREE_NODE,
-                         G_PARAM_READWRITE);
+                         G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
   g_object_class_install_property (object_class, PROP_SELECTION,
                                    gParamSpecs[PROP_SELECTION]);
 }
diff --git a/src/tree/gb-tree.h b/src/tree/gb-tree.h
index 8b02b4d..4aa294d 100644
--- a/src/tree/gb-tree.h
+++ b/src/tree/gb-tree.h
@@ -67,6 +67,9 @@ void          gb_tree_append         (GbTree        *tree,
 void          gb_tree_prepend        (GbTree        *tree,
                                       GbTreeNode    *node,
                                       GbTreeNode    *child);
+void          gb_tree_set_root       (GbTree        *tree,
+                                      GbTreeNode    *node);
+GbTreeNode   *gb_tree_get_root       (GbTree        *tree);
 GbTree       *gb_tree_node_get_tree  (GbTreeNode    *node);
 
 G_END_DECLS


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