gtk.menu_item
Module for [MenuItem] class
Types 3
The #GtkMenuItem widget and the derived widgets are the only valid children for menus. Their function is to correctly handle highlighting, alignment, events and submenus.
As a GtkMenuItem derives from #GtkBin it can hold any valid child widget, although only a few are really useful.
By default, a GtkMenuItem sets a #GtkAccelLabel as its child. GtkMenuItem has direct functions to set the label and its mnemonic. For more advanced label settings, you can fetch the child widget from the GtkBin.
An example for setting markup and accelerator on a MenuItem:
GtkWidget *menu_item = gtk_menu_item_new_with_label ("Example Menu Item");
GtkWidget *child = gtk_bin_get_child (GTK_BIN (menu_item));
gtk_label_set_markup (GTK_LABEL (child), "<i>new label</i> with <b>markup</b>");
gtk_accel_label_set_accel (GTK_ACCEL_LABEL (child), GDK_KEY_1, 0);GtkMenuItem as GtkBuildable
The GtkMenuItem implementation of the #GtkBuildable interface supports adding a submenu by specifying “submenu” as the “type” attribute of a <child> element.
An example of UI definition fragment with submenus:
<object class="GtkMenuItem">
<child type="submenu">
<object class="GtkMenu"/>
</child>
</object>CSS nodes
menuitem
├── <child>
╰── [arrow.right]GtkMenuItem has a single CSS node with name menuitem. If the menuitem has a submenu, it gets another CSS node with name arrow, which has the .left or .right style class.
MenuItemGidBuilder builder() static nothrowGet builder for [gtk.menu_item.MenuItem] Returns: New builder objectstring accelPath() @property nothrowGet `accelPath` property. Returns: Sets the accelerator path of the menu item, through which runtime changes of the menu item's accelerator caused by the user can be identified and saved to persist...void accelPath(string propval) @property nothrowSet `accelPath` property. Params: propval = Sets the accelerator path of the menu item, through which runtime changes of the menu item's accelerator caused by the user can be identified and saved t...void label(string propval) @property nothrowSet `label` property. Params: propval = The text for the child label.bool rightJustified() @property nothrowGet `rightJustified` property. Returns: Sets whether the menu item appears justified at the right side of a menu bar.void rightJustified(bool propval) @property nothrowSet `rightJustified` property. Params: propval = Sets whether the menu item appears justified at the right side of a menu bar.gtk.menu.Menu submenu() @property nothrowGet `submenu` property. Returns: The submenu attached to the menu item, or null if it has none.void submenu(gtk.menu.Menu propval) @property nothrowSet `submenu` property. Params: propval = The submenu attached to the menu item, or null if it has none.bool useUnderline() @property nothrowGet `useUnderline` property. Returns: true if underlines in the text indicate mnemonics.void useUnderline(bool propval) @property nothrowSet `useUnderline` property. Params: propval = true if underlines in the text indicate mnemonics.gtk.menu_item.MenuItem newWithLabel(string label) static nothrowCreates a new #GtkMenuItem whose child is a #GtkLabel.gtk.menu_item.MenuItem newWithMnemonic(string label) static nothrowCreates a new #GtkMenuItem containing a label.string getLabel() nothrowSets text on the menu_item label Returns: The text in the menu_item label. This is the internal string used by the label, and must not be modified.bool getReserveIndicator() nothrowReturns whether the menu_item reserves space for the submenu indicator, regardless if it has a submenu or not. Returns: true if menu_item always reserves space for the submenu indicatorbool getRightJustified() nothrowGets whether the menu item appears justified at the right side of the menu bar. Returns: true if the menu item will appear at the far right if added to a menu bar.gtk.widget.Widget getSubmenu() nothrowGets the submenu underneath this menu item, if any. See [gtk.menu_item.MenuItem.setSubmenu]. Returns: submenu for this menu item, or null if nonebool getUseUnderline() nothrowChecks if an underline in the text indicates the next character should be used for the mnemonic accelerator key. Returns: true if an embedded underline in the label indicates the mnemonic accelerat...void setAccelPath(string accelPath = null) nothrowSet 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 persistent storage (see [gtk.accel_map.AccelM...void setReserveIndicator(bool reserve) nothrowSets whether the menu_item should reserve space for the submenu indicator, regardless if it actually has a submenu or not.void setRightJustified(bool rightJustified) nothrowSets 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 rever...void setSubmenu(gtk.menu.Menu submenu = null) nothrowSets or replaces the menu item’s submenu, or removes it when a null submenu is passed.void setUseUnderline(bool setting) nothrowIf true, an underline in the text indicates the next character should be used for the mnemonic accelerator key.void toggleSizeAllocate(int allocation) nothrowEmits the #GtkMenuItem::toggle-size-allocate signal on the given item.void toggleSizeRequest(ref int requisition) nothrowEmits the #GtkMenuItem::toggle-size-request signal on the given item.gulong connectActivate(T)(T callback, Flag!"After" after = No.After) if (isCallable!T
&& is(ReturnType!T == void)
&& (Parameters!T.length < 1 || (ParameterStorageClassTuple!T[0] == ParameterStorageClass.none && is(Parameters!T[0] : gtk.menu_item.MenuItem)))
&& Parameters!T.length < 2) nothrowConnect to `Activate` signal.gulong connectActivateItem(T)(T callback, Flag!"After" after = No.After) if (isCallable!T
&& is(ReturnType!T == void)
&& (Parameters!T.length < 1 || (ParameterStorageClassTuple!T[0] == ParameterStorageClass.none && is(Parameters!T[0] : gtk.menu_item.MenuItem)))
&& Parameters!T.length < 2) nothrowConnect to `ActivateItem` signal.gulong connectDeselect(T)(T callback, Flag!"After" after = No.After) if (isCallable!T
&& is(ReturnType!T == void)
&& (Parameters!T.length < 1 || (ParameterStorageClassTuple!T[0] == ParameterStorageClass.none && is(Parameters!T[0] : gtk.menu_item.MenuItem)))
&& Parameters!T.length < 2) nothrowConnect to `Deselect` signal.gulong connectSelect(T)(T callback, Flag!"After" after = No.After) if (isCallable!T
&& is(ReturnType!T == void)
&& (Parameters!T.length < 1 || (ParameterStorageClassTuple!T[0] == ParameterStorageClass.none && is(Parameters!T[0] : gtk.menu_item.MenuItem)))
&& Parameters!T.length < 2) nothrowConnect to `Select` signal.gulong connectToggleSizeAllocate(T)(T callback, Flag!"After" after = No.After) if (isCallable!T
&& is(ReturnType!T == void)
&& (Parameters!T.length < 1 || (ParameterStorageClassTuple!T[0] == ParameterStorageClass.none && is(Parameters!T[0] == int)))
&& (Parameters!T.length < 2 || (ParameterStorageClassTuple!T[1] == ParameterStorageClass.none && is(Parameters!T[1] : gtk.menu_item.MenuItem)))
&& Parameters!T.length < 3) nothrowConnect to `ToggleSizeAllocate` signal.gulong connectToggleSizeRequest(T)(T callback, Flag!"After" after = No.After) if (isCallable!T
&& is(ReturnType!T == void)
&& (Parameters!T.length < 1 || (ParameterStorageClassTuple!T[0] == ParameterStorageClass.none && is(Parameters!T[0] == void *)))
&& (Parameters!T.length < 2 || (ParameterStorageClassTuple!T[1] == ParameterStorageClass.none && is(Parameters!T[1] : gtk.menu_item.MenuItem)))
&& Parameters!T.length < 3) nothrowConnect to `ToggleSizeRequest` signal.Fluent builder implementation template for gtk.menu_item.MenuItem
T accelPath(string propval) nothrowSet `accelPath` property. Params: propval = Sets the accelerator path of the menu item, through which runtime changes of the menu item's accelerator caused by the user can be identified and saved t...T label(string propval) nothrowSet `label` property. Params: propval = The text for the child label. Returns: Builder instance for fluent chainingT rightJustified(bool propval) nothrowSet `rightJustified` property. Params: propval = Sets whether the menu item appears justified at the right side of a menu bar. Returns: Builder instance for fluent chainingT submenu(gtk.menu.Menu propval) nothrowSet `submenu` property. Params: propval = The submenu attached to the menu item, or null if it has none. Returns: Builder instance for fluent chainingT useUnderline(bool propval) nothrowSet `useUnderline` property. Params: propval = true if underlines in the text indicate mnemonics. Returns: Builder instance for fluent chainingFluent builder for gtk.menu_item.MenuItem