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 | |
activate | Emits the "activate" signal on the given item. |
deselect | Emits the "deselect" signal on the given item. |
get_accel_path | Retrieve the accelerator path that was previously set on menu_item. |
get_label | Gets the text on the menu_item label |
get_right_justified | Gets whether the menu item appears justified at the right side of the menu bar. |
get_submenu | Gets the submenu underneath this menu item, if any. |
get_use_underline | Checks if an underline in the text indicates the next character should be used for the mnemonic accelerator key. |
new_with_label | Creates a new GtkMenuItem whose child is a GtkLabel. |
new_with_mnemonic | Creates a new GtkMenuItem containing a label. |
select | Emits the "select" signal on the given item. |
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). |
set_label | Sets text on the menu_item label |
set_right_justified | Sets whether the menu item appears justified at the right side of a menu bar. |
set_submenu | Sets or replaces the menu item's submenu, or removes it when a NULL submenu is passed. |
set_use_underline | If true, an underline in the text indicates the next character should be used for the mnemonic accelerator key. |
signal_activate | Emitted when the item is activated. |
signal_activate_item | Emitted when the item is activated, but also if the menu item has a submenu. |
Emits the "activate" signal on the given item.
GtkMenuItem.activate()
Emits the "deselect" signal on the given item.
GtkMenuItem.deselect()
Behaves exactly like gtk_item_deselect.
Retrieve the accelerator path that was previously set on menu_item.
GtkMenuItem.get_accel_path()
Return | the accelerator path corresponding to this menu item's functionality, or NULL if not set |
Gets the text on the menu_item label
GtkMenuItem.get_label()
Return | The text in the menu_item label. |
Gets whether the menu item appears justified at the right side of the menu bar.
GtkMenuItem.get_right_justified()
Return | TRUE if the menu item will appear at the far right if added to a menu bar. |
Gets the submenu underneath this menu item, if any.
GtkMenuItem.get_submenu()
Return | submenu for this menu item, or NULL if none. |
Checks if an underline in the text indicates the next character should be used for the mnemonic accelerator key.
GtkMenuItem.get_use_underline()
Return | TRUE if an embedded underline in the label indicates the mnemonic accelerator key. |
Creates a new GtkMenuItem whose child is a GtkLabel.
GtkMenuItem.new_with_label( label )
label | the text for the label |
Return | the newly created GtkMenuItem |
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 |
Return | a new GtkMenuItem |
The label will be created using gtk_label_new_with_mnemonic(), so underscores in label indicate the mnemonic for the menu item.
Emits the "select" signal on the given item.
GtkMenuItem.select()
Behaves exactly like gtk_item_select.
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.
Sets text on the menu_item label
GtkMenuItem.set_label( label )
label | the text you want to set |
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.)
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. |
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 |
Emitted when the item is activated.
GtkMenuItem.signal_activate()
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".