Next: , Previous: GtkMenuBar, Up: Top


58 GtkMenuItem

The widget used for item in menus

58.1 Overview

The <gtk-menu-item> widget and the derived widgets are the only valid childs for menus. Their function is to correctly handle highlighting, alignment, events and submenus.

As it derives from <gtk-bin> it can hold any valid child widget, altough only a few are really useful.

58.2 Usage

— Class: <gtk-menu-item>

Derives from <gtk-item>.

This class defines the following slots:

submenu
The submenu attached to the menu item, or NULL if it has none
— Signal on <gtk-menu-item>: activate

Emitted when the item is activated.

— Signal on <gtk-menu-item>: activate-item

Emitted when the item is activated, but also if the menu item has a submenu. For normal applications, the relevant signal is "activate".

— Signal on <gtk-menu-item>: toggle-size-request (arg0 <gpointer>)
— Signal on <gtk-menu-item>: toggle-size-allocate (arg0 <gint>)
— Function: gtk-menu-item-new ⇒  (ret <gtk-widget>)

Creates a new <gtk-menu-item>.

ret
the newly created <gtk-menu-item>
— Function: gtk-menu-item-new-with-label (label mchars) ⇒  (ret <gtk-widget>)

Creates a new <gtk-menu-item> whose child is a <gtk-label>.

label
the text for the label
ret
the newly created <gtk-menu-item>
— Function: gtk-menu-item-new-with-mnemonic (label mchars) ⇒  (ret <gtk-widget>)

Creates a new <gtk-menu-item> containing a label. The label will be created using gtk-label-new-with-mnemonic, so underscores in label indicate the mnemonic for the menu item.

label
The text of the button, with an underscore in front of the mnemonic character
ret
a new <gtk-menu-item>
— Function: gtk-menu-item-set-right-justified (self <gtk-menu-item>) (right_justified bool)
— Method: set-right-justified

Sets whether the menu item appears justified at the right side of a menu bar. This was traditionally done for "Help" menu items, but is now considered a bad idea. (If the widget layout is reversed for a right-to-left language like Hebrew or Arabic, right-justified-menu-items appear at the left.)

menu-item
a <gtk-menu-item>.
right-justified
if ‘#t’ the menu item will appear at the far right if added to a menu bar.
— Function: gtk-menu-item-set-submenu (self <gtk-menu-item>) (submenu <gtk-widget>)
— Method: set-submenu

Sets the widget submenu, or changes it.

menu-item
the menu item widget
submenu
the submenu
— Function: gtk-menu-item-set-accel-path (self <gtk-menu-item>) (accel_path mchars)
— Method: set-accel-path

Set the accelerator path on menu-item, through which runtime changes of the menu item's accelerator caused by the user can be identified and saved to persistant storage (see gtk-accel-map-save on this). To setup a default accelerator for this menu item, call gtk-accel-map-add-entry with the same accel-path. See also gtk-accel-map-add-entry on the specifics of accelerator paths, and gtk-menu-set-accel-path for a more convenient variant of this function.

This function is basically a convenience wrapper that handles calling gtk-widget-set-accel-path with the appropriate accelerator group for the menu item.

Note that you do need to set an accelerator on the parent menu with gtk-menu-set-accel-group for this to work.

menu-item
a valid <gtk-menu-item>
accel-path
accelerator path, corresponding to this menu item's functionality, or ‘#f’ to unset the current path.
— Function: gtk-menu-item-remove-submenu (self <gtk-menu-item>)
— Method: remove-submenu

Removes the widget's submenu.

menu-item
the menu item widget
— Function: gtk-menu-item-select (self <gtk-menu-item>)
— Method: select

Emits the "select" signal on the given item. Behaves exactly like <gtk-item-select>.

menu-item
the menu item
— Function: gtk-menu-item-deselect (self <gtk-menu-item>)
— Method: deselect

Emits the "deselect" signal on the given item. Behaves exactly like <gtk-item-deselect>.

menu-item
the menu item
— Function: gtk-menu-item-activate (self <gtk-menu-item>)
— Method: activate

Emits the "activate" signal on the given item

menu-item
the menu item
— Function: gtk-menu-item-toggle-size-request (self <gtk-menu-item>) ⇒  (requisition int)
— Method: toggle-size-request

Emits the "toggle_size_request" signal on the given item.

menu-item
the menu item
requisition
the requisition to use as signal data.
— Function: gtk-menu-item-toggle-size-allocate (self <gtk-menu-item>) (allocation int)
— Method: toggle-size-allocate

Emits the "toggle_size_allocate" signal on the given item.

menu-item
the menu item.
allocation
the allocation to use as signal data.
— Function: gtk-menu-item-get-right-justified (self <gtk-menu-item>) ⇒  (ret bool)
— Method: get-right-justified

Gets whether the menu item appears justified at the right side of the menu bar.

menu-item
a <gtk-menu-item>
ret
#t’ if the menu item will appear at the far right if added to a menu bar.
— Function: gtk-menu-item-get-submenu (self <gtk-menu-item>) ⇒  (ret <gtk-widget>)
— Method: get-submenu

Gets the submenu underneath this menu item, if any. See gtk-menu-item-set-submenu.

menu-item
a <gtk-menu-item>
ret
submenu for this menu item, or ‘#f’ if none.