gtk.MenuItem

class MenuItem : gtk.Bin.Bin, gtk.ActionableIF.ActionableIF, gtk.ActivatableIF.ActivatableIF;
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 *child = gtk_bin_get_child (GTK_BIN (menu_item)); gtk_label_set_markup (GTK_LABEL (child), "new label with markup"); 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.

protected GtkMenuItem* gtkMenuItem ;
the main Gtk struct

GtkMenuItem* getMenuItemStruct ();
Get the main Gtk struct

protected void* getStruct ();
the main Gtk struct as a void*

this(GtkMenuItem* gtkMenuItem, bool ownedRef = false);
Sets our main struct and passes it to the parent class.

string getActionName ();
Gets the application set action code

this(string label, void delegate(MenuItem) dlg, string action);
Creates a new menu item with a label and a listener and a action. used for backward compatibily with DUI.

this(void delegate(MenuItem) dlg, string label, string action, bool mnemonic = true, AccelGroup accelGroup = null, char accelKey = '\x00', GdkModifierType modifierType = GdkModifierType.CONTROL_MASK, GtkAccelFlags accelFlags = GtkAccelFlags.VISIBLE);
Creates a new Item associated with a "activate" delegate and with a action code and optionally accelGroup

this(void delegate(MenuItem) dlg, string label, bool mnemonic = true);
Creates a new Item associated with a "activate" delegate

this(string label, bool mnemonic = true);
Creates a new GtkMenuItem whose child is a GtkLabel.

Params:
string label the text for the label
bool mnemonic if true the label will be created using gtk_label_new_with_mnemonic(), so underscores in label indicate the mnemonic for the menu item.

Throws:
ConstructionException GTK+ fails to create the object.

static GType getType ();
this();
Creates a new #GtkMenuItem.

Returns:
the newly created #GtkMenuItem

Throws:
ConstructionException GTK+ fails to create the object.

void itemActivate ();
Emits the #GtkMenuItem::activate signal on the given item

void deselect ();
Emits the #GtkMenuItem:: deselect signal on the given item.

string getAccelPath ();
Retrieve the accelerator path that was previously set on @menu_item.

See gtk_menu_item_set_accel_path() for details.

Returns:
the accelerator path corresponding to this menu item’s functionality, or %NULL if not set

Since:
2.14

string getLabel ();
Sets @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.

Since:
2.16

bool getReserveIndicator ();
Returns 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 indicator

Since:
3.0

bool getRightJustified ();
Gets whether the menu item appears justified at the right side of the menu bar.

Deprecated:
See gtk_menu_item_set_right_justified()

Returns:
%TRUE if the menu item will appear at the far right if added to a menu bar.

Widget getSubmenu ();
Gets the submenu underneath this menu item, if any. See gtk_menu_item_set_submenu().

Returns:
submenu for this menu item, or %NULL if none

bool getUseUnderline ();
Checks 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 accelerator key.

Since:
2.16

void select ();
Emits the #GtkMenuItem:: select signal on the given item.

void setAccelPath (string accelPath);
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 persistent storage (see gtk_accel_map_save() on this). To set up 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.

Note that @accel_path string will be stored in a #GQuark. Therefore, if you pass a static string, you can save some memory by interning it first with g_intern_static_string().

Params:
string accelPath accelerator path, corresponding to this menu item’s functionality, or %NULL to unset the current path.

void setLabel (string label);
Sets @text on the @menu_item label

Params:
string label the text you want to set

Since:
2.16

void setReserveIndicator (bool reserve);
Sets whether the @menu_item should reserve space for the submenu indicator, regardless if it actually has a submenu or not.

There should be little need for applications to call this functions.

Params:
bool reserve the new value

Since:
3.0

void setRightJustified (bool rightJustified);
Sets 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 reversed for a right-to-left language like Hebrew or Arabic, right-justified-menu-items appear at the left.)

Deprecated:
If you insist on using it, use gtk_widget_set_hexpand() and gtk_widget_set_halign().

Params:
bool rightJustified if %TRUE the menu item will appear at the far right if added to a menu bar

void setSubmenu (Menu submenu);
Sets or replaces the menu item’s submenu, or removes it when a %NULL submenu is passed.

Params:
Menu submenu the submenu, or %NULL

void setUseUnderline (bool setting);
If true, an underline in the text indicates the next character should be used for the mnemonic accelerator key.

Params:
bool setting %TRUE if underlines in the text indicate mnemonics

Since:
2.16

void toggleSizeAllocate (int allocation);
Emits the #GtkMenuItem::toggle-size-allocate signal on the given item.

Params:
int allocation the allocation to use as signal data.

void toggleSizeRequest (ref int requisition);
Emits the #GtkMenuItem::toggle-size-request signal on the given item.

Params:
int requisition the requisition to use as signal data.

gulong addOnActivate (void delegate(MenuItem) dlg, ConnectFlags connectFlags = cast(ConnectFlags)0);
Emitted when the item is activated.

gulong addOnActivateItem (void delegate(MenuItem) dlg, ConnectFlags connectFlags = cast(ConnectFlags)0);
Emitted when the item is activated, but also if the menu item has a submenu. For normal applications, the relevant signal is #GtkMenuItem::activate.

gulong addOnDeselect (void delegate(MenuItem) dlg, ConnectFlags connectFlags = cast(ConnectFlags)0);
gulong addOnSelect (void delegate(MenuItem) dlg, ConnectFlags connectFlags = cast(ConnectFlags)0);
gulong addOnToggleSizeAllocate (void delegate(int, MenuItem) dlg, ConnectFlags connectFlags = cast(ConnectFlags)0);
gulong addOnToggleSizeRequest (void delegate(void*, MenuItem) dlg, ConnectFlags connectFlags = cast(ConnectFlags)0);
Page was generated with on Sun Apr 23 22:52:56 2017