PROFONDEUR DE L'ARBRE (1ère fois)

This commit is contained in:
Jean Sirmai 2023-12-15 22:52:41 +01:00
parent cdc891823f
commit 11c893d2c7
Signed by: jean
GPG Key ID: FB3115C340E057E3
1 changed files with 15 additions and 10 deletions

View File

@ -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))