- gtkMenuItem
GtkMenuItem* gtkMenuItem;
- getMenuItemStruct
GtkMenuItem* getMenuItemStruct()
- 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.
- __anonymous
mixin ActionableT!(GtkMenuItem)
Undocumented in source.
- __anonymous
mixin ActivatableT!(GtkMenuItem)
Undocumented in source.
- getActionName
string getActionName()
Gets the application set action code
- getType
GType getType()
- itemActivate
void itemActivate()
Emits the #GtkMenuItem::activate signal on the given item
- deselect
void deselect()
Emits the #GtkMenuItem::deselect signal on the given item.
- getAccelPath
string getAccelPath()
Retrieve the accelerator path that was previously set on @menu_item.
- getLabel
string getLabel()
Sets @text on the @menu_item label
- getReserveIndicator
bool getReserveIndicator()
Returns whether the @menu_item reserves space for
the submenu indicator, regardless if it has a submenu
or not.
- getRightJustified
bool getRightJustified()
Gets whether the menu item appears justified at the right
side of the menu bar.
- getSubmenu
Widget getSubmenu()
Gets the submenu underneath this menu item, if any.
See gtk_menu_item_set_submenu().
- getUseUnderline
bool getUseUnderline()
Checks if an underline in the text indicates the next character
should be used for the mnemonic accelerator key.
- select
void select()
Emits the #GtkMenuItem::select signal on the given item.
- 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.
- setLabel
void setLabel(string label)
Sets @text on the @menu_item label
- setReserveIndicator
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.
- setRightJustified
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.)
- setSubmenu
void setSubmenu(Menu submenu)
Sets or replaces the menu item’s submenu, or removes it when a %NULL
submenu is passed.
- setUseUnderline
void setUseUnderline(bool setting)
If true, an underline in the text indicates the next character
should be used for the mnemonic accelerator key.
- toggleSizeAllocate
void toggleSizeAllocate(int allocation)
Emits the #GtkMenuItem::toggle-size-allocate signal on the given item.
- toggleSizeRequest
void toggleSizeRequest(int requisition)
Emits the #GtkMenuItem::toggle-size-request signal on the given item.
- OnActivateDelegateWrapper
class OnActivateDelegateWrapper
Undocumented in source.
- onActivateListeners
OnActivateDelegateWrapper[] onActivateListeners;
Undocumented in source.
- addOnActivate
gulong addOnActivate(void delegate(MenuItem) dlg, ConnectFlags connectFlags)
Emitted when the item is activated.
- callBackActivate
void callBackActivate(GtkMenuItem* menuitemStruct, OnActivateDelegateWrapper wrapper)
Undocumented in source. Be warned that the author may not have intended to support it.
- callBackActivateDestroy
void callBackActivateDestroy(OnActivateDelegateWrapper wrapper, GClosure* closure)
Undocumented in source. Be warned that the author may not have intended to support it.
- internalRemoveOnActivate
void internalRemoveOnActivate(OnActivateDelegateWrapper source)
Undocumented in source. Be warned that the author may not have intended to support it.
- OnActivateItemDelegateWrapper
class OnActivateItemDelegateWrapper
Undocumented in source.
- onActivateItemListeners
OnActivateItemDelegateWrapper[] onActivateItemListeners;
Undocumented in source.
- addOnActivateItem
gulong 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
#GtkMenuItem::activate.
- callBackActivateItem
void callBackActivateItem(GtkMenuItem* menuitemStruct, OnActivateItemDelegateWrapper wrapper)
Undocumented in source. Be warned that the author may not have intended to support it.
- callBackActivateItemDestroy
void callBackActivateItemDestroy(OnActivateItemDelegateWrapper wrapper, GClosure* closure)
Undocumented in source. Be warned that the author may not have intended to support it.
- internalRemoveOnActivateItem
void internalRemoveOnActivateItem(OnActivateItemDelegateWrapper source)
Undocumented in source. Be warned that the author may not have intended to support it.
- OnDeselectDelegateWrapper
class OnDeselectDelegateWrapper
Undocumented in source.
- onDeselectListeners
OnDeselectDelegateWrapper[] onDeselectListeners;
Undocumented in source.
- addOnDeselect
gulong addOnDeselect(void delegate(MenuItem) dlg, ConnectFlags connectFlags)
- callBackDeselect
void callBackDeselect(GtkMenuItem* menuitemStruct, OnDeselectDelegateWrapper wrapper)
Undocumented in source. Be warned that the author may not have intended to support it.
- callBackDeselectDestroy
void callBackDeselectDestroy(OnDeselectDelegateWrapper wrapper, GClosure* closure)
Undocumented in source. Be warned that the author may not have intended to support it.
- internalRemoveOnDeselect
void internalRemoveOnDeselect(OnDeselectDelegateWrapper source)
Undocumented in source. Be warned that the author may not have intended to support it.
- OnSelectDelegateWrapper
class OnSelectDelegateWrapper
Undocumented in source.
- onSelectListeners
OnSelectDelegateWrapper[] onSelectListeners;
Undocumented in source.
- addOnSelect
gulong addOnSelect(void delegate(MenuItem) dlg, ConnectFlags connectFlags)
- callBackSelect
void callBackSelect(GtkMenuItem* menuitemStruct, OnSelectDelegateWrapper wrapper)
Undocumented in source. Be warned that the author may not have intended to support it.
- callBackSelectDestroy
void callBackSelectDestroy(OnSelectDelegateWrapper wrapper, GClosure* closure)
Undocumented in source. Be warned that the author may not have intended to support it.
- internalRemoveOnSelect
void internalRemoveOnSelect(OnSelectDelegateWrapper source)
Undocumented in source. Be warned that the author may not have intended to support it.
- OnToggleSizeAllocateDelegateWrapper
class OnToggleSizeAllocateDelegateWrapper
Undocumented in source.
- onToggleSizeAllocateListeners
OnToggleSizeAllocateDelegateWrapper[] onToggleSizeAllocateListeners;
Undocumented in source.
- addOnToggleSizeAllocate
gulong addOnToggleSizeAllocate(void delegate(int, MenuItem) dlg, ConnectFlags connectFlags)
- callBackToggleSizeAllocate
void callBackToggleSizeAllocate(GtkMenuItem* menuitemStruct, int object, OnToggleSizeAllocateDelegateWrapper wrapper)
Undocumented in source. Be warned that the author may not have intended to support it.
- callBackToggleSizeAllocateDestroy
void callBackToggleSizeAllocateDestroy(OnToggleSizeAllocateDelegateWrapper wrapper, GClosure* closure)
Undocumented in source. Be warned that the author may not have intended to support it.
- internalRemoveOnToggleSizeAllocate
void internalRemoveOnToggleSizeAllocate(OnToggleSizeAllocateDelegateWrapper source)
Undocumented in source. Be warned that the author may not have intended to support it.
- OnToggleSizeRequestDelegateWrapper
class OnToggleSizeRequestDelegateWrapper
Undocumented in source.
- onToggleSizeRequestListeners
OnToggleSizeRequestDelegateWrapper[] onToggleSizeRequestListeners;
Undocumented in source.
- addOnToggleSizeRequest
gulong addOnToggleSizeRequest(void delegate(void*, MenuItem) dlg, ConnectFlags connectFlags)
- callBackToggleSizeRequest
void callBackToggleSizeRequest(GtkMenuItem* menuitemStruct, void* object, OnToggleSizeRequestDelegateWrapper wrapper)
Undocumented in source. Be warned that the author may not have intended to support it.
- callBackToggleSizeRequestDestroy
void callBackToggleSizeRequestDestroy(OnToggleSizeRequestDelegateWrapper wrapper, GClosure* closure)
Undocumented in source. Be warned that the author may not have intended to support it.
- internalRemoveOnToggleSizeRequest
void internalRemoveOnToggleSizeRequest(OnToggleSizeRequestDelegateWrapper source)
Undocumented in source. Be warned that the author may not have intended to support it.
A GtkImageMenuItem is a menu item which has an icon next to the text label.
This is functionally equivalent to:
|[<!-- language="C" --> GtkWidget *box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6); GtkWidget *icon = gtk_image_new_from_icon_name ("folder-music-symbolic", GTK_ICON_SIZE_MENU); GtkWidget *label = gtk_label_new ("Music"); GtkWidget *menu_item = gtk_menu_item_new ();
gtk_container_add (GTK_CONTAINER (box), icon); gtk_container_add (GTK_CONTAINER (box), label);
gtk_container_add (GTK_CONTAINER (menu_item), box);
gtk_widget_show_all (menu_item); ]|
Note that the user may disable display of menu icons using the #GtkSettings:gtk-menu-images setting, so make sure to still fill in the text label. If you want to ensure that your menu items show an icon you are strongly encouraged to use a #GtkMenuItem with a #GtkImage instead.
#GtkImageMenuItem has been deprecated since GTK+ 3.10. If you want to display an icon in a menu item, you should use #GtkMenuItem and pack a #GtkBox with a #GtkImage and a #GtkLabel instead. You should also consider using #GtkBuilder and the XML #GMenu description for creating menus, by following the [GMenu guide]https://developer.gnome.org/GMenu/. You should consider using icons in menu items only sparingly, and for "objects" (or "nouns") elements only, like bookmarks, files, and links; "actions" (or "verbs") should not have icons.
Furthermore, if you would like to display keyboard accelerator, you must pack the accel label into the box using gtk_box_pack_end() and align the label, otherwise the accelerator will not display correctly. The following code snippet adds a keyboard accelerator to the menu item, with a key binding of Ctrl+M:
|[<!-- language="C" --> GtkWidget *box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6); GtkWidget *icon = gtk_image_new_from_icon_name ("folder-music-symbolic", GTK_ICON_SIZE_MENU); GtkWidget *label = gtk_accel_label_new ("Music"); GtkWidget *menu_item = gtk_menu_item_new (); GtkAccelGroup *accel_group = gtk_accel_group_new ();
gtk_container_add (GTK_CONTAINER (box), icon);
gtk_label_set_use_underline (GTK_LABEL (label), TRUE); gtk_label_set_xalign (GTK_LABEL (label), 0.0);
gtk_widget_add_accelerator (menu_item, "activate", accel_group, GDK_KEY_m, GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE); gtk_accel_label_set_accel_widget (GTK_ACCEL_LABEL (label), menu_item);
gtk_box_pack_end (GTK_BOX (box), label, TRUE, TRUE, 0);
gtk_container_add (GTK_CONTAINER (menu_item), box);
gtk_widget_show_all (menu_item); ]|