WIP: preparing add & remove item in tree

This commit is contained in:
Jean Sirmai 2024-01-10 17:29:23 +01:00
parent 5743a83b0c
commit 9c4f2ef3ef
Signed by: jean
GPG Key ID: FB3115C340E057E3
1 changed files with 36 additions and 30 deletions

View File

@ -52,6 +52,39 @@ 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 void
add_item (GtkWidget *button, gpointer data)
{
TreeItem foo;
GtkTreeIter current, iter;
GtkTreePath *path;
GtkTreeModel *model;
GtkTreeViewColumn *column;
GtkTreeView *treeview = NULL; // (GtkTreeView *)data;
}
static void
remove_item (GtkWidget *widget, gpointer data)
{
printf("From 'tree.c' (line 130), remove item() > no item selected (or can't get it ?)\n");
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
cell_edited (GtkCellRendererText *cell,
const char *path_string,
const char *new_text,
gpointer data)
{
GtkTreeModel *model = (GtkTreeModel *)data;
GtkTreePath *path = gtk_tree_path_new_from_string (path_string);
GtkTreeIter iter;
}
// TODO GtkTreeListModel ? GtkTreeModel ? (lines 238 & 270)
static GListStore *create_node_recursive (GListStore *model,
// ? GListStore* g_list_store_new (GType item_type)
@ -86,7 +119,6 @@ static GListStore *create_node_recursive (GListStore *model,
GtkWidget *create_my_tree_model(GtkBox *runlib_objects)
{
GListStore *my_list_model = NULL;
GtkWidget *my_tree_box = NULL;
GtkWidget *my_scrolled_window = NULL;
GtkWidget *my_tree_view = NULL;
GtkCellRenderer *my_renderer = NULL;
@ -108,10 +140,9 @@ GtkWidget *create_my_tree_model(GtkBox *runlib_objects)
my_scrolled_window = gtk_scrolled_window_new ();
gtk_scrolled_window_set_has_frame (GTK_SCROLLED_WINDOW (my_scrolled_window), TRUE);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (my_scrolled_window),
GTK_POLICY_AUTOMATIC,
GTK_POLICY_AUTOMATIC);
GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
gtk_box_append (runlib_objects, my_scrolled_window);
gtk_widget_show(my_tree_box);
gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (my_scrolled_window), my_tree_view);
@ -124,31 +155,6 @@ GtkWidget *create_my_tree_model(GtkBox *runlib_objects)
//------------------------------------------------------------------------------
static void
remove_item (GtkWidget *widget, gpointer data)
{
printf("From 'tree.c', remove_item (line 130) > no item selected (or maybe I can't get it ?)\n");
/* GtkTreeIter iter; */
/* GtkTreeView *treeview = (GtkTreeView *)data; */
/* GtkTreeModel *model = gtk_tree_view_get_model (treeview); */
/* GtkTreeSelection *selection = gtk_tree_view_get_selection (treeview); */
/* if (gtk_tree_selection_get_selected (selection, NULL, &iter)) */
/* { */
/* int i; */
/* GtkTreePath *path; */
/* path = gtk_tree_model_get_path (model, &iter); */
/* i = gtk_tree_path_get_indices (path)[0]; */
/* gtk_list_store_remove (GTK_LIST_STORE (model), &iter); */
/* // g_array_remove_index (articles, i); */
/* gtk_tree_path_free (path); */
/* } */
}
static void
print_hello (GtkWidget *widget,
gpointer data)
@ -167,7 +173,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 (remove_item), NULL);
g_signal_connect (button, "clicked", G_CALLBACK (print_hello), NULL);
return button;
}