From 48ef1448ebda8f1fa56366642033c7c0699f5059 Mon Sep 17 00:00:00 2001 From: Jean Sirmai Date: Wed, 29 Nov 2023 20:24:38 +0100 Subject: [PATCH] =?UTF-8?q?WIP:=20(1)=20=C3=A0=20commenter.=20(2)=20rempla?= =?UTF-8?q?cer=20le=20bouton=20par=20un=20arbre.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/ui/tree.c | 29 ++++++++++++++++++++++++----- src/ui/window.c | 10 ++++++---- 2 files changed, 30 insertions(+), 9 deletions(-) diff --git a/src/ui/tree.c b/src/ui/tree.c index 5a1224d..1aea984 100644 --- a/src/ui/tree.c +++ b/src/ui/tree.c @@ -53,6 +53,16 @@ create_and_fill_model (void) /* Append a top level row and leave it empty */ gtk_tree_store_append(treestore, &toplevel, NULL); + gtk_tree_store_set(treestore, &toplevel, + COL_FIRST_NAME, "RanTanPlan", + COL_LAST_NAME, "(dog)", + -1); + + gtk_tree_store_append(treestore, &toplevel, NULL); + gtk_tree_store_set(treestore, &toplevel, + COL_FIRST_NAME, "Ma", + COL_LAST_NAME, "Dalton", + -1); /* Append a second top level row, and fill it with some data */ gtk_tree_store_append(treestore, &toplevel, NULL); @@ -61,6 +71,18 @@ create_and_fill_model (void) COL_LAST_NAME, "Dalton", -1); + gtk_tree_store_append(treestore, &toplevel, NULL); + gtk_tree_store_set(treestore, &toplevel, + COL_FIRST_NAME, "Jack", + COL_LAST_NAME, "Dalton", + -1); + + gtk_tree_store_append(treestore, &toplevel, NULL); + gtk_tree_store_set(treestore, &toplevel, + COL_FIRST_NAME, "William", + COL_LAST_NAME, "Dalton", + -1); + /* Append a child to the second top level row, and fill in some data */ gtk_tree_store_append(treestore, &child, &toplevel); gtk_tree_store_set(treestore, &child, @@ -176,11 +198,8 @@ tree_c_test(void) static void tree_c_printing_test(void) { printf("tree.c tree_c_printing_test() \ -------------------------------------\n\ -A button is now in the GtkBox *runlib_objects of windows.c (line 61)\n\ - How to associate an action to it\n\ - ?\n\ -"); +-------------------------------\n\ +A button is now in the GtkBox and an action is associated to it.\n\n"); } /* diff --git a/src/ui/window.c b/src/ui/window.c index 107a698..0dca17b 100644 --- a/src/ui/window.c +++ b/src/ui/window.c @@ -124,7 +124,6 @@ void ui_set_stack(const char *mode) break; case 'r': gtk_menu_button_set_icon_name(window->main_button_mode, "system-run-symbolic"); -// create_tree_label(); create_tree_button(); break; case 'p': @@ -243,14 +242,17 @@ GtkWidget *create_tree_label(void) return label; } + + #include static void print_hello (GtkWidget *widget, gpointer data) { - printf("Yes. I'm the new button <-> I've been clicked !!!\n"); -// return GDK_EVENT_STOP; + static int nb; + nb++; + printf("Button clicked (n = %d)\n", nb); } GtkWidget *create_tree_button(void) @@ -263,10 +265,10 @@ GtkWidget *create_tree_button(void) gtk_widget_show(button); g_signal_connect (button, "clicked", G_CALLBACK (print_hello), NULL); - //g_signal_connect_swapped (button, "clicked", G_CALLBACK (gtk_window_destroy), window); tree_c_test(); return button; } +/* https://docs.gtk.org/gtk4/getting_started.html */