MenuItem

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.

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.

class MenuItem : Bin , ActivatableIF {}

Constructors

this
this(GtkMenuItem* gtkMenuItem)

Sets our main struct and passes it to the parent class

this
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
this(void delegate(MenuItem) dlg, string label, string action, bool mnemonic, AccelGroup accelGroup, char accelKey, GdkModifierType modifierType, GtkAccelFlags accelFlags)

Creates a new Item associated with a "activate" delegate and with a action code and optionally accelGroup

this
this(void delegate(MenuItem) dlg, string label, bool mnemonic)

Creates a new Item associated with a "activate" delegate

this
this(string label, bool mnemonic)

Creates a new GtkMenuItem whose child is a GtkLabel.

this
this()

Creates a new GtkMenuItem.

Members

Functions

addOnActivate
void addOnActivate(void delegate(MenuItem) dlg, ConnectFlags connectFlags)

Emitted when the item is activated.

addOnActivateItem
void addOnActivateItem(void delegate(MenuItem) dlg, ConnectFlags connectFlags)

Emitted when the item is activated, but also if the menu item has a submenu. For normal applications, the relevant signal is "activate".

addOnDeselect
void addOnDeselect(void delegate(MenuItem) dlg, ConnectFlags connectFlags)
addOnSelect
void addOnSelect(void delegate(MenuItem) dlg, ConnectFlags connectFlags)
addOnToggleSizeAllocate
void addOnToggleSizeAllocate(void delegate(gint, MenuItem) dlg, ConnectFlags connectFlags)
addOnToggleSizeRequest
void addOnToggleSizeRequest(void delegate(void*, MenuItem) dlg, ConnectFlags connectFlags)

See Also GtkBin, GtkMenuShell

deselect
void deselect()

Emits the "deselect" signal on the given item. Behaves exactly like gtk_item_deselect.

getAccelPath
string getAccelPath()

Retrieve the accelerator path that was previously set on menu_item. See gtk_menu_item_set_accel_path() for details. Since 2.14

getActionName
string getActionName()

Gets the application set action code

getLabel
string getLabel()

Sets text on the menu_item label Since 2.16

getMenuItemStruct
GtkMenuItem* getMenuItemStruct()
Undocumented in source. Be warned that the author may not have intended to support it.
getReserveIndicator
int getReserveIndicator()

Returns whether the menu_item reserves space for the submenu indicator, regardless if it has a submenu or not.

getRightJustified
int getRightJustified()

Warning gtk_menu_item_get_right_justified has been deprecated since version 3.2 and should not be used in newly-written code. See gtk_menu_item_set_right_justified() Gets whether the menu item appears justified at the right side of the menu bar.

getStruct
void* getStruct()

the main Gtk struct as a void*

getSubmenu
Widget getSubmenu()

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

getUseUnderline
int getUseUnderline()

Checks if an underline in the text indicates the next character should be used for the mnemonic accelerator key. Since 2.16

itemActivate
void itemActivate()

Emits the "activate" signal on the given item

select
void select()

Emits the "select" signal on the given item. Behaves exactly like gtk_item_select.

setAccelPath
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().

setLabel
void setLabel(string label)

Sets text on the menu_item label Since 2.16

setReserveIndicator
void setReserveIndicator(int 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.

setRightJustified
void setRightJustified(int rightJustified)

Warning gtk_menu_item_set_right_justified has been deprecated since version 3.2 and should not be used in newly-written code. If you insist on using it, use gtk_widget_set_hexpand() and gtk_widget_set_halign(). 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.)

setStruct
void setStruct(GObject* obj)
Undocumented in source. Be warned that the author may not have intended to support it.
setSubmenu
void setSubmenu(Widget submenu)

Sets or replaces the menu item's submenu, or removes it when a NULL submenu is passed.

setUseUnderline
void setUseUnderline(int setting)

If true, an underline in the text indicates the next character should be used for the mnemonic accelerator key. Since 2.16

toggleSizeAllocate
void toggleSizeAllocate(int allocation)

Emits the "toggle-size-allocate" signal on the given item.

toggleSizeRequest
void toggleSizeRequest(int requisition)

Emits the "toggle-size-request" signal on the given item.

Mixins

__anonymous
mixin ActivatableT!(GtkMenuItem)
Undocumented in source.

Static functions

