[gnome-builder] tree: add GbTreeNode:children-possible property
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] tree: add GbTreeNode:children-possible property
- Date: Sun, 27 Sep 2015 04:12:40 +0000 (UTC)
commit 7ec416b9fffba428135503b79e19e272cc1ca04c
Author: Christian Hergert <christian hergert me>
Date: Sat Sep 26 16:12:13 2015 -0700
tree: add GbTreeNode:children-possible property
This is about optimizing building of the tree by being lazy. Just export
it as a property so bindings can use it more easily.
src/tree/gb-tree-node.c | 37 +++++++++++++++++++++++++++++++++++++
src/tree/gb-tree-node.h | 1 +
2 files changed, 38 insertions(+), 0 deletions(-)
---
diff --git a/src/tree/gb-tree-node.c b/src/tree/gb-tree-node.c
index b30545d..170085a 100644
--- a/src/tree/gb-tree-node.c
+++ b/src/tree/gb-tree-node.c
@@ -50,6 +50,7 @@ G_DEFINE_TYPE (GbTreeNode, gb_tree_node, G_TYPE_INITIALLY_UNOWNED)
enum {
PROP_0,
+ PROP_CHILDREN_POSSIBLE,
PROP_ICON_NAME,
PROP_ITEM,
PROP_PARENT,
@@ -519,6 +520,10 @@ gb_tree_node_get_property (GObject *object,
switch (prop_id)
{
+ case PROP_CHILDREN_POSSIBLE:
+ g_value_set_boolean (value, gb_tree_node_get_children_possible (node));
+ break;
+
case PROP_ICON_NAME:
g_value_set_string (value, g_quark_to_string (node->icon_name));
break;
@@ -562,6 +567,10 @@ gb_tree_node_set_property (GObject *object,
switch (prop_id)
{
+ case PROP_CHILDREN_POSSIBLE:
+ gb_tree_node_set_children_possible (node, g_value_get_boolean (value));
+ break;
+
case PROP_ICON_NAME:
gb_tree_node_set_icon_name (node, g_value_get_string (value));
break;
@@ -597,6 +606,26 @@ gb_tree_node_class_init (GbTreeNodeClass *klass)
object_class->set_property = gb_tree_node_set_property;
/**
+ * GbTreeNode:children-possible:
+ *
+ * This property allows for more lazy loading of nodes.
+ *
+ * When a node becomes visible, we normally build it's children nodes
+ * so that we know if we need an expansion arrow. However, that can
+ * be expensive when rendering directories with lots of subdirectories.
+ *
+ * Using this, you can always show an arrow without building the children
+ * and simply hide the arrow if there were in fact no children (upon
+ * expansion).
+ */
+ gParamSpecs [PROP_CHILDREN_POSSIBLE] =
+ g_param_spec_boolean ("children-possible",
+ "Children Possible",
+ "Allows for lazy creation of children nodes.",
+ FALSE,
+ (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+
+ /**
* GbTreeNode:icon-name:
*
* An icon-name to display on the row.
@@ -861,6 +890,14 @@ _gb_tree_node_remove_dummy_child (GbTreeNode *self)
}
}
+gboolean
+gb_tree_node_get_children_possible (GbTreeNode *self)
+{
+ g_return_val_if_fail (GB_IS_TREE_NODE (self), FALSE);
+
+ return self->children_possible;
+}
+
/**
* gb_tree_node_set_children_possible:
* @self: A #GbTreeNode.
diff --git a/src/tree/gb-tree-node.h b/src/tree/gb-tree-node.h
index 47faca3..3af41e7 100644
--- a/src/tree/gb-tree-node.h
+++ b/src/tree/gb-tree-node.h
@@ -58,6 +58,7 @@ 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);
+gboolean gb_tree_node_get_children_possible (GbTreeNode *self);
void gb_tree_node_set_children_possible (GbTreeNode *self,
gboolean children_possible);
gboolean gb_tree_node_get_use_markup (GbTreeNode *self);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]