#!/bin/perl

use strict;
use warnings;
use Data::Dumper;
use Gtk2;
Gtk2->init;

my $window = new Gtk2::Window('toplevel');
my $menuBar = new Gtk2::MenuBar;
my $accel = Gtk2::AccelGroup->new();
my $menuFile = Gtk2::Menu->new();
$menuFile->set_accel_path('<main>/File');
$menuFile->set_accel_group($accel);

my $newFile = Gtk2::ImageMenuItem->new_from_stock('gtk-new', $accel);
$newFile->signal_connect ('activate' => sub {
    my $dialog = Gtk2::MessageDialog->new($window,
					  [qw/modal destroy-with-parent/],
					  'info',
					  'ok',
					  'Test');
    $dialog->run;
    $dialog->destroy;
});
$menuFile->append($newFile);
my $fileItem = Gtk2::MenuItem->new_with_mnemonic('File');
$fileItem->set_submenu($menuFile);
$menuBar->append($fileItem);

$window->add_accel_group($accel);
my $vbox = Gtk2::VBox->new(0,0);
$window->add($vbox);
my $label = Gtk2::Label->new('This is a test');
$vbox->pack_start($menuBar,0,0,1);
$vbox->pack_start($label,1,1,1);
$window->signal_connect(destroy => sub { Gtk2->main_quit; });
$window->show_all;
Gtk2->main;
