From 7efd6ee7959dadd1acd6dcac22e386b331b9f6dd Mon Sep 17 00:00:00 2001 From: Jean Sirmai Date: Sat, 16 Dec 2023 09:12:06 +0100 Subject: [PATCH] =?UTF-8?q?WIP:=20Is=20a=20more=20symetrical=20iteration?= =?UTF-8?q?=20possible=20=3F=20line=2092=20GtkTreeIter=20*=C2=A0/=20GtkTre?= =?UTF-8?q?eStore=20*?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- demos/gtk-demo/tree_store.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/demos/gtk-demo/tree_store.c b/demos/gtk-demo/tree_store.c index 4b6e257..67d81bf 100644 --- a/demos/gtk-demo/tree_store.c +++ b/demos/gtk-demo/tree_store.c @@ -70,9 +70,11 @@ static TreeItem R[] = {{ "A", A }, { "B", B }, { NULL }}; static TreeItem O[] = {{ "R", R }, { NULL }}; // Artefact added for symetry static GtkTreeModel * -iterate_node(GtkTreeStore *model, TreeItem *parent, TreeItem *children) +iterate_node(GtkTreeStore *model, + TreeItem *item_parent, TreeItem *item_children, + GtkTreeIter *iter_parent, GtkTreeIter *iter_children) { - printf("parent, children : %s, %s\n", parent->label, children->label); + printf("parent, children : %s -> %s\n", item_parent->label, item_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); @@ -85,22 +87,22 @@ create_model (void) TreeItem *item_0 = O->children; while (item_0->label) { - iterate_node(model, O, item_0); GtkTreeIter iter; + iterate_node(model, O, item_0, model, &iter); gtk_tree_store_append (model, &iter, NULL); gtk_tree_store_set (model, &iter, COLUMN_0, item_0->label, -1); TreeItem *item_1 = item_0->children; while (item_1->label) { - iterate_node(model, item_0, item_1); GtkTreeIter child_iter; + iterate_node(model, item_0, item_1, &iter, &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) { - iterate_node(model, item_1, item_2); GtkTreeIter child_child_iter; + iterate_node(model, item_1, item_2, &child_iter, &child_child_iter); gtk_tree_store_append (model, &child_child_iter, &child_iter); gtk_tree_store_set (model, &child_child_iter, COLUMN_0, item_2->label, -1);