11.85Class GtkMenuItem

The widget used for item in menus

Class GtkMenuItem

The GtkMenuItem 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 GtkBin it can hold any valid child widget, altough only a few are really useful.

[...]

Methods
activateEmits the "activate" signal on the given item.
deselectEmits the "deselect" signal on the given item.
get_accel_pathRetrieve the accelerator path that was previously set on menu_item.
get_labelGets the text on the menu_item label
get_right_justifiedGets whether the menu item appears justified at the right side of the menu bar.
get_submenuGets the submenu underneath this menu item, if any.
get_use_underlineChecks if an underline in the text indicates the next character should be used for the mnemonic accelerator key.
new_with_labelCreates a new GtkMenuItem whose child is a GtkLabel.
new_with_mnemonicCreates a new GtkMenuItem containing a label.
selectEmits the "select" signal on the given item.
set_accel_pathSet 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).
set_labelSets text on the menu_item label
set_right_justifiedSets whether the menu item appears justified at the right side of a menu bar.
set_submenuSets or replaces the menu item's submenu, or removes it when a NULL submenu is passed.
set_use_underlineIf true, an underline in the text indicates the next character should be used for the mnemonic accelerator key.
signal_activateEmitted when the item is activated.
signal_activate_itemEmitted when the item is activated, but also if the menu item has a submenu.

Methods

activate

Emits the "activate" signal on the given item.

GtkMenuItem.activate()

deselect

Emits the "deselect" signal on the given item.

GtkMenuItem.deselect()

Behaves exactly like gtk_item_deselect.

get_accel_path

Retrieve the accelerator path that was previously set on menu_item.

GtkMenuItem.get_accel_path()
Returnthe accelerator path corresponding to this menu item's functionality, or NULL if not set

get_label

Gets the text on the menu_item label

GtkMenuItem.get_label()
ReturnThe text in the menu_item label.

get_right_justified

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

GtkMenuItem.get_right_justified()
ReturnTRUE if the menu item will appear at the far right if added to a menu bar.

get_submenu

Gets the submenu underneath this menu item, if any.

GtkMenuItem.get_submenu()
Returnsubmenu for this menu item, or NULL if none.

get_use_underline

Checks if an underline in the text indicates the next character should be used for the mnemonic accelerator key.

GtkMenuItem.get_use_underline()
ReturnTRUE if an embedded underline in the label indicates the mnemonic accelerator key.

new_with_label

Creates a new GtkMenuItem whose child is a GtkLabel.

GtkMenuItem.new_with_label( label )
label the text for the label
Returnthe newly created GtkMenuItem

new_with_mnemonic

Creates a new GtkMenuItem containing a label.

GtkMenuItem.new_with_mnemonic( label )
label The text of the button, with an underscore in front of the mnemonic character
Returna new GtkMenuItem

The label will be created using gtk_label_new_with_mnemonic(), so underscores in label indicate the mnemonic for the menu item.

select

Emits the "select" signal on the given item.

GtkMenuItem.select()

Behaves exactly like gtk_item_select.

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).

GtkMenuItem.set_accel_path( accel_path )
accel_path accelerator path, corresponding to this menu item's functionality, or NULL to unset the current path

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.

set_label

Sets text on the menu_item label

GtkMenuItem.set_label( label )
label the text you want to set

set_right_justified

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

GtkMenuItem.set_right_justified( right_justified )
right_justified if TRUE the menu item will appear at the far right if added to 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.)

set_submenu

Sets or replaces the menu item's submenu, or removes it when a NULL submenu is passed.

GtkMenuItem.set_submenu( submenu )
submenu the submenu, or NULL.

set_use_underline

If true, an underline in the text indicates the next character should be used for the mnemonic accelerator key.

GtkMenuItem.set_use_underline( setting )
setting TRUE if underlines in the text indicate mnemonics

signal_activate

Emitted when the item is activated.

GtkMenuItem.signal_activate()

signal_activate_item

Emitted when the item is activated, but also if the menu item has a submenu.

GtkMenuItem.signal_activate_item()

For normal applications, the relevant signal is "activate".

Made with http://www.falconpl.org