gi-gtk-3.0.11: Gtk bindings

CopyrightWill Thompson, Iñaki García Etxebarria and Jonas Platte
LicenseLGPL-2.1
MaintainerIñaki García Etxebarria (garetxe@gmail.com)
Safe HaskellNone
LanguageHaskell2010

GI.Gtk.Objects.MenuItem

Contents

Description

The MenuItem 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 Bin it can hold any valid child widget, although only a few are really useful.

By default, a GtkMenuItem sets a AccelLabel 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:

C code

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 Buildable interface supports adding a submenu by specifying “submenu” as the “type” attribute of a <child> element.

An example of UI definition fragment with submenus: > >class="GtkMenuItem" > type="submenu" > class="GtkMenu"/ > /child >/object

CSS nodes

plain code

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.

Synopsis

Exported types

Methods

activate

data MenuItemActivateMethodInfo Source #

Instances

((~) * signature (m ()), MonadIO m, IsMenuItem a) => MethodInfo * MenuItemActivateMethodInfo a signature Source # 

menuItemActivate Source #

Arguments

:: (HasCallStack, MonadIO m, IsMenuItem a) 
=> a

menuItem: the menu item

-> m () 

Emits the MenuItem::activate signal on the given item

deselect

data MenuItemDeselectMethodInfo Source #

Instances

((~) * signature (m ()), MonadIO m, IsMenuItem a) => MethodInfo * MenuItemDeselectMethodInfo a signature Source # 

menuItemDeselect Source #

Arguments

:: (HasCallStack, MonadIO m, IsMenuItem a) 
=> a

menuItem: the menu item

-> m () 

Emits the MenuItem::deselect signal on the given item.

getAccelPath

menuItemGetAccelPath Source #

Arguments

:: (HasCallStack, MonadIO m, IsMenuItem a) 
=> a

menuItem: a valid MenuItem

-> m (Maybe Text)

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

Retrieve the accelerator path that was previously set on menuItem.

See menuItemSetAccelPath for details.

Since: 2.14

getLabel

menuItemGetLabel Source #

Arguments

:: (HasCallStack, MonadIO m, IsMenuItem a) 
=> a

menuItem: a MenuItem

-> m Text

Returns: The text in the menuItem label. This is the internal string used by the label, and must not be modified.

Sets text on the menuItem label

Since: 2.16

getReserveIndicator

menuItemGetReserveIndicator Source #

Arguments

:: (HasCallStack, MonadIO m, IsMenuItem a) 
=> a

menuItem: a MenuItem

-> m Bool

Returns: True if menuItem always reserves space for the submenu indicator

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

Since: 3.0

getRightJustified

menuItemGetRightJustified Source #

Arguments

:: (HasCallStack, MonadIO m, IsMenuItem a) 
=> a

menuItem: a MenuItem

-> m Bool

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

Deprecated: (Since version 3.2)See menuItemSetRightJustified

Gets whether the menu item appears justified at the right side of the menu bar.

getSubmenu

menuItemGetSubmenu Source #

Arguments

:: (HasCallStack, MonadIO m, IsMenuItem a) 
=> a

menuItem: a MenuItem

-> m (Maybe Widget)

Returns: submenu for this menu item, or Nothing if none

Gets the submenu underneath this menu item, if any. See menuItemSetSubmenu.

getUseUnderline

menuItemGetUseUnderline Source #

Arguments

:: (HasCallStack, MonadIO m, IsMenuItem a) 
=> a

menuItem: a MenuItem

-> m Bool

Returns: True if an embedded underline in the label indicates the mnemonic accelerator key.

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

Since: 2.16

new

menuItemNew Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> m MenuItem

Returns: the newly created MenuItem

Creates a new MenuItem.

newWithLabel

menuItemNewWithLabel Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Text

label: the text for the label

-> m MenuItem

Returns: the newly created MenuItem

Creates a new MenuItem whose child is a Label.

newWithMnemonic

menuItemNewWithMnemonic Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Text