callBackActivate
void callBackActivate(GtkMenuItem* menuitemStruct, MenuItem _menuItem)
Undocumented in source. Be warned that the author may not have intended to support it.
callBackActivateItem
void callBackActivateItem(GtkMenuItem* menuitemStruct, MenuItem _menuItem)
Undocumented in source. Be warned that the author may not have intended to support it.
callBackDeselect
void callBackDeselect(GtkMenuItem* menuitemStruct, MenuItem _menuItem)
Undocumented in source. Be warned that the author may not have intended to support it.
callBackSelect
void callBackSelect(GtkMenuItem* menuitemStruct, MenuItem _menuItem)
Undocumented in source. Be warned that the author may not have intended to support it.
callBackToggleSizeAllocate
void callBackToggleSizeAllocate(GtkMenuItem* menuitemStruct, gint arg1, MenuItem _menuItem)
Undocumented in source. Be warned that the author may not have intended to support it.
callBackToggleSizeRequest
void callBackToggleSizeRequest(GtkMenuItem* menuitemStruct, void* arg1, MenuItem _menuItem)
Undocumented in source. Be warned that the author may not have intended to support it.

Variables

connectedSignals
int[string] connectedSignals;
gtkMenuItem
GtkMenuItem* gtkMenuItem;

the main Gtk struct

onActivateItemListeners
void delegate(MenuItem)[] onActivateItemListeners;
Undocumented in source.
onActivateListeners
void delegate(MenuItem)[] onActivateListeners;
Undocumented in source.
onDeselectListeners
void delegate(MenuItem)[] onDeselectListeners;
Undocumented in source.
onSelectListeners
void delegate(MenuItem)[] onSelectListeners;
Undocumented in source.
onToggleSizeAllocateListeners
void delegate(gint, MenuItem)[] onToggleSizeAllocateListeners;
Undocumented in source.
onToggleSizeRequestListeners
void delegate(void*, MenuItem)[] onToggleSizeRequestListeners;
Undocumented in source.

Inherited Members

From Bin

gtkBin
GtkBin* gtkBin;

the main Gtk struct

getBinStruct
GtkBin* getBinStruct()
Undocumented in source. Be warned that the author may not have intended to support it.
getStruct
void* getStruct()

the main Gtk struct as a void*

setStruct
void setStruct(GObject* obj)
Undocumented in source. Be warned that the author may not have intended to support it.
getChild
Widget getChild()

Gets the child of the GtkBin, or NULL if the bin contains no child widget. The returned widget does not have a reference added, so you do not need to unref it.

From ActivatableIF

getActivatableTStruct
GtkActivatable* getActivatableTStruct()
Undocumented in source.
getStruct
void* getStruct()

the main Gtk struct as a void*

doSetRelatedAction
void doSetRelatedAction(Action action)

Warning gtk_activatable_do_set_related_action is deprecated and should not be used in newly-written code. 3.10 This is a utility function for GtkActivatable implementors. When implementing GtkActivatable you must call this when handling changes of the "related-action", and you must also use this to break references in GObject->dispose(). This function adds a reference to the currently set related action for you, it also makes sure the GtkActivatable->update() method is called when the related GtkAction properties change and registers to the action's proxy list. Note Be careful to call this before setting the local copy of the GtkAction property, since this function uses gtk_activatable_get_related_action() to retrieve the previous action Since 2.16

getRelatedAction
Action getRelatedAction()

Warning gtk_activatable_get_related_action is deprecated and should not be used in newly-written code. 3.10 Gets the related GtkAction for activatable. Since 2.16

getUseActionAppearance
int getUseActionAppearance()

Warning gtk_activatable_get_use_action_appearance is deprecated and should not be used in newly-written code. 3.10 Gets whether this activatable should reset its layout and appearance when setting the related action or when the action changes appearance. Since 2.16

syncActionProperties
void syncActionProperties(Action action)

Warning gtk_activatable_sync_action_properties is deprecated and should not be used in newly-written code. 3.10 This is called to update the activatable completely, this is called internally when the "related-action" property is set or unset and by the implementing class when "use-action-appearance" changes. Since 2.16

setRelatedAction
void setRelatedAction(Action action)

Warning gtk_activatable_set_related_action is deprecated and should not be used in newly-written code. 3.10 Sets the related action on the activatable object. Note GtkActivatable implementors need to handle the "related-action" property and call gtk_activatable_do_set_related_action() when it changes. Since 2.16

setUseActionAppearance
void setUseActionAppearance(int useAppearance)

Warning gtk_activatable_set_use_action_appearance is deprecated and should not be used in newly-written code. 3.10 Sets whether this activatable should reset its layout and appearance when setting the related action or when the action changes appearance Note GtkActivatable implementors need to handle the "use-action-appearance" property and call gtk_activatable_sync_action_properties() to update activatable if needed. Since 2.16

Meta