[libdazzle] tree: add a construct only always-expand property
- From: Sébastien Lafargue <slafargue src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libdazzle] tree: add a construct only always-expand property
- Date: Sat, 29 Jul 2017 20:01:49 +0000 (UTC)
commit 8ad240bae0f9da6447699a9e00a7760789436ecb
Author: Sebastien Lafargue <slafargue gnome org>
Date: Sat Jul 29 15:08:59 2017 +0200
tree: add a construct only always-expand property
src/tree/dzl-tree.c | 31 +++++++++++++++++++++++++++++--
1 files changed, 29 insertions(+), 2 deletions(-)
---
diff --git a/src/tree/dzl-tree.c b/src/tree/dzl-tree.c
index 13576e6..d7502c6 100644
--- a/src/tree/dzl-tree.c
+++ b/src/tree/dzl-tree.c
@@ -37,6 +37,7 @@ typedef struct
GMenuModel *context_menu;
GdkRGBA dim_foreground;
guint show_icons : 1;
+ guint always_expand : 1;
} DzlTreePrivate;
typedef struct
@@ -62,6 +63,7 @@ G_DEFINE_TYPE_WITH_CODE (DzlTree, dzl_tree, GTK_TYPE_TREE_VIEW,
enum {
PROP_0,
+ PROP_ALWAYS_EXPAND,
PROP_CONTEXT_MENU,
PROP_ROOT,
PROP_SELECTION,
@@ -475,8 +477,15 @@ dzl_tree_add (DzlTree *self,
if (dzl_tree_node_get_children_possible (child))
_dzl_tree_node_add_dummy_child (child);
- if (node == priv->root)
- _dzl_tree_build_node (self, child);
+ if (priv->always_expand)
+ {
+ _dzl_tree_build_node (self, child);
+ dzl_tree_node_expand (child, TRUE);
+ }
+ else if (node == priv->root)
+ {
+ _dzl_tree_build_node (self, child);
+ }
g_object_unref (child);
}
@@ -830,6 +839,10 @@ dzl_tree_get_property (GObject *object,
switch (prop_id)
{
+ case PROP_ALWAYS_EXPAND:
+ g_value_set_boolean (value, priv->always_expand);
+ break;
+
case PROP_CONTEXT_MENU:
g_value_set_object (value, priv->context_menu);
break;
@@ -858,9 +871,14 @@ dzl_tree_set_property (GObject *object,
GParamSpec *pspec)
{
DzlTree *self = DZL_TREE (object);
+ DzlTreePrivate *priv = dzl_tree_get_instance_private (self);
switch (prop_id)
{
+ case PROP_ALWAYS_EXPAND:
+ priv->always_expand = g_value_get_boolean (value);
+ break;
+
case PROP_CONTEXT_MENU:
dzl_tree_set_context_menu (self, g_value_get_object (value));
break;
@@ -910,6 +928,15 @@ dzl_tree_class_init (DzlTreeClass *klass)
klass->action = dzl_tree_real_action;
+ properties [PROP_ALWAYS_EXPAND] =
+ g_param_spec_boolean ("always-expand",
+ "Always expand",
+ "Always expand",
+ FALSE,
+ (G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY |
+ G_PARAM_STATIC_STRINGS));
+
properties[PROP_CONTEXT_MENU] =
g_param_spec_object ("context-menu",
"Context Menu",
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]