label: The text of the button, with an underscore in front of the mnemonic character

-> m MenuItem

Returns: a new MenuItem

Creates a new MenuItem containing a label.

The label will be created using labelNewWithMnemonic, so underscores in label indicate the mnemonic for the menu item.

select

data MenuItemSelectMethodInfo Source #

Instances

((~) * signature (m ()), MonadIO m, IsMenuItem a) => MethodInfo * MenuItemSelectMethodInfo a signature Source # 

menuItemSelect Source #

Arguments

:: (HasCallStack, MonadIO m, IsMenuItem a) 
=> a

menuItem: the menu item

-> m () 

Emits the MenuItem::select signal on the given item.

setAccelPath

menuItemSetAccelPath Source #

Arguments

:: (HasCallStack, MonadIO m, IsMenuItem a) 
=> a

menuItem: a valid MenuItem

-> Maybe Text

accelPath: accelerator path, corresponding to this menu item’s functionality, or Nothing to unset the current path.

-> m () 

Set the accelerator path on menuItem, through which runtime changes of the menu item’s accelerator caused by the user can be identified and saved to persistent storage (see accelMapSave on this). To set up a default accelerator for this menu item, call accelMapAddEntry with the same accelPath. See also accelMapAddEntry on the specifics of accelerator paths, and menuSetAccelPath for a more convenient variant of this function.

This function is basically a convenience wrapper that handles calling widgetSetAccelPath with the appropriate accelerator group for the menu item.

Note that you do need to set an accelerator on the parent menu with menuSetAccelGroup for this to work.

Note that accelPath string will be stored in a GQuark. Therefore, if you pass a static string, you can save some memory by interning it first with internStaticString.

setLabel

data MenuItemSetLabelMethodInfo Source #

Instances

((~) * signature (Text -> m ()), MonadIO m, IsMenuItem a) => MethodInfo * MenuItemSetLabelMethodInfo a signature Source # 

menuItemSetLabel Source #

Arguments

:: (HasCallStack, MonadIO m, IsMenuItem a) 
=> a

menuItem: a MenuItem

-> Text

label: the text you want to set

-> m () 

Sets text on the menuItem label

Since: 2.16

setReserveIndicator

menuItemSetReserveIndicator Source #

Arguments

:: (HasCallStack, MonadIO m, IsMenuItem a) 
=> a

menuItem: a MenuItem

-> Bool

reserve: the new value

-> m () 

Sets whether the menuItem 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.

Since: 3.0

setRightJustified

menuItemSetRightJustified Source #

Arguments

:: (HasCallStack, MonadIO m, IsMenuItem a) 
=> a

menuItem: a MenuItem.

-> Bool

rightJustified: if True the menu item will appear at the far right if added to a menu bar

-> m () 

Deprecated: (Since version 3.2)If you insist on using it, use widgetSetHexpand and widgetSetHalign.

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

data MenuItemSetSubmenuMethodInfo Source #

Instances

((~) * signature (Maybe b -> m ()), MonadIO m, IsMenuItem a, IsMenu b) => MethodInfo * MenuItemSetSubmenuMethodInfo a signature Source # 

menuItemSetSubmenu Source #

Arguments

:: (HasCallStack, MonadIO m, IsMenuItem a, IsMenu b) 
=> a

menuItem: a MenuItem

-> Maybe b

submenu: the submenu, or Nothing

-> m () 

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

setUseUnderline

menuItemSetUseUnderline Source #

Arguments

:: (HasCallStack, MonadIO m, IsMenuItem a) 
=> a

menuItem: a MenuItem

-> Bool

setting: True if underlines in the text indicate mnemonics

-> m () 

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

Since: 2.16

toggleSizeAllocate

menuItemToggleSizeAllocate Source #

Arguments

:: (HasCallStack, MonadIO m, IsMenuItem a) 
=> a

menuItem: the menu item.

-> Int32

allocation: the allocation to use as signal data.

-> m () 

Emits the MenuItem::toggle-size-allocate signal on the given item.

