WIP: Construction itérative de l'arbre. _append() et _set() dans iterate_node()
This commit is contained in:
parent
c00e97b4bd
commit
7278567729
|
@ -70,55 +70,52 @@ static TreeItem R[] = {{ "A", A }, { "B", B }, { NULL }};
|
||||||
static TreeItem O[] = {{ "R", R }, { NULL }}; // Artefact added for symetry
|
static TreeItem O[] = {{ "R", R }, { NULL }}; // Artefact added for symetry
|
||||||
|
|
||||||
// iterate_node(model, item_0, item_1, &iter, &child_iter);
|
// iterate_node(model, item_0, item_1, &iter, &child_iter);
|
||||||
static GtkTreeModel *
|
static void iterate_node(GtkTreeStore *model,
|
||||||
iterate_node(GtkTreeStore *model,
|
GtkTreeIter *iter_children,
|
||||||
TreeItem *item_parent, TreeItem *item_children,
|
TreeItem *item_children,
|
||||||
GtkTreeIter iter_parent, GtkTreeIter iter_children)
|
GtkTreeIter *iter_parent)
|
||||||
{ printf("parent, children : %s -> %s %p -> %p %p -> %p %p -> %p %p -> %p\n",\
|
{
|
||||||
item_parent->label, item_children->label,\
|
gtk_tree_store_append (model, iter_children, iter_parent);
|
||||||
item_parent, item_children,
|
gtk_tree_store_set (model, iter_children, COLUMN_0, item_children->label, -1);
|
||||||
&item_parent, &item_children,
|
|
||||||
iter_parent, iter_children,
|
|
||||||
&iter_parent, &iter_children);
|
|
||||||
/* gtk_tree_store_append (model, &iter_children, &iter_parent); */
|
|
||||||
/* gtk_tree_store_set (model, &iter_children, COLUMN_0, item_children->label, -1); */
|
|
||||||
return GTK_TREE_MODEL (model);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static GtkTreeModel *
|
static GtkTreeModel *
|
||||||
create_model (void)
|
create_model (void)
|
||||||
{
|
{
|
||||||
|
TreeItem *item_0, *item_1, *item_2;
|
||||||
|
GtkTreeIter iter_0, iter_1, iter_2;
|
||||||
|
|
||||||
GtkTreeStore *model = gtk_tree_store_new (NUM_COLUMNS, G_TYPE_STRING);
|
GtkTreeStore *model = gtk_tree_store_new (NUM_COLUMNS, G_TYPE_STRING);
|
||||||
|
|
||||||
TreeItem *item_0 = O->children;
|
if (O->children) {
|
||||||
|
item_0 = O->children;
|
||||||
|
|
||||||
while (item_0->label) {
|
while (item_0->label) {
|
||||||
GtkTreeIter iter;
|
printf("item_0 = %s\n", item_0->label);
|
||||||
// iterate_node(model, O, item_0, (GtkTreeIter) model, iter);
|
iterate_node(model, &iter_0, item_0, NULL);
|
||||||
gtk_tree_store_append (model, &iter, NULL);
|
|
||||||
gtk_tree_store_set (model, &iter, COLUMN_0, item_0->label, -1);
|
if (item_0->children) {
|
||||||
|
item_1 = item_0->children;
|
||||||
|
|
||||||
TreeItem *item_1 = item_0->children;
|
|
||||||
while (item_1->label) {
|
while (item_1->label) {
|
||||||
GtkTreeIter child_iter;
|
printf("[case item1 %s]\n",item_1->label);
|
||||||
iterate_node(model, item_0, item_1, iter, child_iter);
|
iterate_node(model, &iter_1, item_1, &iter_0);
|
||||||
gtk_tree_store_append (model, &child_iter, &iter);
|
|
||||||
gtk_tree_store_set (model, &child_iter, COLUMN_0, item_1->label, -1);
|
if (item_1->children) {
|
||||||
|
item_2 = item_1->children;
|
||||||
|
|
||||||
TreeItem *item_2 = item_1->children;
|
|
||||||
while (item_2->label) {
|
while (item_2->label) {
|
||||||
GtkTreeIter child_child_iter;
|
printf("[case item2 %s]\n",item_2->label);
|
||||||
iterate_node(model, item_1, item_2, child_iter, child_child_iter);
|
iterate_node(model, &iter_2, item_2, &iter_1);
|
||||||
gtk_tree_store_append (model, &child_child_iter, &child_iter);
|
|
||||||
gtk_tree_store_set (model, &child_child_iter, COLUMN_0, item_2->label, -1);
|
|
||||||
|
|
||||||
item_2++;
|
item_2++;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
item_1++;
|
item_1++;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
item_0++;
|
item_0++;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return GTK_TREE_MODEL (model);
|
return GTK_TREE_MODEL (model);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue