~ubuntu-branches/ubuntu/precise/gtk+2.0/precise-updates

« back to all changes in this revision

Viewing changes to docs/reference/gtk/tmpl/gtkmenu.sgml

  • Committer: Package Import Robot
  • Author(s): Ken VanDine
  • Date: 2011-12-01 11:40:06 UTC
  • mfrom: (1.14.11)
  • Revision ID: package-import@ubuntu.com-20111201114006-nrmf6qu3pg512veo
Tags: 2.24.8-0ubuntu1
* New upstream release 
  - gtkfilechooser should be more robust to malformed URIs
    in .gtk-bookmarks (LP: #189494)
* debian/patches/010_make_bg_changes_queue_repaint.patch
  - dropped it introduces performance regressions in some gtk2 
    apps (LP: #889019)
* 101_filechooser.patch, 000git_file_chooser.patch: dropped, upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
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
 
<!-- ##### SECTION Image ##### -->
83
 
 
84
 
 
85
 
<!-- ##### STRUCT GtkMenu ##### -->
86
 
<para>
87
 
The #GtkMenu struct contains private data only, and
88
 
should be accessed using the functions below.
89
 
</para>
90
 
 
91
 
 
92
 
<!-- ##### SIGNAL GtkMenu::move-scroll ##### -->
93
 
<para>
94
 
 
95
 
</para>
96
 
 
97
 
@menu: the object which received the signal.
98
 
@arg1: 
99
 
 
100
 
<!-- ##### ARG GtkMenu:accel-group ##### -->
101
 
<para>
102
 
 
103
 
</para>
104
 
 
105
 
<!-- ##### ARG GtkMenu:accel-path ##### -->
106
 
<para>
107
 
 
108
 
</para>
109
 
 
110
 
<!-- ##### ARG GtkMenu:active ##### -->
111
 
<para>
112
 
 
113
 
</para>
114
 
 
115
 
<!-- ##### ARG GtkMenu:attach-widget ##### -->
116
 
<para>
117
 
 
118
 
</para>
119
 
 
120
 
<!-- ##### ARG GtkMenu:monitor ##### -->
121
 
<para>
122
 
 
123
 
</para>
124
 
 
125
 
<!-- ##### ARG GtkMenu:reserve-toggle-size ##### -->
126
 
<para>
127
 
 
128
 
</para>
129
 
 
130
 
<!-- ##### ARG GtkMenu:tearoff-state ##### -->
131
 
<para>
132
 
 
133
 
</para>
134
 
 
135
 
<!-- ##### ARG GtkMenu:tearoff-title ##### -->
136
 
<para>
137
 
 
138
 
</para>
139
 
 
140
 
<!-- ##### ARG GtkMenu:bottom-attach ##### -->
141
 
<para>
142
 
 
143
 
</para>
144
 
 
145
 
<!-- ##### ARG GtkMenu:left-attach ##### -->
146
 
<para>
147
 
 
148
 
</para>
149
 
 
150
 
<!-- ##### ARG GtkMenu:right-attach ##### -->
151
 
<para>
152
 
 
153
 
</para>
154
 
 
155
 
<!-- ##### ARG GtkMenu:top-attach ##### -->
156
 
<para>
157
 
 
158
 
</para>
159
 
 
160
 
<!-- ##### ARG GtkMenu:arrow-placement ##### -->
161
 
<para>
162
 
 
163
 
</para>
164
 
 
165
 
<!-- ##### ARG GtkMenu:arrow-scaling ##### -->
166
 
<para>
167
 
 
168
 
</para>
169
 
 
170
 
<!-- ##### ARG GtkMenu:double-arrows ##### -->
171
 
<para>
172
 
 
173
 
</para>
174
 
 
175
 
<!-- ##### ARG GtkMenu:horizontal-offset ##### -->
176
 
<para>
177
 
 
178
 
</para>
179
 
 
180
 
<!-- ##### ARG GtkMenu:horizontal-padding ##### -->
181
 
<para>
182
 
 
183
 
</para>
184
 
 
185
 
<!-- ##### ARG GtkMenu:vertical-offset ##### -->
186
 
<para>
187
 
 
188
 
</para>
189
 
 
190
 
<!-- ##### ARG GtkMenu:vertical-padding ##### -->
191
 
<para>
192
 
 
193
 
</para>
194
 
 
195
 
<!-- ##### FUNCTION gtk_menu_new ##### -->
196
 
<para>
197
 
Creates a new #GtkMenu.
198
 
</para>
199
 
 
200
 
@void: 
201
 
@Returns: a new #GtkMenu.
202
 
 
203
 
 
204
 
<!-- ##### FUNCTION gtk_menu_set_screen ##### -->
205
 
<para>
206
 
 
207
 
</para>
208
 
 
209
 
@menu: 
210
 
@screen: 
211
 
 
212
 
 
213
 
<!-- ##### MACRO gtk_menu_append ##### -->
214
 
<para>
215
 
Adds a new #GtkMenuItem to the end of the menu's item list.
216
 
</para>
217
 
 
218
 
@menu: a #GtkMenu.
219
 
@child: The #GtkMenuItem to add.
220
 
@Deprecated: Use gtk_menu_shell_append() instead.
221
 
 
222
 
 
223
 
<!-- ##### MACRO gtk_menu_prepend ##### -->
224
 
<para>
225
 
Adds a new #GtkMenuItem to the beginning of the menu's item list.
226
 
</para>
227
 
 
228
 
@menu: a #GtkMenu.
229
 
@child: The #GtkMenuItem to add.
230
 
@Deprecated: Use gtk_menu_shell_prepend() instead.
231
 
 
232
 
 
233
 
<!-- ##### MACRO gtk_menu_insert ##### -->
234
 
<para>
235
 
Adds a new #GtkMenuItem to the menu's item list at the position
236
 
indicated by @position. 
237
 
</para>
238
 
 
239
 
@menu: a #GtkMenu.
240
 
@child: The #GtkMenuItem to add.
241
 
@pos: The position in the item list where @child is added.
242
 
      Positions are numbered from 0 to n-1.
243
 
@Deprecated: Use gtk_menu_shell_insert() instead.
244
 
 
245
 
 
246
 
<!-- ##### FUNCTION gtk_menu_reorder_child ##### -->
247
 
<para>
248
 
Moves a #GtkMenuItem to a new position within the #GtkMenu.
249
 
</para>
250
 
 
251
 
@menu: a #GtkMenu.
252
 
@child: the #GtkMenuItem to move.
253
 
@position: the new position to place @child.  Positions are numbered from 
254
 
0 to n-1.
255
 
 
256
 
 
257
 
<!-- ##### FUNCTION gtk_menu_attach ##### -->
258
 
<para>
259
 
 
260
 
</para>
261
 
 
262
 
@menu: 
263
 
@child: 
264
 
@left_attach: 
265
 
@right_attach: 
266
 
@top_attach: 
267
 
@bottom_attach: 
268
 
 
269
 
 
270
 
<!-- ##### FUNCTION gtk_menu_popup ##### -->
271
 
 
272
 
 
273
 
@menu: 
274
 
@parent_menu_shell: 
275
 
@parent_menu_item: 
276
 
@func: 
277
 
@data: 
278
 
@button: 
279
 
@activate_time: 
280
 
 
281
 
 
282
 
<!-- ##### FUNCTION gtk_menu_set_accel_group ##### -->
283
 
<para>
284
 
Set the #GtkAccelGroup which holds global accelerators for the menu.
285
 
This accelerator group needs to also be added to all windows that
286
 
this menu is being used in with gtk_window_add_accel_group(), in order
287
 
for those windows to support all the accelerators contained in this group.
288
 
</para>
289
 
 
290
 
@menu: a #GtkMenu.
291
 
@accel_group: the #GtkAccelGroup to be associated with the menu.
292
 
 
293
 
 
294
 
<!-- ##### FUNCTION gtk_menu_get_accel_group ##### -->
295
 
<para>
296
 
Gets the #GtkAccelGroup which holds global accelerators for the menu.
297
 
See gtk_menu_set_accel_group().
298
 
</para>
299
 
 
300
 
@menu: a #GtkMenu.
301
 
@Returns: the #GtkAccelGroup associated with the menu.
302
 
 
303
 
 
304
 
<!-- ##### FUNCTION gtk_menu_set_accel_path ##### -->
305
 
<para>
306
 
 
307
 
</para>
308
 
 
309
 
@menu: 
310
 
@accel_path: 
311
 
 
312
 
 
313
 
<!-- ##### FUNCTION gtk_menu_get_accel_path ##### -->
314
 
<para>
315
 
 
316
 
</para>
317
 
 
318
 
@menu: 
319
 
@Returns: 
320
 
 
321
 
 
322
 
<!-- ##### FUNCTION gtk_menu_set_title ##### -->
323
 
<para>
324
 
</para>
325
 
 
326
 
@menu: 
327
 
@title: 
328
 
 
329
 
 
330
 
<!-- ##### FUNCTION gtk_menu_get_title ##### -->
331
 
<para>
332
 
 
333
 
</para>
334
 
 
335
 
@menu: 
336
 
@Returns: 
337
 
 
338
 
 
339
 
<!-- ##### FUNCTION gtk_menu_set_monitor ##### -->
340
 
<para>
341
 
 
342
 
</para>
343
 
 
344
 
@menu: 
345
 
@monitor_num: 
346
 
 
347
 
 
348
 
<!-- ##### FUNCTION gtk_menu_get_monitor ##### -->
349
 
<para>
350
 
 
351
 
</para>
352
 
 
353
 
@menu: 
354
 
@Returns: 
355
 
 
356
 
 
357
 
<!-- ##### FUNCTION gtk_menu_get_tearoff_state ##### -->
358
 
<para>
359
 
 
360
 
</para>
361
 
 
362
 
@menu: 
363
 
@Returns: 
364
 
 
365
 
 
366
 
<!-- ##### FUNCTION gtk_menu_set_reserve_toggle_size ##### -->
367
 
<para>
368
 
 
369
 
</para>
370
 
 
371
 
@menu: 
372
 
@reserve_toggle_size: 
373
 
 
374
 
 
375
 
<!-- ##### FUNCTION gtk_menu_get_reserve_toggle_size ##### -->
376
 
<para>
377
 
 
378
 
</para>
379
 
 
380
 
@menu: 
381
 
@Returns: 
382
 
 
383
 
 
384
 
<!-- ##### FUNCTION gtk_menu_popdown ##### -->
385
 
<para>
386
 
Removes the menu from the screen.
387
 
</para>
388
 
 
389
 
@menu: a #GtkMenu.
390
 
 
391
 
 
392
 
<!-- ##### FUNCTION gtk_menu_reposition ##### -->
393
 
<para>
394
 
Repositions the menu according to its position function.
395
 
</para>
396
 
 
397
 
@menu: a #GtkMenu.
398
 
 
399
 
 
400
 
<!-- ##### FUNCTION gtk_menu_get_active ##### -->
401
 
<para>
402
 
Returns the selected menu item from the menu.  This is used by the 
403
 
#GtkOptionMenu.
404
 
</para>
405
 
 
406
 
@menu: a #GtkMenu.
407
 
@Returns: the #GtkMenuItem that was last selected in the menu.  If a 
408
 
selection has not yet been made, the first menu item is selected.
409
 
 
410
 
 
411
 
<!-- ##### FUNCTION gtk_menu_set_active ##### -->
412
 
<para>
413
 
Selects the specified menu item within the menu.  This is used by the
414
 
#GtkOptionMenu and should not be used by anyone else.
415
 
</para>
416
 
 
417
 
@menu: a #GtkMenu.
418
 
@index_: the index of the menu item to select.  Index values are from
419
 
0 to n-1.
420
 
 
421
 
 
422
 
<!-- ##### FUNCTION gtk_menu_set_tearoff_state ##### -->
423
 
<para>
424
 
Changes the tearoff state of the menu.  A menu is normally displayed 
425
 
as drop down menu which persists as long as the menu is active.  It can 
426
 
also be displayed as a tearoff menu which persists until it is closed 
427
 
or reattached.
428
 
</para>
429
 
 
430
 
@menu: a #GtkMenu.
431
 
@torn_off: If %TRUE, menu is displayed as a tearoff menu.
432
 
 
433
 
 
434
 
<!-- ##### FUNCTION gtk_menu_attach_to_widget ##### -->
435
 
<para>
436
 
Attaches the menu to the widget and provides a callback function that will
437
 
be invoked when the menu calls gtk_menu_detach() during its destruction.
438
 
</para>
439
 
 
440
 
@menu: a #GtkMenu.
441
 
@attach_widget: the #GtkWidget that the menu will be attached to.
442
 
@detacher: the user supplied callback function that will be called when 
443
 
the menu calls gtk_menu_detach().
444
 
 
445
 
 
446
 
<!-- ##### FUNCTION gtk_menu_detach ##### -->
447
 
<para>
448
 
Detaches the menu from the widget to which it had been attached.  
449
 
This function will call the callback function, @detacher, provided
450
 
when the gtk_menu_attach_to_widget() function was called.
451
 
</para>
452
 
 
453
 
@menu: a #GtkMenu.
454
 
 
455
 
 
456
 
<!-- ##### FUNCTION gtk_menu_get_attach_widget ##### -->
457
 
<para>
458
 
Returns the #GtkWidget that the menu is attached to.
459
 
</para>
460
 
 
461
 
@menu: a #GtkMenu.
462
 
@Returns: the #GtkWidget that the menu is attached to.
463
 
 
464
 
 
465
 
<!-- ##### FUNCTION gtk_menu_get_for_attach_widget ##### -->
466
 
<para>
467
 
 
468
 
</para>
469
 
 
470
 
@widget: 
471
 
@Returns: 
472
 
 
473
 
 
474
 
<!-- ##### USER_FUNCTION GtkMenuPositionFunc ##### -->
475
 
<para>
476
 
A user function supplied when calling gtk_menu_popup() which controls the
477
 
positioning of the menu when it is displayed.  The function sets the @x
478
 
and @y parameters to the coordinates where the menu is to be drawn.
479
 
To make the menu appear on a different monitor than the mouse pointer,
480
 
gtk_menu_set_monitor() must be called.
481
 
</para>
482
 
 
483
 
@menu: a #GtkMenu.
484
 
@x: address of the #gint representing the horizontal position where the
485
 
menu shall be drawn.  This is an output parameter.
486
 
@y: address of the #gint representing the vertical position where the
487
 
menu shall be drawn.  This is an output parameter.
488
 
@push_in: This parameter controls how menus placed outside the monitor are handled.
489
 
        If this is set to %TRUE and part of the menu is outside the monitor then
490
 
        GTK+ pushes the window into the visible area, effectively modifying the
491
 
        popup position.
492
 
        Note that moving and possibly resizing the menu around will alter the
493
 
        scroll position to keep the menu items "in place", i.e. at the same monitor
494
 
        position they would have been without resizing.
495
 
        In practice, this behavior is only useful for combobox popups or option
496
 
        menus and cannot be used to simply confine a menu to monitor boundaries.
497
 
        In that case, changing the scroll offset is not desirable.
498
 
@user_data: the data supplied by the user in the gtk_menu_popup() @data
499
 
parameter.
500
 
 
501
 
 
502
 
<!-- ##### USER_FUNCTION GtkMenuDetachFunc ##### -->
503
 
<para>
504
 
A user function supplied when calling gtk_menu_attach_to_widget() which 
505
 
will be called when the menu is later detached from the widget.
506
 
</para>
507
 
 
508
 
@attach_widget: the #GtkWidget that the menu is being detached from.
509
 
@menu: the #GtkMenu being detached.
510
 
 
511