a) Ok, I suspect this is
a list of child nodes beneath or at the same level. If you look at the
header file, you will find that GTK_CTREE_NODE is infact a
definition for casting to a GList *node.
b) I have had problems
with this recently! It seems that there has been a bug reported (if you
look around the web for it) which means that if you want to get the text of a
cell which is a parent node, the text returned is NULL. Similarly I
tried casting it back to its inherited GtkCList and getting the row text... that
didnt work either. As a result I had to use
gtk_ctree_node_set_row_data. When setting and getting you
parse a gpointer, however, all you have to do is cast past it
on both occasions. Eg: If you wanted to pass a gchar*, you would do the
following:
gchar
*mytext = "helloworld";
GtkCTreeNode *node = NULL;
...
node =
gtk_ctree_node_insert(...);
gtk_ctree_node_set_row_data(ctree,node,(gchar*)mytext);
...
getmytext = (gchar*)
gtk_ctree_node_get_row_data(ctree,node);
...
c) Unless you set data,
you will (if you try to extract data) receive NULL when you call
gtk_ctree_node_get_row_data.
Also, be
careful to make sure that the mytext variable you will be using
doesn't get freed, or when you come to extract the data, it wont be what you
expect, usually, I call g_strdup(mytext). To clean
the memory up, there is a function called:
gtk_ctree_node_set_row_data_full which allows you to specify a
destructor function for the data, I passed it (GtkDestroyNotify)
g_free. That seems to work fine (found here: http://developer.gnome.org/doc/API/gtk/gtkctree.html#GTK-CTREE-NODE-SET-ROW-DATA-FULL).
Regards,
Martyn
|