/* gcc stack.c $(pkg-config --cflags --libs gtk+-3.0 glib-2.0) */

#include <gtk/gtk.h>

static void
visible_child_cb (GtkStack *stack)
{
  g_message ("visible-child changed");
}

int
main (void)
{
  GtkWidget *label;
  GtkWidget *stack;
  GtkWidget *window;

  gtk_init (NULL, NULL);

  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  g_signal_connect (window, "delete-event", gtk_main_quit, NULL);

  stack = gtk_stack_new ();
  gtk_container_add (GTK_CONTAINER (window), stack);

  label = gtk_label_new ("hello world");
  gtk_widget_show (label);
  gtk_stack_add_named (GTK_STACK (stack), label, "child1");
  gtk_stack_set_visible_child (GTK_STACK (stack), label);

  g_signal_connect (stack,
                    "notify::visible-child",
                    G_CALLBACK (visible_child_cb),
                    NULL);

  gtk_widget_show_all (window);
  gtk_main ();

  return 0;
}
