From 11c893d2c7fe2cb0a70ae2e637d088a6188e58db Mon Sep 17 00:00:00 2001 From: Jean Sirmai Date: Fri, 15 Dec 2023 22:52:41 +0100 Subject: [PATCH] =?UTF-8?q?PROFONDEUR=20DE=20L'ARBRE=20(1=C3=A8re=20fois)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- demos/gtk-demo/tree_store.c | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/demos/gtk-demo/tree_store.c b/demos/gtk-demo/tree_store.c index 0eea0c6..7837b6e 100644 --- a/demos/gtk-demo/tree_store.c +++ b/demos/gtk-demo/tree_store.c @@ -59,7 +59,6 @@ static TreeItem B[] = {{ "E", NULL }, { "F", NULL }, { "G", NULL }, { NULL }}; static TreeItem A[] = {{ "C", C }, { "D", D }, { NULL }}; static TreeItem R[] = {{ "A", A }, { "B", B }, { NULL }}; - static GtkTreeModel * create_model (void) { @@ -68,8 +67,7 @@ create_model (void) TreeItem *item_0 = R; /* create tree store */ - model = gtk_tree_store_new (NUM_COLUMNS, - G_TYPE_STRING); + model = gtk_tree_store_new (NUM_COLUMNS, G_TYPE_STRING); /* add data to the tree store */ while (item_0->label) @@ -77,9 +75,7 @@ create_model (void) TreeItem *item_1 = item_0->children; gtk_tree_store_append (model, &iter, NULL); - gtk_tree_store_set (model, &iter, - COLUMN_0, item_0->label, - -1); + gtk_tree_store_set (model, &iter, COLUMN_0, item_0->label, -1); /* add children */ while (item_1->label) @@ -87,9 +83,18 @@ create_model (void) GtkTreeIter child_iter; gtk_tree_store_append (model, &child_iter, &iter); - gtk_tree_store_set (model, &child_iter, - COLUMN_0, item_1->label, - -1); + gtk_tree_store_set (model, &child_iter, COLUMN_0, item_1->label, -1); + + TreeItem *item_2 = item_1->children; + if (item_1->children) + while (item_2->label) { + //printf("while (item_1->label) item_1->label = %s item_2->label = %s\n", item_1->label, item_2->label); + GtkTreeIter 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); + + item_2++; + } item_1++; } @@ -166,7 +171,7 @@ do_tree_store (GtkWidget *do_widget) /* expand all rows after the treeview widget has been realized */ g_signal_connect (treeview, "realize", G_CALLBACK (gtk_tree_view_expand_all), NULL); - gtk_window_set_default_size (GTK_WINDOW (window), 200, 250); + gtk_window_set_default_size (GTK_WINDOW (window), 200, 330); } if (!gtk_widget_get_visible (window))