1 <!-- ##### SECTION Title ##### -->
4 <!-- ##### SECTION Short_Description ##### -->
5 a drop down menu widget.
7 <!-- ##### SECTION Long_Description ##### -->
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.
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.
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
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.
32 <title>Connecting the popup signal handler.</title>
34 /* connect our handler which will popup the menu */
35 g_signal_connect_swapped (GTK_OBJECT (window), "button_press_event",
36 G_CALLBACK (my_popup_handler), GTK_OBJECT (menu));
41 <title>Signal handler which displays a popup menu.</title>
44 my_popup_handler (GtkWidget *widget, GdkEvent *event)
47 GdkEventButton *event_button;
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);
53 /* The "widget" is the menu that was supplied when
54 * g_signal_connect_swapped() was called.
56 menu = GTK_MENU (widget);
58 if (event->type == GDK_BUTTON_PRESS)
60 event_button = (GdkEventButton *) event;
61 if (event_button->button == 3)
63 gtk_menu_popup (menu, NULL, NULL, NULL, NULL,
64 event_button->button, event_button->time);
74 <!-- ##### SECTION See_Also ##### -->
79 <!-- ##### STRUCT GtkMenu ##### -->
81 The #GtkMenu struct contains private data only, and
82 should be accessed using the functions below.
86 <!-- ##### FUNCTION gtk_menu_new ##### -->
88 Creates a new #GtkMenu.
91 @Returns: a new #GtkMenu.
94 <!-- ##### FUNCTION gtk_menu_set_screen ##### -->
103 <!-- ##### MACRO gtk_menu_append ##### -->
105 Adds a new #GtkMenuItem to the end of the menu's item list.
109 @child: The #GtkMenuItem to add.
110 <!-- # Unused Parameters # -->
115 <!-- ##### MACRO gtk_menu_prepend ##### -->
117 Adds a new #GtkMenuItem to the beginning of the menu's item list.
121 @child: The #GtkMenuItem to add.
122 <!-- # Unused Parameters # -->
128 <!-- ##### MACRO gtk_menu_insert ##### -->
130 Adds a new #GtkMenuItem to the menu's item list at the position
131 indicated by @position.
135 @child: The #GtkMenuItem to add.
137 <!-- # Unused Parameters # -->
138 @position: The position in the item list where @child is added.
139 Positions are numbered from 0 to n-1.
142 <!-- ##### FUNCTION gtk_menu_reorder_child ##### -->
144 Moves a #GtkMenuItem to a new position within the #GtkMenu.
148 @child: the #GtkMenuItem to move.
149 @position: the new position to place @child. Positions are numbered from
153 <!-- ##### FUNCTION gtk_menu_attach ##### -->
166 <!-- ##### FUNCTION gtk_menu_popup ##### -->
178 <!-- ##### FUNCTION gtk_menu_set_accel_group ##### -->
180 Set the #GtkAccelGroup which holds global accelerators for the menu.
181 This accelerator group needs to also be added to all windows that
182 this menu is being used in with gtk_window_add_accel_group(), in order
183 for those windows to support all the accelerators contained in this group.
187 @accel_group: the #GtkAccelGroup to be associated with the menu.
190 <!-- ##### FUNCTION gtk_menu_get_accel_group ##### -->
192 Gets the #GtkAccelGroup which holds global accelerators for the menu.
193 See gtk_menu_set_accel_group().
197 @Returns: the #GtkAccelGroup associated with the menu.
200 <!-- ##### FUNCTION gtk_menu_set_accel_path ##### -->
209 <!-- ##### FUNCTION gtk_menu_set_title ##### -->
217 <!-- ##### FUNCTION gtk_menu_get_tearoff_state ##### -->
226 <!-- ##### FUNCTION gtk_menu_get_title ##### -->
235 <!-- ##### FUNCTION gtk_menu_popdown ##### -->
237 Removes the menu from the screen.
243 <!-- ##### FUNCTION gtk_menu_reposition ##### -->
245 Repositions the menu according to its position function.
251 <!-- ##### FUNCTION gtk_menu_get_active ##### -->
253 Returns the selected menu item from the menu. This is used by the
258 @Returns: the #GtkMenuItem that was last selected in the menu. If a
259 selection has not yet been made, the first menu item is selected.
262 <!-- ##### FUNCTION gtk_menu_set_active ##### -->
264 Selects the specified menu item within the menu. This is used by the
265 #GtkOptionMenu and should not be used by anyone else.
269 @index_: the index of the menu item to select. Index values are from
273 <!-- ##### FUNCTION gtk_menu_set_tearoff_state ##### -->
275 Changes the tearoff state of the menu. A menu is normally displayed
276 as drop down menu which persists as long as the menu is active. It can
277 also be displayed as a tearoff menu which persists until it is closed
282 @torn_off: If %TRUE, menu is displayed as a tearoff menu.
285 <!-- ##### FUNCTION gtk_menu_attach_to_widget ##### -->
287 Attaches the menu to the widget and provides a callback function that will
288 be invoked when the menu calls gtk_menu_detach() during its destruction.
292 @attach_widget: the #GtkWidget that the menu will be attached to.
293 @detacher: the user supplied callback function that will be called when
294 the menu calls gtk_menu_detach().
297 <!-- ##### FUNCTION gtk_menu_detach ##### -->
299 Detaches the menu from the widget to which it had been attached.
300 This function will call the callback function, @detacher, provided
301 when the gtk_menu_attach_to_widget() function was called.
307 <!-- ##### FUNCTION gtk_menu_get_attach_widget ##### -->
309 Returns the #GtkWidget that the menu is attached to.
313 @Returns: the #GtkWidget that the menu is attached to.
316 <!-- ##### USER_FUNCTION GtkMenuPositionFunc ##### -->
318 A user function supplied when calling gtk_menu_popup() which controls the
319 positioning of the menu when it is displayed. The function sets the @x
320 and @y parameters to the coordinates where the menu is to be drawn.
324 @x: address of the #gint representing the horizontal position where the
325 menu shall be drawn. This is an output parameter.
326 @y: address of the #gint representing the vertical position where the
327 menu shall be drawn. This is an output parameter.
329 @user_data: the data supplied by the user in the gtk_menu_popup() @data
333 <!-- ##### USER_FUNCTION GtkMenuDetachFunc ##### -->
335 A user function supplied when calling gtk_menu_attach_to_widget() which
336 will be called when the menu is later detached from the widget.
339 @attach_widget: the #GtkWidget that the menu is being detached from.
340 @menu: the #GtkMenu being detached.
343 <!-- ##### FUNCTION gtk_menu_set_monitor ##### -->
352 <!-- ##### SIGNAL GtkMenu::move-scroll ##### -->
357 @menu: the object which received the signal.
360 <!-- ##### ARG GtkMenu:tearoff-title ##### -->
365 <!-- ##### ARG GtkMenu:bottom-attach ##### -->
370 <!-- ##### ARG GtkMenu:left-attach ##### -->
375 <!-- ##### ARG GtkMenu:right-attach ##### -->
380 <!-- ##### ARG GtkMenu:top-attach ##### -->
385 <!-- ##### ARG GtkMenu:horizontal-offset ##### -->
390 <!-- ##### ARG GtkMenu:vertical-offset ##### -->
395 <!-- ##### ARG GtkMenu:vertical-padding ##### -->