WIP: preparing the recursive loop that builds the tree (0)
This commit is contained in:
parent
8c3884e619
commit
1d1b1fa744
|
@ -13,8 +13,10 @@
|
|||
/* */
|
||||
/*************************************************************************************************************************************/
|
||||
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - //
|
||||
|
||||
|
||||
/************************************************** <> *****************************************************/
|
||||
/* */
|
||||
/* https://developer-old.gnome.org/gtk4/stable/GtkTreeView.html */
|
||||
|
@ -67,38 +69,36 @@ static TreeItem A[] = {{ "C", C }, { "D", D }, { NULL }};
|
|||
static TreeItem R[] = {{ "A", A }, { "B", B }, { NULL }};
|
||||
|
||||
static GtkTreeModel *
|
||||
iterate_node(GtkTreeStore *model, TreeItem *parent)
|
||||
iterate_node(GtkTreeStore *model, TreeItem *parent, TreeItem *children)
|
||||
{
|
||||
printf("parent->label : %s\n", parent->label);
|
||||
printf("parent, children : %s, %s\n", parent->label, children->label);
|
||||
/* gtk_tree_store_append (model, &child_child_iter, &child_iter); */
|
||||
/* gtk_tree_store_set (model, &child_child_iter, COLUMN_0, item_2->label, -1); */
|
||||
return GTK_TREE_MODEL (model);
|
||||
}
|
||||
|
||||
static GtkTreeModel *
|
||||
create_model (void)
|
||||
{
|
||||
GtkTreeStore *model;
|
||||
GtkTreeIter iter;
|
||||
GtkTreeStore *model = gtk_tree_store_new (NUM_COLUMNS, G_TYPE_STRING);
|
||||
|
||||
TreeItem *item_0 = R;
|
||||
|
||||
model = gtk_tree_store_new (NUM_COLUMNS, G_TYPE_STRING);
|
||||
|
||||
while (item_0->label)
|
||||
{
|
||||
TreeItem *item_1 = item_0->children;
|
||||
GtkTreeIter iter;
|
||||
gtk_tree_store_append (model, &iter, NULL);
|
||||
gtk_tree_store_set (model, &iter, COLUMN_0, item_0->label, -1);
|
||||
|
||||
while (item_1->label)
|
||||
{
|
||||
TreeItem *item_1 = item_0->children;
|
||||
while (item_1->label) {
|
||||
GtkTreeIter child_iter;
|
||||
|
||||
gtk_tree_store_append (model, &child_iter, &iter);
|
||||
gtk_tree_store_set (model, &child_iter, COLUMN_0, item_1->label, -1);
|
||||
|
||||
TreeItem *item_2 = item_1->children;
|
||||
while (item_2->label) {
|
||||
GtkTreeIter child_child_iter;
|
||||
iterate_node(model, item_2);
|
||||
iterate_node(model, item_1, item_2);
|
||||
gtk_tree_store_append (model, &child_child_iter, &child_iter);
|
||||
gtk_tree_store_set (model, &child_child_iter, COLUMN_0, item_2->label, -1);
|
||||
|
||||
|
|
Loading…
Reference in New Issue