File: testmf.pl

package info (click to toggle)
libgtk-perl 0.7009-12
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 3,956 kB
  • ctags: 2,260
  • sloc: perl: 13,998; xml: 9,919; ansic: 2,894; makefile: 64; cpp: 45
file content (33 lines) | stat: -rw-r--r-- 847 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/usr/bin/perl -w

#TITLE: MenuFactory
#REQUIRES: Gtk

use Gtk;

init Gtk;

$factory = new Gtk::MenuFactory('menu_bar');
$subfactory = new Gtk::MenuFactory('menu_bar');
$factory->add_subfactory($subfactory, '<Main>');
$entry1 = { path  =>  '<Main>/File/Hello',
           accelerator     =>  '<alt>H',
           widget          =>  undef,
           callback        =>  sub {print "Hello world!\n"}
         };
$entry2 = { path  =>  '<Main>/File/Quit',
           accelerator     =>  '<alt>Q',
           widget          =>  undef,
           callback        =>  sub {Gtk->exit(0)}
         };
    $factory->add_entries($entry1, $entry2);
    $menubar = $subfactory->widget;

#$entry->{'widget'}->show;
$menubar->show;
$win = new Gtk::Window;
$win->add($menubar);
$win->show;
$win->signal_connect('delete_event', sub {Gtk->exit(0)});
main Gtk;