From 05230b7a64bee2ce24f7d88c910bb39970b5f944 Mon Sep 17 00:00:00 2001 From: Jean Sirmai Date: Sun, 21 Jan 2024 00:04:39 +0100 Subject: [PATCH] WIP: GtkStringList *my_string_list = gtk_string_list_new ((const char * const *) array); --- src/main.c | 1 + src/ui/application.c | 2 +- src/ui/sand_box.c | 59 ++++++++++++++++++++++++++++++++------------ 3 files changed, 45 insertions(+), 17 deletions(-) diff --git a/src/main.c b/src/main.c index 92a75e3..1de10a4 100644 --- a/src/main.c +++ b/src/main.c @@ -72,6 +72,7 @@ int main(int argc, char **argv) "This signal comes from main.c"); // Jean 2024-01-20 Je désactive la visualisation de la fenêtre principale + // dans : application.c > gem_graph_client_application_activate() // pour ne travailler que dans la fenêtre de sand_box.c res = g_application_run(G_APPLICATION(app), argc, argv); diff --git a/src/ui/application.c b/src/ui/application.c index dd33b11..8ad585a 100644 --- a/src/ui/application.c +++ b/src/ui/application.c @@ -119,7 +119,7 @@ static void gem_graph_client_application_activate(GApplication *app) // Jean 2024-01-20 Je désactive la visualisation de cette fenêtre // pour travailler dans une fenêtre minimale (cf. sand_box) // - gtk_window_present(window); + // gtk_window_present(window); } /* diff --git a/src/ui/sand_box.c b/src/ui/sand_box.c index 07e4a01..9545e96 100644 --- a/src/ui/sand_box.c +++ b/src/ui/sand_box.c @@ -28,24 +28,49 @@ #include "../../include/base.h" #include "../../include/ui.h" -static void just_use_gtk_application_window_new() -{ - GtkApplication *app = gtk_application_new ("org.gtk.test", 0); - GtkWidget *that_window = gtk_application_window_new (app); - char *that_window_title = "Gloups ! Who am I ?"; - gtk_window_set_title (GTK_WINDOW(that_window), that_window_title); - gtk_window_set_default_size (GTK_WINDOW(that_window), 300, 300); - gtk_widget_show (that_window); -} - - 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) { +static void just_use_gtk_application_window_new() +{ + GtkApplication *app = gtk_application_new ("org.gtk.test", 0); + GtkWidget *that_window = gtk_application_window_new (app); + g_signal_connect (G_OBJECT (that_window), "destroy", G_CALLBACK(on_destroy), "closes window using exit(0)\n"); + char *that_window_title = "Gloups ! Who am I ?"; + gtk_window_set_title (GTK_WINDOW(that_window), that_window_title); + gtk_window_set_default_size (GTK_WINDOW(that_window), 300, 300); + gtk_widget_show (that_window); - just_use_gtk_application_window_new(); + char *array[] = {"one", "two", "three", "four", NULL}; + GtkStringList *my_string_list = gtk_string_list_new ((const char * const *) array); + + + + /* model = GtkStringList(string.(names(Gtk4))) */ + /* selmodel = GtkSelectionModel(GtkSingleSelection(GListModel(model))) */ + + /* function setup_cb(f, li) */ + /* set_child(li,GtkLabel("")) */ + /* end */ + + /* function bind_cb(f, li) */ + /* text = li[].string */ + /* label = get_child(li) */ + /* label.label = text */ + /* end */ + + /* factory = GtkSignalListItemFactory(setup_cb, bind_cb) */ + /* list = GtkListView(selmodel, factory) */ + + /* win = GtkWindow("Listview demo", 250, 800) */ + /* sw = GtkScrolledWindow() */ + /* win[] = sw */ + /* sw[] = list */ +} + + +void on_activate_window_creation (GtkApplication *app, gpointer data) { GtkDebugFlags my_debug_flags = gtk_get_debug_flags (); if (0) printf("my_debug_flags %d\n", my_debug_flags); // << null // gtk_init (); < usefulness ? @@ -62,15 +87,17 @@ void on_activate_window_creation (GtkApplication *app, gpointer data) { 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 +// gtk_widget_show (my_window); // L E A R N > !!! 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 (n = %d)\n"); + 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"); + 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)); // else : gtk_window_set_child (GTK_WINDOW (my_window), my_button); + just_use_gtk_application_window_new(); + if (data) {g_print (data); g_print (" and is displayed by [sand_box.c > on_activate_window_creation()] NB #define G_DEBUG_HERE (void) added\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");