From 5e870ae87084e357b07b47ef4bfd0a9b66d08d2a Mon Sep 17 00:00:00 2001 From: Jean Sirmai Date: Mon, 18 Dec 2023 09:38:59 +0100 Subject: [PATCH] WIP: TreeItem create_node_recursive (GtkTreeStore *model, TreeItem *current_item) {...} --- demos/gtk-demo/tree_store.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/demos/gtk-demo/tree_store.c b/demos/gtk-demo/tree_store.c index 5b113a4..e41d540 100644 --- a/demos/gtk-demo/tree_store.c +++ b/demos/gtk-demo/tree_store.c @@ -89,7 +89,7 @@ static TreeItem A[] = {{ "C", C }, { "D", D }, { NULL }}; static TreeItem R[] = {{ "A", A }, { "B", B }, { NULL }}; // ROOT static TreeItem O[] = {{ "R", R }, { NULL }}; // Artefact added for symmetry -static void create_node(GtkTreeStore *model, +static void create_node (GtkTreeStore *model, GtkTreeIter *iter_children, TreeItem *item_children, GtkTreeIter *iter_parent) @@ -98,6 +98,24 @@ static void create_node(GtkTreeStore *model, gtk_tree_store_set (model, iter_children, COLUMN_0, item_children->label, -1); } +static TreeItem create_node_recursive (GtkTreeStore *model, TreeItem *current_item) +{ + TreeItem *item_children; + GtkTreeIter iter_children, iter_parent; + + if (current_item->children) { + item_children = current_item->children; + + while (item_children->label) { + gtk_tree_store_append (model, &iter_children, &iter_parent); + gtk_tree_store_set (model, &iter_children, COLUMN_0, item_children->label, -1); + item_children++; + create_node_recursive (model, item_children); + } + } + return *item_children; +} + static GtkTreeModel * create_model (void) {