visible is page [C] whose name is : 3

This commit is contained in:
Jean Sirmai 2024-04-26 21:37:58 +02:00
parent 80603caff0
commit aceb65fd00
Signed by: jean
GPG Key ID: FB3115C340E057E3
2 changed files with 17 additions and 10 deletions

BIN
exec.o

Binary file not shown.

27
main.c
View File

@ -8,18 +8,18 @@ static void activate (GtkApplication *app, gpointer user_data) {
GtkWidget *button_2 = gtk_button_new_with_label ("II");
GtkWidget *button_3 = gtk_button_new_with_label ("III");
GtkWidget *button_4 = gtk_button_new_with_label ("IV");
GtkWidget *button_5 = gtk_button_new_with_label ("V");
GtkWidget *window = gtk_application_window_new (app);
GtkWidget *titlebar = gtk_header_bar_new();
// GtkWidget *overlay = gtk_overlay_new();
// gtk_overlay_set_buildable_id (GTK_BUILDABLE(overlay), "overlay id");
// printf("overlay %s\n", gtk_buildable_get_buildable_id (GTK_BUILDABLE(overlay)));
GtkWidget *switcher = gtk_stack_switcher_new();
// GtkWidget *sidebar = gtk_stack_sidebar_new();
GtkStack *stack = GTK_STACK (gtk_stack_new());
GtkWidget *page_1 = gtk_paned_new(GTK_ORIENTATION_VERTICAL);
GtkWidget *page_2 = gtk_paned_new(GTK_ORIENTATION_VERTICAL);
GtkWidget *grid = gtk_grid_new();
GtkWidget *grid_3 = gtk_grid_new();
GtkWidget *box = gtk_box_new (0, 6); // 6 = spacing
gtk_window_set_title (GTK_WINDOW (window), "Window");
@ -44,22 +44,24 @@ static void activate (GtkApplication *app, gpointer user_data) {
// https://docs.gtk.org/gtk4/enum.AccessibleRole.html
// GtkToggleButton *tb1 = GTK_TOGGLE_BUTTON (gtk_button_new_with_label ("tb1"));
gtk_stack_add_titled (stack, page_1, "name 1", "page A");
gtk_stack_add_titled (stack, page_2, "name 2", "page B");
gtk_stack_add_titled (stack, page_1, "1", "A");
gtk_stack_add_titled (stack, page_2, "2", "B");
GtkStackPage *page_3 = gtk_stack_add_titled (stack, grid_3, "3", "C");
gtk_grid_attach (GTK_GRID (grid_3), button_5, 0, 0, 1, 1);
gtk_orientable_set_orientation (GTK_ORIENTABLE (switcher), GTK_ORIENTATION_HORIZONTAL);
gtk_orientable_set_orientation (GTK_ORIENTABLE (switcher), GTK_ORIENTATION_VERTICAL);
gtk_orientable_set_orientation (GTK_ORIENTABLE (switcher), GTK_ORIENTATION_HORIZONTAL);
gtk_stack_switcher_set_stack (GTK_STACK_SWITCHER (switcher), stack);
// gtk_stack_sidebar_set_stack (GTK_STACK_SIDEBAR (sidebar), stack);
gtk_stack_page_get_child (GTK_STACK_PAGE(page_1));
// gtk_stack_page_set_name (GTK_STACK_PAGE(page_1), "new name");
gtk_stack_set_visible_child_name (stack, "name 1");
printf("visible is page [%s] with name (%s)\n",
"?", // gtk_stack_page_get_title (GTK_STACK_PAGE(page_1)),
gtk_stack_set_visible_child_name (stack, "3");
printf("visible is page [%s] whose name is : %s\n",
gtk_stack_page_get_title (page_3),
gtk_stack_get_visible_child_name (stack));
// gtk_stack_page_get_title (GTK_STACK_PAGE(page_1)));
gtk_stack_set_transition_type (GTK_STACK (stack),
GTK_STACK_TRANSITION_TYPE_CROSSFADE);
@ -111,4 +113,9 @@ main (int argc,
*
*/
// GtkWidget *overlay = gtk_overlay_new();
// gtk_overlay_set_buildable_id (GTK_BUILDABLE(overlay), "overlay id");
// printf("overlay %s\n", gtk_buildable_get_buildable_id (GTK_BUILDABLE(overlay)));
// how do I attach a widget to a page ?