WIP: (micro) before creating a new function to iterate a node

This commit is contained in:
Jean Sirmai 2023-12-15 23:11:47 +01:00
parent 11c893d2c7
commit 9d5a1ed25a
Signed by: jean
GPG Key ID: FB3115C340E057E3
1 changed files with 11 additions and 8 deletions

View File

@ -53,9 +53,16 @@ enum
}; };
/* tree data */ /* tree data */
static TreeItem D[] = {{ "I", NULL }, { "J", NULL }, { "K", NULL }, { NULL }}; static TreeItem K[] = { NULL };
static TreeItem C[] = {{ "H", NULL }, { NULL }}; static TreeItem J[] = { NULL };
static TreeItem B[] = {{ "E", NULL }, { "F", NULL }, { "G", NULL }, { NULL }}; static TreeItem I[] = { NULL };
static TreeItem H[] = { NULL };
static TreeItem G[] = { NULL };
static TreeItem F[] = { NULL };
static TreeItem E[] = { NULL };
static TreeItem D[] = {{ "I", I }, { "J", J }, { "K", K }, { NULL }};
static TreeItem C[] = {{ "H", H }, { NULL }};
static TreeItem B[] = {{ "E", E }, { "F", F }, { "G", G }, { NULL }};
static TreeItem A[] = {{ "C", C }, { "D", D }, { NULL }}; static TreeItem A[] = {{ "C", C }, { "D", D }, { NULL }};
static TreeItem R[] = {{ "A", A }, { "B", B }, { NULL }}; static TreeItem R[] = {{ "A", A }, { "B", B }, { NULL }};
@ -66,10 +73,8 @@ create_model (void)
GtkTreeIter iter; GtkTreeIter iter;
TreeItem *item_0 = R; 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) while (item_0->label)
{ {
TreeItem *item_1 = item_0->children; TreeItem *item_1 = item_0->children;
@ -77,7 +82,6 @@ create_model (void)
gtk_tree_store_append (model, &iter, NULL); 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) while (item_1->label)
{ {
GtkTreeIter child_iter; GtkTreeIter child_iter;
@ -86,9 +90,7 @@ create_model (void)
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; TreeItem *item_2 = item_1->children;
if (item_1->children)
while (item_2->label) { 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; GtkTreeIter child_child_iter;
gtk_tree_store_append (model, &child_child_iter, &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); gtk_tree_store_set (model, &child_child_iter, COLUMN_0, item_2->label, -1);
@ -114,6 +116,7 @@ add_columns (GtkTreeView *treeview)
gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (treeview), -1, gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (treeview), -1,
"Col 0", renderer, "text", COLUMN_0, NULL); "Col 0", renderer, "text", COLUMN_0, NULL);
/* WE DON'T NEED A SECOND COLUMN UNTILL WE WANT TO REPRESENT LEAVES */
/* renderer = gtk_cell_renderer_text_new (); g_object_set (renderer, "xalign", 0.0, NULL); */ /* renderer = gtk_cell_renderer_text_new (); g_object_set (renderer, "xalign", 0.0, NULL); */
/* gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (treeview), -1, */ /* gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (treeview), -1, */
/* "Col 1", renderer, "text", COLUMN_1, NULL); */ /* "Col 1", renderer, "text", COLUMN_1, NULL); */