selected page name is [n°0] (can't get its title)

This commit is contained in:
Jean Sirmai 2024-04-26 22:11:20 +02:00
parent aceb65fd00
commit 0ab7a233db
Signed by: jean
GPG Key ID: FB3115C340E057E3
2 changed files with 11 additions and 8 deletions

BIN
exec.o

Binary file not shown.

19
main.c
View File

@ -44,9 +44,9 @@ static void activate (GtkApplication *app, gpointer user_data) {
// https://docs.gtk.org/gtk4/enum.AccessibleRole.html // https://docs.gtk.org/gtk4/enum.AccessibleRole.html
// GtkToggleButton *tb1 = GTK_TOGGLE_BUTTON (gtk_button_new_with_label ("tb1")); // GtkToggleButton *tb1 = GTK_TOGGLE_BUTTON (gtk_button_new_with_label ("tb1"));
gtk_stack_add_titled (stack, page_1, "1", "A"); gtk_stack_add_titled (stack, page_1, "n°0", "A");
gtk_stack_add_titled (stack, page_2, "2", "B"); gtk_stack_add_titled (stack, page_2, "n°1", "B");
GtkStackPage *page_3 = gtk_stack_add_titled (stack, grid_3, "3", "C"); GtkStackPage *page_3 = gtk_stack_add_titled (stack, grid_3, "n°2", "C");
gtk_grid_attach (GTK_GRID (grid_3), button_5, 0, 0, 1, 1); gtk_grid_attach (GTK_GRID (grid_3), button_5, 0, 0, 1, 1);
@ -56,12 +56,15 @@ static void activate (GtkApplication *app, gpointer user_data) {
gtk_stack_switcher_set_stack (GTK_STACK_SWITCHER (switcher), stack); gtk_stack_switcher_set_stack (GTK_STACK_SWITCHER (switcher), stack);
// gtk_stack_sidebar_set_stack (GTK_STACK_SIDEBAR (sidebar), stack); // gtk_stack_sidebar_set_stack (GTK_STACK_SIDEBAR (sidebar), stack);
gtk_stack_page_get_child (GTK_STACK_PAGE(page_1)); // gtk_stack_page_get_child (GTK_STACK_PAGE(page_1));
// gtk_stack_page_set_name (GTK_STACK_PAGE(page_1), "new name"); // gtk_stack_page_set_name (GTK_STACK_PAGE(page_1), "new name");
gtk_stack_set_visible_child_name (stack, "3");
printf("visible is page [%s] whose name is : %s\n", GtkSelectionModel *stack_selection_model = gtk_stack_get_pages (stack);
gtk_stack_page_get_title (page_3), gtk_selection_model_select_item (stack_selection_model, 0, 1);
gtk_stack_get_visible_child_name (stack)); // gtk_stack_set_visible_child_name (stack, "n°3");
printf("selected page name is [%s] (can't get its title !)\n",
gtk_stack_get_visible_child_name (stack));
gtk_stack_set_transition_type (GTK_STACK (stack), gtk_stack_set_transition_type (GTK_STACK (stack),
GTK_STACK_TRANSITION_TYPE_CROSSFADE); GTK_STACK_TRANSITION_TYPE_CROSSFADE);