From 912f2e50448faa9a3a70908f1a24f1918c030926 Mon Sep 17 00:00:00 2001 From: Jean Sirmai Date: Sat, 20 Jan 2024 13:57:24 +0100 Subject: [PATCH] WIP: cleaning... cleaning... cleaning... --- src/main.c | 2 +- src/ui/sand_box.c | 55 +++++++++++++++++++++-------------------------- src/ui/window.c | 5 ----- 3 files changed, 26 insertions(+), 36 deletions(-) diff --git a/src/main.c b/src/main.c index 07d24b4..d18e236 100644 --- a/src/main.c +++ b/src/main.c @@ -65,7 +65,7 @@ int main(int argc, char **argv) G_APPLICATION_DEFAULT_FLAGS); g_signal_connect (app, "activate", G_CALLBACK (on_activate_window_creation), // in : "sand_box_2.c :" - "the signal comes from main.c and is displayed by sand_box_2 -> on_activate_window_creation()\n"); + "This signal comes from main.c and is displayed by the sand_box window\n"); // Jean 2024-01-20 Je désactive la visualisation de la fenêtre principale diff --git a/src/ui/sand_box.c b/src/ui/sand_box.c index d878fda..2c55751 100644 --- a/src/ui/sand_box.c +++ b/src/ui/sand_box.c @@ -29,9 +29,6 @@ #include "../../include/base.h" #include "../../include/ui.h" -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);} - static enum { NAME_COLUMN }; /* custom function to fill the model with data */ @@ -53,35 +50,34 @@ static GtkWidget populate_tree_model (my_store){ +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);} + void on_activate_window_creation (GtkApplication *app, gpointer data) { - GtkWidget *my_window_2; - GtkWidget *my_box_2; - GtkWidget *my_button_2; - char *my_window_title_2 = "I'm the second one !"; - char *my_button_title_2 = "Yep ! And... I'm the second button."; + GtkWidget *my_window; + GtkWidget *my_box; + GtkWidget *my_button; + char *my_window_title = "Hello folks !"; + char *my_button_title = "Yep ! I'm the button."; + + my_window = gtk_window_new (); + gtk_window_set_title (GTK_WINDOW(my_window), my_window_title); + gtk_window_set_default_size (GTK_WINDOW(my_window), 400, 34); + + my_box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0); + gtk_window_set_child(GTK_WINDOW(my_window), GTK_WIDGET(my_box)); + 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_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); - // Create a new window - // GtkWidget *window = gtk_application_window_new (app); - // gtk_init(); if (data) g_print (data); - my_window_2 = gtk_window_new (); - gtk_window_set_title (GTK_WINDOW(my_window_2), my_window_title_2); - gtk_window_set_default_size (GTK_WINDOW(my_window_2), 400, 34); - my_box_2 = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0); - gtk_window_set_child(GTK_WINDOW(my_window_2), GTK_WIDGET(my_box_2)); - gtk_widget_show (my_window_2); - - // Create a new button - my_button_2 = gtk_button_new_with_label (my_button_title_2); - // When the button is clicked, close the window passed as an argument - g_signal_connect(G_OBJECT (my_button_2), "clicked", G_CALLBACK(on_button_action), "some data from window 2\n"); - g_signal_connect_swapped (my_button_2, "clicked", G_CALLBACK (gtk_window_close), my_window_2); - g_signal_connect(G_OBJECT (my_window_2), "destroy", G_CALLBACK(on_destroy), "window 2 destruction ! (alone <> no exit(0) here)\n"); - - // gtk_window_set_child (GTK_WINDOW (my_window_2), my_button_2); // < écrase - gtk_box_append(GTK_BOX - (my_box_2), GTK_WIDGET(my_button_2)); -// gtk_window_present (GTK_WINDOW (my_window)); + 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"); } //------------------------------------------------------------------------------ @@ -103,7 +99,6 @@ void on_activate_window_creation (GtkApplication *app, gpointer data) { // https://www.typeerror.org/docs/gtk~4.0/gtksignallistitemfactory // https://docs.gtk.org/gtk4/section-list-widget.html < les listes old/new et la discussion // https://developer-old.gnome.org/gtk4/stable/GtkListView.html <<< copy that ! -// https://docs.gtk.org/gtk4/section-list-widget.html // https://docs.gtk.org/gtk4/ctor.TreeListModel.new.html *** // https://blog.gtk.org/2020/06/08/more-on-lists-in-gtk-4/ *** // diff --git a/src/ui/window.c b/src/ui/window.c index 8e6b5c4..943fcea 100644 --- a/src/ui/window.c +++ b/src/ui/window.c @@ -122,11 +122,6 @@ static void gem_graph_client_window_init(GemGraphClientWindow *self) // Setup GLArea //XXX TEMP ui_setup_glarea(window->run_glarea, window->run_controls); // - printf("--------------------------------------------------------------------------------------\n\ -from : gem_graph_client_window_init(GemGraphClientWindow *self) in window.c (line 124)\n\ -> widgets examples in user/jean/01/GTK4/tree (learning)/The_Gnome_way/demos/gtk-demo <\n\ ---------------------------------------------------------------------------------------\n"); - } /* Is this used to 'FREE' something and must be retained ? */