gi-gtk-3.0.27: 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 *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 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

newtype MenuItem Source #

Memory-managed wrapper type.

Constructors

MenuItem (ManagedPtr MenuItem) 
Instances
GObject MenuItem Source # 
Instance details

Defined in GI.Gtk.Objects.MenuItem

IsImplementorIface MenuItem Source # 
Instance details

Defined in GI.Gtk.Objects.MenuItem

IsObject MenuItem Source # 
Instance details

Defined in GI.Gtk.Objects.MenuItem

IsActionable MenuItem Source # 
Instance details

Defined in GI.Gtk.Objects.MenuItem

IsActivatable MenuItem Source # 
Instance details

Defined in GI.Gtk.Objects.MenuItem

IsBuildable MenuItem Source # 
Instance details

Defined in GI.Gtk.Objects.MenuItem

IsBin MenuItem Source # 
Instance details

Defined in GI.Gtk.Objects.MenuItem

IsContainer MenuItem Source # 
Instance details

Defined in GI.Gtk.Objects.MenuItem

IsMenuItem MenuItem Source # 
Instance details

Defined in GI.Gtk.Objects.MenuItem

IsWidget MenuItem Source # 
Instance details

Defined in GI.Gtk.Objects.MenuItem

class GObject o => IsMenuItem o Source #

Type class for types which can be safely cast to MenuItem, for instance with toMenuItem.

toMenuItem :: (MonadIO m, IsMenuItem o) => o -> m MenuItem Source #

Cast to MenuItem, for types for which this is known to be safe. For general casts, use castTo.

noMenuItem :: Maybe MenuItem Source #

A convenience alias for Nothing :: Maybe MenuItem.

Methods

activate

menuItemActivate Source #

Arguments

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

menuItem: the menu item

-> m () 

Emits the MenuItem::activate signal on the given item

deselect

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

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

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

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

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 persistant storage.

Since: 2.14

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

Set the value of the “accel-path” property to Nothing. When overloading is enabled, this is equivalent to

clear #accelPath

constructMenuItemAccelPath :: IsMenuItem o => Text -> IO (GValueConstruct o) Source #

Construct a GValueConstruct with valid value for the “accel-path” property. This is rarely needed directly, but it is used by new.

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

Get the value of the “accel-path” property. When overloading is enabled, this is equivalent to

get menuItem #accelPath

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

Set the value of the “accel-path” property. When overloading is enabled, this is equivalent to

