diff --git a/src/ui/tree.c b/src/ui/tree.c index dbc37de..9689778 100644 --- a/src/ui/tree.c +++ b/src/ui/tree.c @@ -52,15 +52,18 @@ static TreeItem A[] = {{"D", D}, {NULL}}, B[] = {{"E", E}, {NULL}}; static TreeItem R[] = {{"A", A}, {"B", B}, {"C", C}, {NULL}}; static TreeItem O[] = {{"ROOT", R}, {NULL}}; // Artefact added for symmetry +static GtkWidget *my_tree_view; // = NULL; +static GListStore *my_list_model = NULL; + static void add_item (GtkWidget *button, gpointer data) { TreeItem foo; - GtkTreeIter current, iter; + GtkTreeView *treeview = my_tree_view; // (GtkTreeView *)data; + GtkTreeModel *model = my_list_model; // gtk_tree_view_get_model (treeview); GtkTreePath *path; - GtkTreeModel *model; GtkTreeViewColumn *column; - GtkTreeView *treeview = NULL; // (GtkTreeView *)data; + GtkTreeIter current, iter; } static void @@ -68,10 +71,10 @@ remove_item (GtkWidget *widget, gpointer data) { printf("From 'tree.c' (line 130), remove item() > no item selected (or can't get it ?)\n"); + GtkTreeView *treeview = my_tree_view; // (GtkTreeView *)data; + GtkTreeModel *model = my_list_model; // gtk_tree_view_get_model (treeview); + GtkTreeSelection *selection = gtk_tree_view_get_selection (treeview); GtkTreeIter iter; - GtkTreeView *treeview = NULL; // (GtkTreeView *)data; - GtkTreeModel *model = NULL; // gtk_tree_view_get_model (treeview); - GtkTreeSelection *selection = NULL; // gtk_tree_view_get_selection (treeview); } static void @@ -80,7 +83,7 @@ cell_edited (GtkCellRendererText *cell, const char *new_text, gpointer data) { - GtkTreeModel *model = (GtkTreeModel *)data; + GtkTreeModel *model = my_list_model; // gtk_tree_view_get_model (treeview); GtkTreePath *path = gtk_tree_path_new_from_string (path_string); GtkTreeIter iter; } @@ -118,13 +121,12 @@ static GListStore *create_node_recursive (GListStore *model, GtkWidget *create_my_tree_model(GtkBox *runlib_objects) { - GListStore *my_list_model = NULL; GtkWidget *my_scrolled_window = NULL; - GtkWidget *my_tree_view = NULL; GtkCellRenderer *my_renderer = NULL; my_list_model = create_node_recursive (my_list_model, O, NULL, 0); my_tree_view = gtk_tree_view_new_with_model (my_list_model); + gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (my_tree_view), FALSE); gtk_tree_view_set_enable_tree_lines (GTK_TREE_VIEW (my_tree_view), TRUE); gtk_widget_set_vexpand (my_tree_view, TRUE); @@ -161,7 +163,7 @@ print_hello (GtkWidget *widget, { static int nb; nb++; - printf("From 'tree.c', > button clicked (n = %d)\n", nb); + printf("From 'tree.c', > %s added and button clicked (n = %d)\n", data, nb); } GtkWidget *create_my_button_test(GtkBox *runlib_objects) @@ -173,7 +175,7 @@ GtkWidget *create_my_button_test(GtkBox *runlib_objects) gtk_box_append(runlib_objects, button); gtk_widget_show(button); - g_signal_connect (button, "clicked", G_CALLBACK (print_hello), NULL); + g_signal_connect (button, "clicked", G_CALLBACK (print_hello), "some data"); return button; }