From 5743a83b0cf2b8340be4dca2dc808617676f7700 Mon Sep 17 00:00:00 2001 From: Jean Sirmai Date: Wed, 10 Jan 2024 12:49:21 +0100 Subject: [PATCH] WIP: importing a 'remove_item() function in tree.c --- src/ui/tree.c | 29 +++++++++++++++++++++++++++-- src/ui/window.c | 2 +- 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/src/ui/tree.c b/src/ui/tree.c index a770d3e..8512e92 100644 --- a/src/ui/tree.c +++ b/src/ui/tree.c @@ -124,6 +124,31 @@ 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) @@ -136,13 +161,13 @@ print_hello (GtkWidget *widget, GtkWidget *create_my_button_test(GtkBox *runlib_objects) { GtkWidget *button; - const char *text = "Hello ! I'm the new button. Click me !"; + const char *text = "Remove the Selected Item"; button = gtk_button_new_with_label(text); 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 (remove_item), NULL); return button; } diff --git a/src/ui/window.c b/src/ui/window.c index cd9cf5a..1358939 100644 --- a/src/ui/window.c +++ b/src/ui/window.c @@ -152,7 +152,7 @@ void ui_set_stack(const char *mode) case 'r': gtk_menu_button_set_icon_name(window->main_button_mode, "system-run-symbolic"); if (! my_tree) my_tree = create_my_tree_model(window->runlib_objects); // in tree.c - // if (! my_button) my_button = create_my_button_test(window->runlib_objects); // in tree.c + if (! my_button) my_button = create_my_button_test(window->runlib_objects); // in tree.c // if (! my_list) my_list = create_my_list_view_test(window->runlib_objects); // in "bac-a-sable.c" // if (! my_editable_cells) my_editable_cells = create_my_editable_cells(window->runlib_objects); // in editable_cell.c break;