WIP: cleaning before : and_now_let_s_climb_that_tree (my_box_in_that_window); (sand_box 99)

This commit is contained in:
Jean Sirmai 2024-01-21 13:22:51 +01:00
parent 148460db0f
commit 682178afae
Signed by: jean
GPG Key ID: FB3115C340E057E3
1 changed files with 24 additions and 18 deletions

View File

@ -32,16 +32,11 @@ int n = 0;
static void on_button_action (GtkWidget *widget, gpointer data){n++; g_print (data, n);} 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);} static void on_destroy (GtkWidget *widget, gpointer data) {if (data) g_print (data); exit(0);}
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), "exit(0) closes window\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);
static void and_now_let_s_climb_that_tree(GtkWidget *that_box)
{
const gchar *my_array[] = {"one", "two", "three", "four", NULL}; // https://toshiocp.github.io/Gtk4-tutorial/sec29.html const gchar *my_array[] = {"one", "two", "three", "four", NULL}; // https://toshiocp.github.io/Gtk4-tutorial/sec29.html
GtkStringList *my_string_list = gtk_string_list_new ((const char * const *) my_array); GtkStringList *my_string_list = gtk_string_list_new ((const char * const *) my_array);
if (0) printf(strcat(gtk_string_list_get_string (my_string_list, 2), "\n")); if (0) printf(strcat(gtk_string_list_get_string (my_string_list, 2), "\n"));
@ -53,17 +48,14 @@ static void just_use_gtk_application_window_new()
// GtkSelectionModel *my_select_model = gtk_no_selection_new (my_string_list); // GtkSelectionModel *my_select_model = gtk_no_selection_new (my_string_list);
// GtkSingleSelection ... = gtk_single_selection_new (my_string_list); // GtkSingleSelection ... = gtk_single_selection_new (my_string_list);
GtkListItemFactory *my_factory = gtk_signal_list_item_factory_new (); GtkListItemFactory *my_factory = gtk_signal_list_item_factory_new ();
//setup (GtkSignalListItemFactory* self, GObject* object, gpointer user_data);
GtkWidget *my_list_view = gtk_list_view_new (my_string_list, my_factory); GtkWidget *my_list_view = gtk_list_view_new (my_string_list, my_factory);
gtk_box_append(GTK_BOX (that_box), GTK_WIDGET(my_list_view));
GtkWidget *my_box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
gtk_window_set_child(GTK_WINDOW(that_window), GTK_WIDGET(my_box));
gtk_box_append(GTK_BOX (my_box), GTK_WIDGET(my_list_view));
GtkWidget *my_button = gtk_button_new_with_label ("Sure ! I'm a button.");
gtk_box_append(GTK_BOX (my_box), GTK_WIDGET(my_button));
} }
void on_activate_window_creation (GtkApplication *app, gpointer data) { void on_activate_window_creation (GtkApplication *app, gpointer data) {
GtkDebugFlags my_debug_flags = gtk_get_debug_flags (); GtkDebugFlags my_debug_flags = gtk_get_debug_flags ();
@ -90,9 +82,23 @@ 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); 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(); // or just do it using : gtk_application_window_new(); -------------------------------------------------------------------------
GtkWidget *that_window = gtk_application_window_new (gtk_application_new ("org.gtk.test", 0));
g_signal_connect (G_OBJECT (that_window), "destroy", G_CALLBACK(on_destroy), "exit(0) closes window\n");
gtk_window_set_title (GTK_WINDOW(that_window), "Gloups ! Who am I ? Oooh...");
gtk_window_set_default_size (GTK_WINDOW(that_window), 300, 300);
gtk_widget_show (that_window);
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");} GtkWidget *my_box_in_that_window = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
gtk_window_set_child(GTK_WINDOW(that_window), GTK_WIDGET(my_box_in_that_window));
GtkWidget *my_other_button = gtk_button_new_with_label ("Sure ! I'm a button.");
g_signal_connect (G_OBJECT (my_other_button), "clicked", G_CALLBACK(on_button_action), "button clicked (n = %d)\n");
gtk_box_append(GTK_BOX (my_box_in_that_window), GTK_WIDGET(my_other_button));
and_now_let_s_climb_that_tree (my_box_in_that_window);
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\ 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"); [sand_box.c > on_activate_window_creation()] > widgets examples are in user/jean/01/GTK4/tree (learning)/The_Gnome_way/demos/gtk-demo <\n");
} }