#include <gtk/gtk.h>

int
main (int   argc,
      char *argv[])
{
  GtkWidget *window,*box,*btn1,*btn2;
  GMenu* menu, *submenu;
  GMenuItem* item;

  gtk_init (&argc, &argv);
  menu = g_menu_new();
  submenu = g_menu_new();
  g_menu_append(submenu,"Label only",NULL);
  item = g_menu_item_new(NULL,NULL);
  g_menu_item_set_attribute(item,"icon","s","preferences-system");
  g_menu_append_item(submenu,item);
  g_object_unref(item);
  item = g_menu_item_new("Label and icon",NULL);
  g_menu_item_set_attribute(item,"icon","s","preferences-system");
  g_menu_append_item(submenu,item);
  g_object_unref(item);
  item = g_menu_item_new_submenu(NULL,G_MENU_MODEL(submenu));
  g_menu_item_set_attribute(item,"icon","s","preferences-system");
  g_menu_append_item(menu,item);
  g_object_unref(item);
  item = g_menu_item_new_submenu("Submenu with label and icon",G_MENU_MODEL(submenu));
  g_menu_item_set_attribute(item,"icon","s","preferences-system");
  g_menu_append_item(menu,item);
  g_object_unref(item);
  g_menu_append_submenu(menu,"Submenu with label",G_MENU_MODEL(submenu));
  g_object_unref(submenu);
  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_window_set_title (GTK_WINDOW (window), "Window");
  gtk_window_set_default_size(GTK_WINDOW(window),800,800);
  box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL,100);
  gtk_container_set_border_width(GTK_CONTAINER(box),700);
  gtk_container_add(GTK_CONTAINER(window),box);
  btn1 = gtk_menu_button_new();
  gtk_button_set_label(GTK_BUTTON(btn1),"Menu");
  gtk_menu_button_set_use_popover(GTK_MENU_BUTTON(btn1),FALSE);
  gtk_menu_button_set_menu_model(GTK_MENU_BUTTON(btn1),G_MENU_MODEL(menu));
  gtk_container_add(GTK_CONTAINER(box),btn1);
  btn2 = gtk_menu_button_new();
  gtk_button_set_label(GTK_BUTTON(btn2),"Popover");
  gtk_menu_button_set_use_popover(GTK_MENU_BUTTON(btn2),TRUE);
  gtk_menu_button_set_menu_model(GTK_MENU_BUTTON(btn2),G_MENU_MODEL(menu));
  gtk_container_add(GTK_CONTAINER(box),btn2);
  g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);

  gtk_widget_show_all (window);

  gtk_main ();

  return 0;
}
