From cc899e13c9fa70bd2692dfa4f1f829d93cb2c447 Mon Sep 17 00:00:00 2001 From: Jean Sirmai Date: Thu, 14 Dec 2023 12:15:49 +0100 Subject: [PATCH] WIP: before removing item_toggled() --- demos/gtk-demo/tree_store.c | 46 +++++++++++++------------------------ 1 file changed, 16 insertions(+), 30 deletions(-) diff --git a/demos/gtk-demo/tree_store.c b/demos/gtk-demo/tree_store.c index 6383ab7..944bc2c 100644 --- a/demos/gtk-demo/tree_store.c +++ b/demos/gtk-demo/tree_store.c @@ -32,7 +32,6 @@ struct _TreeItem { const char *label; gboolean AA; - gboolean BB; gboolean CC; TreeItem *children; }; @@ -42,7 +41,6 @@ enum { COLUMN_0, COLUMN_1, - COLUMN_2, VISIBLE_COLUMN, WORLD_COLUMN, @@ -52,33 +50,33 @@ enum /* tree data */ static TreeItem item_name_0[] = { - { "A", TRUE, TRUE, TRUE, NULL }, - { "B", FALSE, TRUE, FALSE, NULL }, - { "C", FALSE, TRUE, FALSE, NULL }, + { "A", TRUE, TRUE, NULL }, + { "B", FALSE, TRUE, NULL }, + { "C", FALSE, TRUE, NULL }, { NULL } }; static TreeItem item_name_1[] = { - { "A", FALSE, TRUE, FALSE, NULL }, - { "B", FALSE, FALSE, FALSE, NULL }, - { "C", FALSE, FALSE, TRUE, NULL }, - { "D", FALSE, TRUE, TRUE, NULL }, + { "A", FALSE, TRUE, NULL }, + { "B", FALSE, FALSE, NULL }, + { "C", FALSE, TRUE, NULL }, + { "D", FALSE, TRUE, NULL }, { NULL } }; static TreeItem item_name_2[] = { - { "A", FALSE, FALSE, FALSE, NULL }, - { "B", FALSE, FALSE, TRUE, NULL }, + { "A", FALSE, FALSE, NULL }, + { "B", FALSE, TRUE, NULL }, { NULL } }; -static TreeItem toplevel[] = +static TreeItem root[] = { - { "IT-0", FALSE, FALSE, FALSE, item_name_0 }, - { "IT-1", FALSE, FALSE, FALSE, item_name_1 }, - { "IT-2", FALSE, FALSE, FALSE, item_name_2 }, + { "IT-0", FALSE, FALSE, item_name_0 }, + { "IT-1", FALSE, FALSE, item_name_1 }, + { "IT-2", FALSE, FALSE, item_name_2 }, { NULL } }; @@ -88,7 +86,7 @@ create_model (void) { GtkTreeStore *model; GtkTreeIter iter; - TreeItem *item_0 = toplevel; + TreeItem *item_0 = root; /* create tree store */ model = gtk_tree_store_new (NUM_COLUMNS, @@ -107,7 +105,6 @@ create_model (void) gtk_tree_store_set (model, &iter, COLUMN_0, item_0->label, COLUMN_1, FALSE, - COLUMN_2, FALSE, VISIBLE_COLUMN, FALSE, WORLD_COLUMN, FALSE, -1); @@ -121,7 +118,6 @@ create_model (void) gtk_tree_store_set (model, &child_iter, COLUMN_0, item_1->label, COLUMN_1, item_1->AA, - COLUMN_2, item_1->BB, VISIBLE_COLUMN, TRUE, WORLD_COLUMN, item_1->CC, -1); @@ -135,7 +131,7 @@ create_model (void) return GTK_TREE_MODEL (model); } -static void +static void // https://www.gnu.org/software/guile-gnome/docs/gtk/html/GtkCellRendererToggle.html item_toggled (GtkCellRendererToggle *cell, char *path_str, gpointer data) @@ -186,7 +182,7 @@ add_columns (GtkTreeView *treeview) g_object_set (renderer, "xalign", 0.0, NULL); g_object_set_data (G_OBJECT (renderer), "column", (int *)COLUMN_1); - g_signal_connect (renderer, "toggled", G_CALLBACK (item_toggled), model); + // g_signal_connect (renderer, "toggled", G_CALLBACK (item_toggled), model); col_offset = gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (treeview), -1, "Col 1", renderer, "active", COLUMN_1, "visible", VISIBLE_COLUMN, "activatable", WORLD_COLUMN, NULL); @@ -195,16 +191,6 @@ add_columns (GtkTreeView *treeview) // gtk_tree_view_column_set_sizing (GTK_TREE_VIEW_COLUMN (column), GTK_TREE_VIEW_COLUMN_FIXED); // gtk_tree_view_column_set_clickable (GTK_TREE_VIEW_COLUMN (column), TRUE); - /* BB column */ - renderer = gtk_cell_renderer_toggle_new (); - g_object_set (renderer, "xalign", 0.0, NULL); - g_object_set_data (G_OBJECT (renderer), "column", (int *)COLUMN_2); - - g_signal_connect (renderer, "toggled", G_CALLBACK (item_toggled), model); - - col_offset = gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (treeview), -1, "Col 2", renderer, "active", - COLUMN_2, "visible", VISIBLE_COLUMN, NULL); - /* column = */ gtk_tree_view_get_column (GTK_TREE_VIEW (treeview), col_offset - 1); // gtk_tree_view_column_set_sizing (GTK_TREE_VIEW_COLUMN (column), GTK_TREE_VIEW_COLUMN_FIXED); // gtk_tree_view_column_set_clickable (GTK_TREE_VIEW_COLUMN (column), TRUE);