WIP: GtkStringList *my_string_list = gtk_string_list_new ((const char * const *) array);

This commit is contained in:
Jean Sirmai 2024-01-21 00:04:39 +01:00
parent 6039ebacd9
commit 05230b7a64
Signed by: jean
GPG Key ID: FB3115C340E057E3
3 changed files with 45 additions and 17 deletions

View File

@ -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);

View File

@ -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);
}
/*

View File

@ -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,7 +87,7 @@ 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");
@ -71,6 +96,8 @@ void on_activate_window_creation (GtkApplication *app, gpointer data) {
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");