From aff067662dcc8bd825d7ef4174ad1d57bed8522e Mon Sep 17 00:00:00 2001 From: Jean Sirmai Date: Mon, 22 Jan 2024 00:49:06 +0100 Subject: [PATCH] gtk_single_selection_new < it works fine ! (see line 60 in the sand_box) --- src/ui/sand_box.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/ui/sand_box.c b/src/ui/sand_box.c index f90f5e3..c5c582e 100644 --- a/src/ui/sand_box.c +++ b/src/ui/sand_box.c @@ -30,7 +30,6 @@ static void on_destroy (GtkWidget *widget, gpointer data) {if (data) g_print (data); exit(0);} - static void setup_cb (GtkSignalListItemFactory *self, GtkListItem *listitem, gpointer user_data) { GtkWidget *my_label = gtk_label_new (NULL); gtk_list_item_set_child (listitem, my_label); @@ -49,16 +48,16 @@ static void bind_cb (GtkSignalListItemFactory *self, GtkListItem *listitem, gpoi static void and_now_let_s_climb_that_tree (GtkWidget *in_that_box) { const gchar *my_array[] = {"zero", "one", "two", "three", "four", "five", - "six", "seven", "eight", "nine", "ten", "eleven", "twelve", NULL}; - // https://toshiocp.github.io/Gtk4-tutorial/sec29.html + "six", "seven", "eight", "nine", "ten", "eleven", "twelve", NULL}; + // https://toshiocp.github.io/Gtk4-tutorial/sec29.html GtkStringList *my_string_list = gtk_string_list_new ((const char * const *) my_array); - gint selected = 3; + gint selected = 7; if (1) printf("The item n°%d of my array is the string \"%s\"\n",\ selected, gtk_string_list_get_string (my_string_list, selected)); - GtkNoSelection *my_selection = gtk_no_selection_new (G_LIST_MODEL (my_string_list)); + GtkNoSelection *my_selection = gtk_single_selection_new (G_LIST_MODEL (my_string_list)); GtkListItemFactory *my_factory = gtk_signal_list_item_factory_new (); g_signal_connect (my_factory, "setup", G_CALLBACK (setup_cb), NULL); @@ -89,4 +88,3 @@ void on_activate_window_creation (GtkApplication *app, gpointer data) { // guix shell -m manifest.scm && pkg-config --libs gtk4 make clean && clear && time make run // my local widgets examples are in user/jean/01/GTK4/tree (learning)/The_Gnome_way/demos/gtk-demo -