Package: gtk

Class gtk-menu-item

Superclasses

gtk-bin, gtk-container, gtk-widget, gtk-buildable, gtk-activatable, g-object, common-lisp:standard-object, common-lisp:t

Documented Subclasses

Direct Slots

accel-path
The accel-path property of type :string (Read / Write)
Sets the accelerator path of the menu item, through which runtime changes of the accelerator of the menu item caused by the user can be identified and saved to persistant storage.
Default value: nil
label
The label property of type :string (Read / Write)
The text for the child label.
Default value: ""
right-justified
The right-justified property of type :boolean (Read / Write)
Sets whether the menu item appears justified at the right side of a menu bar.
Default value: false
submenu
The submenu property of type gtk-menu (Read / Write)
The submenu attached to the menu item, or nil if it has none.
use-underline
The use-underline property of type :boolean (Read / Write)
True if underlines in the text indicate mnemonics.
Default value: false

Details

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 the gtk-bin class it can hold any valid child widget, although only a few are really useful.

GtkMenuItem as GtkBuildable

The gtk-menu-item implementation of the gtk-buildable interface supports adding a submenu by specifying "submenu" as the "type" attribute of a <child> element.

Example: A UI definition fragment with submenus.
<object class="GtkMenuItem">
  <child type="submenu">
    <object class="GtkMenu"/>
  </child>
</object>    

CSS nodes

 menuitem
 ├── <child>
 ╰── [arrow.right]    
The gtk-menu-item class has a single CSS node with name menuitem. If the menu item has a submenu, it gets another CSS node with name arrow, which has the .left or .right style class.

Style Property Details

arrow-scaling
The arrow-scaling style property of type :float (Read)
Amount of space used up by arrow, relative to the font size of the menu item.
Warning: The arrow-scaling style property has been deprecated since version 3.20 and should not be used in newly written code. Use the standard min-width/min-height CSS properties on the arrow node. The value of this style property is ignored.
Allowed values: [0,2]
Default value: 0.8
arrow-spacing
The arrow-spacing style property of type :int (Read)
Space between label and arrow.
Warning: The arrow-spacing style property has been deprecated since version 3.20 and should not be used in newly written code. Use the standard margin CSS property on the arrow node. The value of this style property is ignored.
Allowed values: >= 0
Default value: 10
horizontal-padding
The horizontal-padding style property of type :int (Read)
Padding to left and right of the menu item.
Warning: The horizontal-padding style property has been deprecated since version 3.8 and should not be used in newly written code. Use the standard padding CSS property, through objects like gtk-style-context and gtk-css-provider. The value of this style property is ignored.
Allowed values: >= 0
Default value: 3
selected-shadow-type
The selected-shadow-type style property of type gtk-shadow-type (Read)
Shadow type when the menu item is selected.
Warning: The selected-shadow-type style property has been deprecated since version 3.20 and should not be used in newly written code. Use CSS to determine the shadow. The value of this style property is ignored.
Default value: :none
toggle-spacing
The toggle-spacing style property of type :int (Read)
Space between icon and label.
Warning: The toggle-spacing style property has been deprecated since version 3.20 and should not be used in newly written code. Use the standard margin CSS property on the check or radio nodes. The value of this style property is ignored.
Allowed values: >= 0
Default value: 5
width-chars
The width-chars style property of type :int (Read)
The minimum desired width of the menu item in characters.
Warning: The width-chars style property has been deprecated since version 3.20 and should not be used in newly written code. Use the standard CSS property min-width. The value of this style property is ignored.
Allowed values: >= 0
Default value: 12

Signal Details

The "activate" signal
 lambda (item)    :action      
Emitted when the menu item is activated.
item
The gtk-menu-item widget which received the signal.
The "activate-item" signal
 lambda (item)    :run-first      
Emitted when the menu item is activated, but also if the menu item has a submenu. For normal applications, the relevant signal is "activate".
item
The gtk-menu-item widget which received the signal.
The "deselect" signal
 lambda (item)    :run-first      
item
The gtk-menu-item widget which received the signal.
The "select" signal
 lambda (item)    :run-first      
item
The gtk-menu-item widget which received the signal.
The "toggle-size-allocate" signal
 lambda (item arg)    :run-first      
item
The gtk-menu-item widget which received the signal.
arg
An integer which is not documented.
The "toggle-size-request" signal
 lambda (item arg)    :run-first      
item
The gtk-menu-item widget which received the signal.
arg
A pointer which is not documented.
 

Slot Access Functions

Inherited Slot Access Functions

See also

*2021-11-13