set menuItem [ #accelPath := value ]

label

The text for the child label.

Since: 2.16

constructMenuItemLabel :: IsMenuItem o => Text -> IO (GValueConstruct o) Source #

Construct a GValueConstruct with valid value for the “label” property. This is rarely needed directly, but it is used by new.

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

Get the value of the “label” property. When overloading is enabled, this is equivalent to

get menuItem #label

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

Set the value of the “label” property. When overloading is enabled, this is equivalent to

set menuItem [ #label := value ]

rightJustified

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

Since: 2.14

constructMenuItemRightJustified :: IsMenuItem o => Bool -> IO (GValueConstruct o) Source #

Construct a GValueConstruct with valid value for the “right-justified” property. This is rarely needed directly, but it is used by new.

getMenuItemRightJustified :: (MonadIO m, IsMenuItem o) => o -> m Bool Source #

Get the value of the “right-justified” property. When overloading is enabled, this is equivalent to

get menuItem #rightJustified

setMenuItemRightJustified :: (MonadIO m, IsMenuItem o) => o -> Bool -> m () Source #

Set the value of the “right-justified” property. When overloading is enabled, this is equivalent to

set menuItem [ #rightJustified := value ]

submenu

The submenu attached to the menu item, or Nothing if it has none.

Since: 2.12

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

Set the value of the “submenu” property to Nothing. When overloading is enabled, this is equivalent to

clear #submenu

constructMenuItemSubmenu :: (IsMenuItem o, IsMenu a) => a -> IO (GValueConstruct o) Source #

Construct a GValueConstruct with valid value for the “submenu” property. This is rarely needed directly, but it is used by new.

getMenuItemSubmenu :: (MonadIO m, IsMenuItem o) => o -> m (Maybe Menu) Source #

Get the value of the “submenu” property. When overloading is enabled, this is equivalent to

get menuItem #submenu

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

Set the value of the “submenu” property. When overloading is enabled, this is equivalent to

set menuItem [ #submenu := value ]

useUnderline

True if underlines in the text indicate mnemonics.

Since: 2.16

constructMenuItemUseUnderline :: IsMenuItem o => Bool -> IO (GValueConstruct o) Source #

Construct a GValueConstruct with valid value for the “use-underline” property. This is rarely needed directly, but it is used by new.

getMenuItemUseUnderline :: (MonadIO m, IsMenuItem o) => o -> m Bool Source #

Get the value of the “use-underline” property. When overloading is enabled, this is equivalent to

get menuItem #useUnderline

setMenuItemUseUnderline :: (MonadIO m, IsMenuItem o) => o -> Bool -> m () Source #

Set the value of the “use-underline” property. When overloading is enabled, this is equivalent to

set menuItem [ #useUnderline := value ]

Signals

activate

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

Type for the callback on the (unwrapped) C side.

type MenuItemActivateCallback = IO () Source #

Emitted when the item is activated.

afterMenuItemActivate :: (IsMenuItem a, MonadIO m) => a -> MenuItemActivateCallback -> m SignalHandlerId Source #

Connect a signal handler for the “activate” signal, to be run after the default handler. When overloading is enabled, this is equivalent to

after menuItem #activate callback

onMenuItemActivate :: (IsMenuItem a, MonadIO m) => a -> MenuItemActivateCallback -> m SignalHandlerId Source #

Connect a signal handler for the “activate” signal, to be run before the default handler. When overloading is enabled, this is equivalent to

on menuItem #activate callback

activateItem

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

Type for the callback on the (unwrapped) C side.

type MenuItemActivateItemCallback = IO () Source #

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

afterMenuItemActivateItem :: (IsMenuItem a, MonadIO m) => a -> MenuItemActivateItemCallback -> m SignalHandlerId Source #

Connect a signal handler for the “activate-item” signal, to be run after the default handler. When overloading is enabled, this is equivalent to

after menuItem #activateItem callback

onMenuItemActivateItem :: (IsMenuItem a, MonadIO m) => a -> MenuItemActivateItemCallback -> m SignalHandlerId Source #

Connect a signal handler for the “activate-item” signal, to be run before the default handler. When overloading is enabled, this is equivalent to

on menuItem #activateItem callback

deselect

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

Type for the callback on the (unwrapped) C side.

type MenuItemDeselectCallback = IO () Source #

No description available in the introspection data.

afterMenuItemDeselect :: (IsMenuItem a, MonadIO m) => a -> MenuItemDeselectCallback -> m SignalHandlerId Source #

Connect a signal handler for the “deselect” signal, to be run after the default handler. When overloading is enabled, this is equivalent to

after menuItem #deselect callback

onMenuItemDeselect :: (IsMenuItem a, MonadIO m) => a -> MenuItemDeselectCallback -> m SignalHandlerId Source #

Connect a signal handler for the “deselect” signal, to be run before the default handler. When overloading is enabled, this is equivalent to

on menuItem #deselect callback

select

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

Type for the callback on the (unwrapped) C side.

type MenuItemSelectCallback = IO () Source #

No description available in the introspection data.

afterMenuItemSelect :: (IsMenuItem a, MonadIO m) => a -> MenuItemSelectCallback -> m SignalHandlerId Source #

Connect a signal handler for the “select” signal, to be run after the default handler. When overloading is enabled, this is equivalent to

after menuItem #select callback

onMenuItemSelect :: (IsMenuItem a, MonadIO m) => a -> MenuItemSelectCallback -> m SignalHandlerId Source #

Connect a signal handler for the “select” signal, to be run before the default handler. When overloading is enabled, this is equivalent to

on menuItem #select callback

toggleSizeAllocate

type C_MenuItemToggleSizeAllocateCallback = Ptr () -> Int32 -> Ptr () -> IO () Source #

Type for the callback on the (unwrapped) C side.

type MenuItemToggleSizeAllocateCallback = Int32 -> IO () Source #

No description available in the introspection data.

afterMenuItemToggleSizeAllocate :: (IsMenuItem a, MonadIO m) => a -> MenuItemToggleSizeAllocateCallback -> m SignalHandlerId Source #

Connect a signal handler for the “toggle-size-allocate” signal, to be run after the default handler. When overloading is enabled, this is equivalent to

after menuItem #toggleSizeAllocate callback

onMenuItemToggleSizeAllocate :: (IsMenuItem a, MonadIO m) => a -> MenuItemToggleSizeAllocateCallback -> m SignalHandlerId Source #

Connect a signal handler for the “toggle-size-allocate” signal, to be run before the default handler. When overloading is enabled, this is equivalent to

on menuItem #toggleSizeAllocate callback

toggleSizeRequest

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

Type for the callback on the (unwrapped) C side.

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

No description available in the introspection data.

afterMenuItemToggleSizeRequest :: (IsMenuItem a, MonadIO m) => a -> MenuItemToggleSizeRequestCallback -> m SignalHandlerId Source #

Connect a signal handler for the “toggle-size-request” signal, to be run after the default handler. When overloading is enabled, this is equivalent to

after menuItem #toggleSizeRequest callback

onMenuItemToggleSizeRequest :: (IsMenuItem a, MonadIO m) => a -> MenuItemToggleSizeRequestCallback -> m SignalHandlerId Source #

Connect a signal handler for the “toggle-size-request” signal, to be run before the default handler. When overloading is enabled, this is equivalent to

on menuItem #toggleSizeRequest callback