#include <gtk/gtk.h>

static GtkWidget *createWindow()
{
  GtkWidget *window=gtk_window_new(GTK_WINDOW_TOPLEVEL);
  
  GtkWidget *menu=gtk_menu_new();
  GtkWidget *box=gtk_vbox_new(FALSE, 0);
  GtkWidget *menubar=gtk_menu_bar_new();
  GtkWidget *menuitem;
  
  menuitem=gtk_menu_item_new_with_label("Exit");
  g_signal_connect_swapped(menuitem, "activate",
			   G_CALLBACK(gtk_widget_hide), window);
  gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
  gtk_widget_show(menuitem);

  menuitem=gtk_menu_item_new_with_label("File");
  gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), menu);
  gtk_menu_shell_append(GTK_MENU_SHELL(menubar), menuitem);
  gtk_widget_show(menuitem);

  gtk_box_pack_start(GTK_BOX(box), menubar, TRUE, FALSE, 0);
  gtk_window_set_title(GTK_WINDOW(window), "mywindow");
  gtk_container_add(GTK_CONTAINER(window), box);
  gtk_widget_show(menubar);
  gtk_widget_show(box);
  gtk_widget_show(window);

  g_signal_connect(window, "delete-event",
		   G_CALLBACK(gtk_widget_hide_on_delete), NULL);
  
  return window;
}

int main(int argc, char **argv)
{   
  GtkWidget *window;

  gtk_init(&argc, &argv);
  window=createWindow();

  g_signal_connect_after(window, "hide", G_CALLBACK(gtk_main_quit), NULL);
  gtk_main();
  
  gtk_widget_destroy(window);
  
  return 0;
}
