From 8891d5adfe641140822e94e2aab8b22ee11d43e5 Mon Sep 17 00:00:00 2001 From: Jean Sirmai Date: Fri, 15 Dec 2023 11:31:09 +0100 Subject: [PATCH] WIP: simplifications (TreeItem notation) 57-60 --- demos/gtk-demo/tree_store.c | 33 ++++++++------------------------- 1 file changed, 8 insertions(+), 25 deletions(-) diff --git a/demos/gtk-demo/tree_store.c b/demos/gtk-demo/tree_store.c index 4d8759f..a7c22f2 100644 --- a/demos/gtk-demo/tree_store.c +++ b/demos/gtk-demo/tree_store.c @@ -49,32 +49,15 @@ struct _TreeItem enum { COLUMN_0, -// COLUMN_1, + COLUMN_1, NUM_COLUMNS }; /* tree data */ -static TreeItem item_name_0[] = -{ - { "C", NULL }, - { "D", NULL }, - { NULL } -}; - -static TreeItem item_name_1[] = -{ - { "E", NULL }, - { "F", NULL }, - { "G", NULL }, - { NULL } -}; - -static TreeItem root[] = -{ - { "A", item_name_0 }, - { "B", item_name_1 }, - { NULL } -}; +static TreeItem C[] = {{ "H", NULL }, { NULL }}; +static TreeItem A[] = {{ "C", C }, { "D", NULL }, { NULL }}; +static TreeItem B[] = {{ "E", NULL }, { "F", NULL }, { "G", NULL }, { NULL }}; +static TreeItem R[] = {{ "A", A }, { "B", B }, { NULL }}; static GtkTreeModel * @@ -82,7 +65,7 @@ create_model (void) { GtkTreeStore *model; GtkTreeIter iter; - TreeItem *item_0 = root; + TreeItem *item_0 = R; /* create tree store */ model = gtk_tree_store_new (NUM_COLUMNS, @@ -97,7 +80,7 @@ create_model (void) gtk_tree_store_append (model, &iter, NULL); gtk_tree_store_set (model, &iter, COLUMN_0, item_0->label, -// COLUMN_1, FALSE, + COLUMN_1, item_1->label, -1); /* add children */ @@ -108,7 +91,7 @@ create_model (void) gtk_tree_store_append (model, &child_iter, &iter); gtk_tree_store_set (model, &child_iter, COLUMN_0, item_1->label, -// COLUMN_1, item_1->label, // AA, + COLUMN_1, item_1->label, -1); item_1++;