gtk_single_selection_new < it works fine ! (see line 60 in the sand_box)

This commit is contained in:
Jean Sirmai 2024-01-22 00:49:06 +01:00
parent f44c7d1f1e
commit aff067662d
Signed by: jean
GPG Key ID: FB3115C340E057E3
1 changed files with 4 additions and 6 deletions

View File

@ -30,7 +30,6 @@
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 setup_cb (GtkSignalListItemFactory *self, GtkListItem *listitem, gpointer user_data) { static void setup_cb (GtkSignalListItemFactory *self, GtkListItem *listitem, gpointer user_data) {
GtkWidget *my_label = gtk_label_new (NULL); GtkWidget *my_label = gtk_label_new (NULL);
gtk_list_item_set_child (listitem, my_label); 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) static void and_now_let_s_climb_that_tree (GtkWidget *in_that_box)
{ {
const gchar *my_array[] = {"zero", "one", "two", "three", "four", "five", const gchar *my_array[] = {"zero", "one", "two", "three", "four", "five",
"six", "seven", "eight", "nine", "ten", "eleven", "twelve", NULL}; "six", "seven", "eight", "nine", "ten", "eleven", "twelve", NULL};
// https://toshiocp.github.io/Gtk4-tutorial/sec29.html // 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);
gint selected = 3; gint selected = 7;
if (1) printf("The item n°%d of my array is the string \"%s\"\n",\ 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)); 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 (); GtkListItemFactory *my_factory = gtk_signal_list_item_factory_new ();
g_signal_connect (my_factory, "setup", G_CALLBACK (setup_cb), NULL); 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 // 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 // my local widgets examples are in user/jean/01/GTK4/tree (learning)/The_Gnome_way/demos/gtk-demo