toggleSizeRequest

menuItemToggleSizeRequest Source #

Arguments

:: (HasCallStack, MonadIO m, IsMenuItem a) 
=> a

menuItem: the menu item

-> Int32

requisition: the requisition to use as signal data.

-> m Int32 

Emits the MenuItem::toggle-size-request signal on the given item.

Properties

accelPath

data MenuItemAccelPathPropertyInfo Source #

Instances

AttrInfo MenuItemAccelPathPropertyInfo Source # 
type AttrOrigin MenuItemAccelPathPropertyInfo Source # 
type AttrLabel MenuItemAccelPathPropertyInfo Source # 
type AttrGetType MenuItemAccelPathPropertyInfo Source # 
type AttrBaseTypeConstraint MenuItemAccelPathPropertyInfo Source # 
type AttrSetTypeConstraint MenuItemAccelPathPropertyInfo Source # 
type AttrAllowedOps MenuItemAccelPathPropertyInfo Source # 

label

data MenuItemLabelPropertyInfo Source #

Instances

AttrInfo MenuItemLabelPropertyInfo Source # 
type AttrOrigin MenuItemLabelPropertyInfo Source # 
type AttrLabel MenuItemLabelPropertyInfo Source # 
type AttrGetType MenuItemLabelPropertyInfo Source # 
type AttrBaseTypeConstraint MenuItemLabelPropertyInfo Source # 
type AttrSetTypeConstraint MenuItemLabelPropertyInfo Source # 
type AttrAllowedOps MenuItemLabelPropertyInfo Source # 

setMenuItemLabel :: (MonadIO m, IsMenuItem o) => o -> Text -> m () Source #

rightJustified

data MenuItemRightJustifiedPropertyInfo Source #

Instances

AttrInfo MenuItemRightJustifiedPropertyInfo Source # 
type AttrOrigin MenuItemRightJustifiedPropertyInfo Source # 
type AttrLabel MenuItemRightJustifiedPropertyInfo Source # 
type AttrGetType MenuItemRightJustifiedPropertyInfo Source # 
type AttrBaseTypeConstraint MenuItemRightJustifiedPropertyInfo Source # 
type AttrSetTypeConstraint MenuItemRightJustifiedPropertyInfo Source # 
type AttrAllowedOps MenuItemRightJustifiedPropertyInfo Source # 

submenu

data MenuItemSubmenuPropertyInfo Source #

Instances

AttrInfo MenuItemSubmenuPropertyInfo Source # 
type AttrOrigin MenuItemSubmenuPropertyInfo Source # 
type AttrLabel MenuItemSubmenuPropertyInfo Source # 
type AttrGetType MenuItemSubmenuPropertyInfo Source # 
type AttrBaseTypeConstraint MenuItemSubmenuPropertyInfo Source # 
type AttrSetTypeConstraint MenuItemSubmenuPropertyInfo Source # 
type AttrAllowedOps MenuItemSubmenuPropertyInfo Source # 

setMenuItemSubmenu :: (MonadIO m, IsMenuItem o, IsMenu a) => o -> a -> m () Source #

useUnderline

data MenuItemUseUnderlinePropertyInfo Source #

Instances

AttrInfo MenuItemUseUnderlinePropertyInfo Source # 
type AttrOrigin MenuItemUseUnderlinePropertyInfo Source # 
type AttrLabel MenuItemUseUnderlinePropertyInfo Source # 
type AttrGetType MenuItemUseUnderlinePropertyInfo Source # 
type AttrBaseTypeConstraint MenuItemUseUnderlinePropertyInfo Source # 
type AttrSetTypeConstraint MenuItemUseUnderlinePropertyInfo Source # 
type AttrAllowedOps MenuItemUseUnderlinePropertyInfo Source # 

Signals

activate

activateItem

deselect

select

type C_MenuItemSelectCallback = Ptr () -> Ptr () -> IO () Source #

toggleSizeAllocate

toggleSizeRequest