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.