]> Pileus Git - ~andy/gtk/blob - docs/reference/gtk/tmpl/gtkmenu.sgml
Doc fixes
[~andy/gtk] / docs / reference / gtk / tmpl / gtkmenu.sgml
1 <!-- ##### SECTION Title ##### -->
2 GtkMenu
3
4 <!-- ##### SECTION Short_Description ##### -->
5 A menu widget
6
7 <!-- ##### SECTION Long_Description ##### -->
8 <para>
9 A #GtkMenu is a #GtkMenuShell that implements a drop down menu consisting of
10 a list of #GtkMenuItem objects which can be navigated and activated by the 
11 user to perform application functions.
12 </para>
13
14 <para>
15 A #GtkMenu is most commonly dropped down by activating a #GtkMenuItem in a 
16 #GtkMenuBar or popped up by activating a #GtkMenuItem in another #GtkMenu.  
17 </para>
18
19 <para>
20 A #GtkMenu can also be popped up by activating a #GtkOptionMenu.  
21 Other composite widgets such as the #GtkNotebook can pop up a #GtkMenu 
22 as well.
23 </para>
24
25 <para>
26 Applications can display a #GtkMenu as a popup menu by calling the 
27 gtk_menu_popup() function.  The example below shows how an application
28 can pop up a menu when the 3rd mouse button is pressed.  
29 </para>
30
31 <example>
32 <title>Connecting the popup signal handler.</title>
33 <programlisting>
34     /* connect our handler which will popup the menu */
35     g_signal_connect_swapped (window, "button_press_event",
36         G_CALLBACK (my_popup_handler), menu);
37 </programlisting>
38 </example>
39
40 <example>
41 <title>Signal handler which displays a popup menu.</title>
42 <programlisting>
43 static gint
44 my_popup_handler (GtkWidget *widget, GdkEvent *event)
45 {
46   GtkMenu *menu;
47   GdkEventButton *event_button;
48
49   g_return_val_if_fail (widget != NULL, FALSE);
50   g_return_val_if_fail (GTK_IS_MENU (widget), FALSE);
51   g_return_val_if_fail (event != NULL, FALSE);
52
53   /* The "widget" is the menu that was supplied when 
54    * g_signal_connect_swapped() was called.
55    */
56   menu = GTK_MENU (widget);
57
58   if (event->type == GDK_BUTTON_PRESS)
59     {
60       event_button = (GdkEventButton *) event;
61       if (event_button->button == 3)
62         {
63           gtk_menu_popup (menu, NULL, NULL, NULL, NULL, 
64                           event_button->button, event_button->time);
65           return TRUE;
66         }
67     }
68
69   return FALSE;
70 }
71 </programlisting>
72 </example>
73
74 <!-- ##### SECTION See_Also ##### -->
75 <para>
76
77 </para>
78
79 <!-- ##### SECTION Stability_Level ##### -->
80
81
82 <!-- ##### STRUCT GtkMenu ##### -->
83 <para>
84 The #GtkMenu struct contains private data only, and
85 should be accessed using the functions below.
86 </para>
87
88
89 <!-- ##### SIGNAL GtkMenu::move-scroll ##### -->
90 <para>
91
92 </para>
93
94 @menu: the object which received the signal.
95 @arg1: 
96
97 <!-- ##### ARG GtkMenu:tearoff-state ##### -->
98 <para>
99
100 </para>
101
102 <!-- ##### ARG GtkMenu:tearoff-title ##### -->
103 <para>
104
105 </para>
106
107 <!-- ##### ARG GtkMenu:bottom-attach ##### -->
108 <para>
109
110 </para>
111
112 <!-- ##### ARG GtkMenu:left-attach ##### -->
113 <para>
114
115 </para>
116
117 <!-- ##### ARG GtkMenu:right-attach ##### -->
118 <para>
119
120 </para>
121
122 <!-- ##### ARG GtkMenu:top-attach ##### -->
123 <para>
124
125 </para>
126
127 <!-- ##### ARG GtkMenu:horizontal-offset ##### -->
128 <para>
129
130 </para>
131
132 <!-- ##### ARG GtkMenu:vertical-offset ##### -->
133 <para>
134
135 </para>
136
137 <!-- ##### ARG GtkMenu:vertical-padding ##### -->
138 <para>
139
140 </para>
141
142 <!-- ##### FUNCTION gtk_menu_new ##### -->
143 <para>
144 Creates a new #GtkMenu.
145 </para>
146
147 @Returns: a new #GtkMenu.
148
149
150 <!-- ##### FUNCTION gtk_menu_set_screen ##### -->
151 <para>
152
153 </para>
154
155 @menu: 
156 @screen: 
157
158
159 <!-- ##### MACRO gtk_menu_append ##### -->
160 <para>
161 Adds a new #GtkMenuItem to the end of the menu's item list.
162 </para>
163
164 @menu: a #GtkMenu.
165 @child: The #GtkMenuItem to add.
166 <!-- # Unused Parameters # -->
167 @m: 
168 @c: 
169
170
171 <!-- ##### MACRO gtk_menu_prepend ##### -->
172 <para>
173 Adds a new #GtkMenuItem to the beginning of the menu's item list.
174 </para>
175
176 @menu: a #GtkMenu.
177 @child: The #GtkMenuItem to add.
178 <!-- # Unused Parameters # -->
179 @menu_child: 
180 @m: 
181 @c: 
182
183
184 <!-- ##### MACRO gtk_menu_insert ##### -->
185 <para>
186 Adds a new #GtkMenuItem to the menu's item list at the position
187 indicated by @position. 
188 </para>
189
190 @menu: a #GtkMenu.
191 @child: The #GtkMenuItem to add.
192 @pos: The position in the item list where @child is added.
193 Positions are numbered from 0 to n-1.
194
195
196 <!-- ##### FUNCTION gtk_menu_reorder_child ##### -->
197 <para>
198 Moves a #GtkMenuItem to a new position within the #GtkMenu.
199 </para>
200
201 @menu: a #GtkMenu.
202 @child: the #GtkMenuItem to move.
203 @position: the new position to place @child.  Positions are numbered from 
204 0 to n-1.
205
206
207 <!-- ##### FUNCTION gtk_menu_attach ##### -->
208 <para>
209
210 </para>
211
212 @menu: 
213 @child: 
214 @left_attach: 
215 @right_attach: 
216 @top_attach: 
217 @bottom_attach: 
218
219
220 <!-- ##### FUNCTION gtk_menu_popup ##### -->
221
222
223 @menu: 
224 @parent_menu_shell: 
225 @parent_menu_item: 
226 @func: 
227 @data: 
228 @button: 
229 @activate_time: 
230
231
232 <!-- ##### FUNCTION gtk_menu_set_accel_group ##### -->
233 <para>
234 Set the #GtkAccelGroup which holds global accelerators for the menu.
235 This accelerator group needs to also be added to all windows that
236 this menu is being used in with gtk_window_add_accel_group(), in order
237 for those windows to support all the accelerators contained in this group.
238 </para>
239
240 @menu: a #GtkMenu.
241 @accel_group: the #GtkAccelGroup to be associated with the menu.
242
243
244 <!-- ##### FUNCTION gtk_menu_get_accel_group ##### -->
245 <para>
246 Gets the #GtkAccelGroup which holds global accelerators for the menu.
247 See gtk_menu_set_accel_group().
248 </para>
249
250 @menu: a #GtkMenu.
251 @Returns: the #GtkAccelGroup associated with the menu.
252
253
254 <!-- ##### FUNCTION gtk_menu_set_accel_path ##### -->
255 <para>
256
257 </para>
258
259 @menu: 
260 @accel_path: 
261
262
263 <!-- ##### FUNCTION gtk_menu_set_title ##### -->
264 <para>
265 </para>
266
267 @menu: 
268 @title: 
269
270
271 <!-- ##### FUNCTION gtk_menu_get_tearoff_state ##### -->
272 <para>
273
274 </para>
275
276 @menu: 
277 @Returns: 
278
279
280 <!-- ##### FUNCTION gtk_menu_get_title ##### -->
281 <para>
282
283 </para>
284
285 @menu: 
286 @Returns: 
287
288
289 <!-- ##### FUNCTION gtk_menu_popdown ##### -->
290 <para>
291 Removes the menu from the screen.
292 </para>
293
294 @menu: a #GtkMenu.
295
296
297 <!-- ##### FUNCTION gtk_menu_reposition ##### -->
298 <para>
299 Repositions the menu according to its position function.
300 </para>
301
302 @menu: a #GtkMenu.
303
304
305 <!-- ##### FUNCTION gtk_menu_get_active ##### -->
306 <para>
307 Returns the selected menu item from the menu.  This is used by the 
308 #GtkOptionMenu.
309 </para>
310
311 @menu: a #GtkMenu.
312 @Returns: the #GtkMenuItem that was last selected in the menu.  If a 
313 selection has not yet been made, the first menu item is selected.
314
315
316 <!-- ##### FUNCTION gtk_menu_set_active ##### -->
317 <para>
318 Selects the specified menu item within the menu.  This is used by the
319 #GtkOptionMenu and should not be used by anyone else.
320 </para>
321
322 @menu: a #GtkMenu.
323 @index_: the index of the menu item to select.  Index values are from
324 0 to n-1.
325
326
327 <!-- ##### FUNCTION gtk_menu_set_tearoff_state ##### -->
328 <para>
329 Changes the tearoff state of the menu.  A menu is normally displayed 
330 as drop down menu which persists as long as the menu is active.  It can 
331 also be displayed as a tearoff menu which persists until it is closed 
332 or reattached.
333 </para>
334
335 @menu: a #GtkMenu.
336 @torn_off: If %TRUE, menu is displayed as a tearoff menu.
337
338
339 <!-- ##### FUNCTION gtk_menu_attach_to_widget ##### -->
340 <para>
341 Attaches the menu to the widget and provides a callback function that will
342 be invoked when the menu calls gtk_menu_detach() during its destruction.
343 </para>
344
345 @menu: a #GtkMenu.
346 @attach_widget: the #GtkWidget that the menu will be attached to.
347 @detacher: the user supplied callback function that will be called when 
348 the menu calls gtk_menu_detach().
349
350
351 <!-- ##### FUNCTION gtk_menu_detach ##### -->
352 <para>
353 Detaches the menu from the widget to which it had been attached.  
354 This function will call the callback function, @detacher, provided
355 when the gtk_menu_attach_to_widget() function was called.
356 </para>
357
358 @menu: a #GtkMenu.
359
360
361 <!-- ##### FUNCTION gtk_menu_get_attach_widget ##### -->
362 <para>
363 Returns the #GtkWidget that the menu is attached to.
364 </para>
365
366 @menu: a #GtkMenu.
367 @Returns: the #GtkWidget that the menu is attached to.
368
369
370 <!-- ##### FUNCTION gtk_menu_get_for_attach_widget ##### -->
371 <para>
372
373 </para>
374
375 @widget: 
376 @Returns: 
377
378
379 <!-- ##### USER_FUNCTION GtkMenuPositionFunc ##### -->
380 <para>
381 A user function supplied when calling gtk_menu_popup() which controls the
382 positioning of the menu when it is displayed.  The function sets the @x
383 and @y parameters to the coordinates where the menu is to be drawn.
384 </para>
385
386 @menu: a #GtkMenu.
387 @x: address of the #gint representing the horizontal position where the
388 menu shall be drawn.  This is an output parameter.
389 @y: address of the #gint representing the vertical position where the
390 menu shall be drawn.  This is an output parameter.
391 @push_in: whether the menu should be pushed in to be completely inside the
392   screen instead of just clamped to the size to the screen.
393 @user_data: the data supplied by the user in the gtk_menu_popup() @data
394 parameter.
395
396
397 <!-- ##### USER_FUNCTION GtkMenuDetachFunc ##### -->
398 <para>
399 A user function supplied when calling gtk_menu_attach_to_widget() which 
400 will be called when the menu is later detached from the widget.
401 </para>
402
403 @attach_widget: the #GtkWidget that the menu is being detached from.
404 @menu: the #GtkMenu being detached.
405
406
407 <!-- ##### FUNCTION gtk_menu_set_monitor ##### -->
408 <para>
409
410 </para>
411
412 @menu: 
413 @monitor_num: 
414
415