From c22187af450d96ae867789e28219e8d3b7690732 Mon Sep 17 00:00:00 2001 From: Jean Sirmai Date: Sat, 20 Jan 2024 18:31:50 +0100 Subject: [PATCH] WIP: cleaning... cleaning... cleaning... --- src/main.c | 10 +++------- src/ui/sand_box.c | 41 +++++++++++------------------------------ 2 files changed, 14 insertions(+), 37 deletions(-) diff --git a/src/main.c b/src/main.c index d18e236..18d9b51 100644 --- a/src/main.c +++ b/src/main.c @@ -64,15 +64,11 @@ int main(int argc, char **argv) app = gem_graph_client_application_new("org.alec.gemgraph", G_APPLICATION_DEFAULT_FLAGS); - g_signal_connect (app, "activate", G_CALLBACK (on_activate_window_creation), // in : "sand_box_2.c :" - "This signal comes from main.c and is displayed by the sand_box window\n"); - + g_signal_connect (app, "activate", G_CALLBACK (on_activate_window_creation), + "This signal comes from main.c"); // Jean 2024-01-20 Je désactive la visualisation de la fenêtre principale - // pour travailler dans une fenêtre minimale (cf. sand_box) - // - // gtk_window_present(window); < cf. application.c ligne 122 - + // pour ne travailler que dans la fenêtre de sand_box.c res = g_application_run(G_APPLICATION(app), argc, argv); return res; diff --git a/src/ui/sand_box.c b/src/ui/sand_box.c index 2c55751..6c8ee14 100644 --- a/src/ui/sand_box.c +++ b/src/ui/sand_box.c @@ -25,33 +25,12 @@ #include #include #include - #include "../../include/base.h" #include "../../include/ui.h" -static enum { NAME_COLUMN }; - - /* custom function to fill the model with data */ -static GtkWidget populate_tree_model (my_store){ - GtkWidget *my_tree; - GtkTreeViewColumn *my_column; - GtkCellRenderer *my_renderer; - - GtkTreeIter my_iter_1, my_iter_2; - gtk_tree_store_append (my_store, &my_iter_1, NULL); // Acquire an iterator - gtk_tree_store_set (my_store, &my_iter_1, NAME_COLUMN, "value A", -1); - gtk_tree_store_append (my_store, &my_iter_2, &my_iter_1); // Acquire a child iterator - gtk_tree_store_set (my_store, &my_iter_2, NAME_COLUMN, "value B", -1); - my_column = gtk_tree_view_column_new_with_attributes ("names", my_renderer, "text", NAME_COLUMN, NULL); - gtk_tree_view_append_column (GTK_TREE_VIEW (my_tree), my_column); - - return *my_tree; -}; - - - -static void on_button_action (GtkWidget *widget, gpointer data) {if (data) g_print (data);} -static void on_destroy (GtkWidget *widget, gpointer data) { if (data) g_print (data); exit(0);} +int n = 0; +static void on_button_action (GtkWidget *widget, gpointer data){n++; g_print (data, n);} +static void on_destroy (GtkWidget *widget, gpointer data) {if (data) g_print (data); exit(0);} void on_activate_window_creation (GtkApplication *app, gpointer data) { GtkWidget *my_window; @@ -69,21 +48,22 @@ void on_activate_window_creation (GtkApplication *app, gpointer data) { gtk_widget_show (my_window); // show != present my_button = gtk_button_new_with_label (my_button_title); - g_signal_connect(G_OBJECT (my_button), "clicked", G_CALLBACK(on_button_action), "button clicked (could use some data)\n"); -// g_signal_connect_swapped (my_button, "clicked", G_CALLBACK (gtk_window_close), my_window); + g_signal_connect(G_OBJECT (my_button), "clicked", G_CALLBACK(on_button_action), "button clicked (n = %d)\n"); +// g_signal_connect_swapped (my_button, "clicked", G_CALLBACK (gtk_window_close), my_window); // < Then my_button closes my_window g_signal_connect(G_OBJECT (my_window), "destroy", G_CALLBACK(on_destroy), "closes window using exit(0)\n"); - gtk_box_append(GTK_BOX (my_box), GTK_WIDGET(my_button)); // gtk_window_set_child (GTK_WINDOW (my_window), my_button); + gtk_box_append(GTK_BOX (my_box), GTK_WIDGET(my_button)); // else : gtk_window_set_child (GTK_WINDOW (my_window), my_button); - if (data) g_print (data); + if (data) {g_print (data); g_print (" and is displayed by [on_activate_window_creation()] in the sand_box window.\n");} printf("-------------------------------------------------------------------------------------------------------------------------------------------\n\ [sand_box.c > on_activate_window_creation()] > widgets examples are in user/jean/01/GTK4/tree (learning)/The_Gnome_way/demos/gtk-demo <\n"); } //------------------------------------------------------------------------------ -// guix shell -m manifest.scm make clean && clear && time make run -// GOBJECT_DEBUG=instance_count GIO Gnome Input Output +// guix shell -m manifest.scm && pkg-config --libs gtk4 +// make clean && clear && time make run +// GOBJECT_DEBUG=instance_count GIO = Gnome Input Output // https://docs.gtk.org/ // https://docs.gtk.org/gtk4/ @@ -109,3 +89,4 @@ void on_activate_window_creation (GtkApplication *app, gpointer data) { // // +