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

NAME

6       Gtk2::SimpleMenu - A simple interface to Gtk2's ItemFactory for
7       creating 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
94       simple a manner as possible. Its main benefit is that the menu is
95       specified as a tree, which is the natural representation of such a
96       menu.
97

DESCRIPTION

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

OBJECT HIERARCHY

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

FUNCTIONS

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

MEMBER VARIABLES

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

SEE ALSO

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

AUTHORS

151        Ross McFarland <rwmcfa1 at neces dot com>
152
154       Copyright 2003 by the Gtk2-Perl team.
155
156       This library is free software; you can redistribute it and/or modify it
157       under the terms of the GNU Library General Public License as published
158       by the Free Software Foundation; either version 2.1 of the License, or
159       (at your option) any later version.
160
161       This library is distributed in the hope that it will be useful, but
162       WITHOUT ANY WARRANTY; without even the implied warranty of
163       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
164       Library General Public License for more details.
165
166       You should have received a copy of the GNU Library General Public
167       License along with this library; if not, write to the Free Software
168       Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
169       02110-1301  USA.
170
171
172
173perl v5.36.0                      2023-01-20               Gtk2::SimpleMenu(3)
Impressum