From 1d1b1fa74453fb624e19e99b34c11391839386f4 Mon Sep 17 00:00:00 2001 From: Jean Sirmai Date: Sat, 16 Dec 2023 08:30:28 +0100 Subject: [PATCH] WIP: preparing the recursive loop that builds the tree (0) --- demos/gtk-demo/tree_store.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/demos/gtk-demo/tree_store.c b/demos/gtk-demo/tree_store.c index 34e8dee..bf8eb5e 100644 --- a/demos/gtk-demo/tree_store.c +++ b/demos/gtk-demo/tree_store.c @@ -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) { + 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);