[gnome-builder] tree: add gb_tree_node_get_iter()



commit 5438d6bfc8c204d9626162dbf7beb71070678e24
Author: Christian Hergert <christian hergert me>
Date:   Mon Jun 15 01:52:31 2015 -0700

    tree: add gb_tree_node_get_iter()
    
    Helper to get an iter for a given node.

 src/tree/gb-tree-node.c |   33 +++++++++++++++++++++++++++++++++
 src/tree/gb-tree-node.h |    4 +++-
 2 files changed, 36 insertions(+), 1 deletions(-)
---
diff --git a/src/tree/gb-tree-node.c b/src/tree/gb-tree-node.c
index 5ea42c7..90e0813 100644
--- a/src/tree/gb-tree-node.c
+++ b/src/tree/gb-tree-node.c
@@ -231,6 +231,39 @@ gb_tree_node_get_path (GbTreeNode *node)
   return path;
 }
 
+gboolean
+gb_tree_node_get_iter (GbTreeNode  *self,
+                       GtkTreeIter *iter)
+{
+  GtkTreeModel *model;
+  GtkTreePath *path;
+  gboolean ret = FALSE;
+
+  g_return_val_if_fail (GB_IS_TREE_NODE (self), FALSE);
+  g_return_val_if_fail (iter != NULL, FALSE);
+
+  if (self->tree != NULL)
+    {
+      model = gtk_tree_view_get_model (GTK_TREE_VIEW (self->tree));
+      path = gb_tree_node_get_path (self);
+      ret = gtk_tree_model_get_iter (model, iter, path);
+      gtk_tree_path_free (path);
+    }
+
+#if 0
+  if (ret)
+    {
+      GbTreeNode *other = NULL;
+
+      gtk_tree_model_get (model, iter, 0, &other, -1);
+      g_assert (other == self);
+      g_clear_object (&other);
+    }
+#endif
+
+  return ret;
+}
+
 /**
  * gb_tree_node_get_parent:
  * @node: (in): A #GbTreeNode.
diff --git a/src/tree/gb-tree-node.h b/src/tree/gb-tree-node.h
index 94d3663..828883e 100644
--- a/src/tree/gb-tree-node.h
+++ b/src/tree/gb-tree-node.h
@@ -34,7 +34,9 @@ const gchar   *gb_tree_node_get_icon_name (GbTreeNode   *node);
 GObject       *gb_tree_node_get_item      (GbTreeNode   *node);
 GbTreeNode    *gb_tree_node_get_parent    (GbTreeNode   *node);
 GtkTreePath   *gb_tree_node_get_path      (GbTreeNode   *node);
-void           gb_tree_node_prepend       (GbTreeNode  *node,
+gboolean       gb_tree_node_get_iter      (GbTreeNode   *node,
+                                           GtkTreeIter  *iter);
+void           gb_tree_node_prepend       (GbTreeNode   *node,
                                            GbTreeNode   *child);
 void           gb_tree_node_remove        (GbTreeNode   *node,
                                            GbTreeNode   *child);


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