1pm::SimpleMenu(3)     User Contributed Perl Documentation    pm::SimpleMenu(3)
2
3
4

NAME

6       Gtk2::SimpleMenu - A simple interface to Gtk2's ItemFactory for creat‐
7       ing application menus
8

SYNOPSIS

10         use Gtk2 '-init';
11         use Gtk2::SimpleMenu;
12
13         my $menu_tree = [
14               _File => {
15                       item_type => '<Branch>',
16                       children => [
17                               _New => {
18                                       callback => \&new_cb,
19                                       callback_action => 0,
20                                       accelerator => '<ctrl>N',
21                               },
22                               _Save => {
23                                       callback_action => 1,
24                                       callback_data => 'per entry cbdata',
25                                       accelerator => '<ctrl>S',
26                               },
27                               _Exec => {
28                                       item_type => '<StockItem>',
29                                       callback_action => 2,
30                                       extra_data => 'gtk-execute',
31                               },
32                               _Quit => {
33                                       callback => sub { Gtk2->main_quit; },
34                                       callback_action => 3,
35                                       accelerator => '<ctrl>Q',
36                               },
37                       ],
38               },
39               _Mode => {
40                       _First => {
41                               item_type => '<RadioItem>',
42                               callback => \&mode_callback,
43                               callback_action => 4,
44                               groupid => 1,
45                       }
46                       _Second => {
47                               item_type => '<RadioItem>',
48                               callback => \&mode_callback,
49                               callback_action => 5,
50                               groupid => 1,
51                       }
52                       _Third => {
53                               item_type => '<RadioItem>',
54                               callback => \&mode_callback,
55                               callback_action => 6,
56                               groupid => 1,
57                       }
58               }
59               _Help => {
60                       children => [
61                               _Tearoff => {
62                                       item_type => '<Tearoff>',
63                               },
64                               _CheckItem => {
65                                       item_type => '<CheckItem>',
66                                       callback_action => 7,
67                               },
68                               Separator => {
69                                       item_type => '<Separator>',
70                               },
71                               _Contents => {
72                                       callback_action => 8,
73                               },
74                               _About => {
75                                       callback_action => 9,
76                               },
77                       ]
78               }
79         ];
80
81         my $menu = Gtk2::SimpleMenu->new (
82                       menu_tree => $menu_tree,
83                       default_callback => \&default_callback,
84                       user_data => 'user_data',
85               );
86
87         # an example of how to get to the menuitems.
88         $menu->get_widget('/File/Save')->activate;
89
90         $container->add ($menu->{widget});
91

ABSTRACT

93       SimpleMenu is an interface for creating application menubars in as sim‐
94       ple a manner as possible. Its main benifit is that the menu is speci‐
95       fied as a tree, which is the natural representation of such a menu.
96

DESCRIPTION

98       SimpleMenu aims to simplify the design and management of a complex
99       application menu bar by allowing the structure to be specified as a
100       multi-rooted tree. Much the same functionality is provided by
101       Gtk2::ItemFactory, but the data provided as input is a 1-D array and
102       the hierarchy of the menu is controled entierly by the path com‐
103       ponenets. This is not ideal when languages such as perl provide for
104       simple nested data structures.
105
106       Another advantage of the SimpleMenu widget is that it simplifies the
107       creation and use of accelerators.
108
109       SimpleMenu is a child of Gtk2::ItemFactory, so that it may be treated
110       as such.  Any method that can be called on a ItemFactory can be called
111       on a SimpleMenu.
112

OBJECT HIERARCHY

114        Glib::Object
115        +--- Gtk2::Object
116             +--- Gtk2::ItemFactory
117                  +--- Gtk2::SimpleMenu
118

FUNCTIONS

120       $menu = Gtk2::SimpleMenu->new (menu_tree => $menu_tree, ...)
121           Creates a new Gtk2::SimpleMenu object with the specified tree.
122           Optionally key value paris providing a default_callback and
123           user_data can be provided as well.  After creating the menu object
124           all of the subsequent widgets will have been created and are ready
125           for use.
126

MEMBER VARIABLES

128       $menu->{widget}
129           The Gtk2::MenuBar root of the SimpleMenu. This is what should be
130           added to the widget which will contain the SimpleMenu.
131
132             $container->add ($menu->{widget});
133
134       $menu->{accel_group}
135           The Gtk2::AccellGroup created by the menu tree. Normally
136           accell_group would be added to the main window of an application,
137           but this is only necessary if accelerators are being used in the
138           menu tree's items.
139
140             $win->add_accel_group ($menu->{accel_group});
141

SEE ALSO

143       Perl(1), Glib(3pm), Gtk2(3pm), examples/simple_menu.pl.
144
145       Note: Gtk2::SimpleMenu is deprecated in favor of Gtk2::Ex::Sim‐
146       ple::Menu, part of the Gtk2-Perl-Ex project at
147       <http://gtk2-perl-ex.sf.net/> .
148

AUTHORS

150        Ross McFarland <rwmcfa1 at neces dot com>
151
153       Copyright 2003 by the Gtk2-Perl team.
154
155       This library is free software; you can redistribute it and/or modify it
156       under the terms of the GNU Library General Public License as published
157       by the Free Software Foundation; either version 2.1 of the License, or
158       (at your option) any later version.
159
160       This library is distributed in the hope that it will be useful, but
161       WITHOUT ANY WARRANTY; without even the implied warranty of MER‐
162       CHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library
163       General Public License for more details.
164
165       You should have received a copy of the GNU Library General Public
166       License along with this library; if not, write to the Free Software
167       Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307
168       USA.
169
170
171
172perl v5.8.8                       2007-03-18                 pm::SimpleMenu(3)
Impressum