GdaTreeNode

GdaTreeNode — a node in a GdaTree

Synopsis

                    GdaTreeNode;
GdaTreeNode*        gda_tree_node_new                   (const gchar *name);
GSList*             gda_tree_node_get_children          (GdaTreeNode *node);
GdaTreeNode*        gda_tree_node_get_child_index       (GdaTreeNode *node,
                                                         gint index);
GdaTreeNode*        gda_tree_node_get_child_name        (GdaTreeNode *node,
                                                         const gchar *name);
void                gda_tree_node_set_node_attribute    (GdaTreeNode *node,
                                                         const gchar *attribute,
                                                         const GValue *value,
                                                         GDestroyNotify destroy);
const GValue*       gda_tree_node_get_node_attribute    (GdaTreeNode *node,
                                                         const gchar *attribute);
const GValue*       gda_tree_node_fetch_attribute       (GdaTreeNode *node,
                                                         const gchar *attribute);

Object Hierarchy

  GObject
   +----GdaTreeNode

Properties

  "name"                     gchar*                : Read / Write

Description

Every node in a GdaTree tree is represented by a single GdaTreeNode object. There is no distinction between nodes which have children and those which don't (leaf nodes).

The GdaTreeNode is very basic as it only has a "name" attribute: users are encouraged to subclass it to add more features if needed (and make use of them by defining a GdaTreeManagerNodeFunc function and calling gda_tree_manager_set_node_create_func()).

Details

GdaTreeNode

typedef struct _GdaTreeNode GdaTreeNode;


gda_tree_node_new ()

GdaTreeNode*        gda_tree_node_new                   (const gchar *name);

Creates a new GdaTreeNode object

name :

a name, or NULL

Returns :

a new GdaTreeNode

gda_tree_node_get_children ()

GSList*             gda_tree_node_get_children          (GdaTreeNode *node);

Get a list of all node's children, free it with g_slist_free() after usage

node :

a GdaTreeNode object

Returns :

a new GSList of GdaTreeNode objects, or NULL if node does not have any child

gda_tree_node_get_child_index ()

GdaTreeNode*        gda_tree_node_get_child_index       (GdaTreeNode *node,
                                                         gint index);

Get the GdaTreeNode child of node at position index (starting at 0).

node :

a GdaTreeNode object

index :

a index

Returns :

the GdaTreeNode, or NULL if not found

gda_tree_node_get_child_name ()

GdaTreeNode*        gda_tree_node_get_child_name        (GdaTreeNode *node,
                                                         const gchar *name);

Get the GdaTreeNode child of node which has the GDA_ATTRIBUTE_NAME set to name

node :

a GdaTreeNode object

name :

requested node's name

Returns :

the GdaTreeNode, or NULL if not found

gda_tree_node_set_node_attribute ()

void                gda_tree_node_set_node_attribute    (GdaTreeNode *node,
                                                         const gchar *attribute,
                                                         const GValue *value,
                                                         GDestroyNotify destroy);

Set the value associated to a named attribute. The attribute string is 'stolen' by this method, and the memory it uses will be freed using the destroy function when no longer needed (if destroy is NULL, then the string will not be freed at all).

Attributes can have any name, but Libgda proposes some default names, see this section.

For example one would use it as:

gda_tree_node_set_node_attribute (node, g_strdup (my_attribute), g_free, my_value); gda_tree_node_set_node_attribute (node, GDA_ATTRIBUTE_NAME, NULL, my_value);

If there is already an attribute named attribute set, then its value is replaced with the new value (value is copied), except if value is NULL, in which case the attribute is removed.

node :

a GdaTreeNode

attribute :

attribute name

value :

a GValue, or NULL

destroy :

a function to be called when attribute is not needed anymore, or NULL

gda_tree_node_get_node_attribute ()

const GValue*       gda_tree_node_get_node_attribute    (GdaTreeNode *node,
                                                         const gchar *attribute);

Get the value associated to the attribute named attribute for node. The difference with gda_tree_node_fetch_attribute() is that gda_tree_node_fetch_attribute() will also query node's parents (recursively up to the top level node) if the attribute is not set for node.

Attributes can have any name, but Libgda proposes some default names, see this section.

node :

a GdaTreeNode

attribute :

attribute name as a string

Returns :

a read-only GValue, or NULL if not attribute named attribute has been set for node

gda_tree_node_fetch_attribute ()

const GValue*       gda_tree_node_fetch_attribute       (GdaTreeNode *node,
                                                         const gchar *attribute);

Get the value associated to the attribute named attribute for node. If the attribute is not set, then node's parents is queries (recursively up to the top level node).

Attributes can have any name, but Libgda proposes some default names, see this section.

node :

a GdaTreeNode

attribute :

attribute name as a string

Returns :

a read-only GValue, or NULL if not attribute named attribute has been set for node

Property Details

The "name" property

  "name"                     gchar*                : Read / Write

Node's name attribute.

Default value: NULL