#include <gtk/gtk.h>

static void
on_mnemonic (GtkButton *button)
{
  g_print ("%s\n", gtk_button_get_label (button));
}

static void
open_popover (GtkPopover *popover)
{
  gtk_popover_popup (popover);
}

int
main (int argc, char **argv)
{
  gtk_init (&argc, &argv);

  GtkWidget *window = gtk_window_new (GTK_WINDOW_TOPLEVEL);

  GtkWidget *box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);

  GtkWidget *button = gtk_button_new_with_mnemonic ("_Button in Window");
  g_signal_connect (button, "clicked", (GCallback) &on_mnemonic, NULL);
  gtk_container_add ((GtkContainer *)box, button);

  button = gtk_button_new_with_mnemonic ("Open _Popover");
  GtkWidget *popover = gtk_popover_new (button);
  g_signal_connect_swapped (button, "clicked", (GCallback) &open_popover, popover);
  gtk_container_add ((GtkContainer *)box, button);

  button = gtk_button_new_with_mnemonic ("_Button in Popover");
  g_signal_connect (button, "clicked", (GCallback) &on_mnemonic, NULL);
  gtk_container_add ((GtkContainer *)popover, button);
  gtk_widget_show (button);

  gtk_container_add ((GtkContainer *)window, box);
  gtk_window_set_default_size ((GtkWindow *)window, 500, 500);
  gtk_widget_show_all (window);
  gtk_main ();
}
