gi-gtk-4.0.4: Gtk bindings
CopyrightWill Thompson Iñaki García Etxebarria and Jonas Platte
LicenseLGPL-2.1
MaintainerIñaki García Etxebarria
Safe HaskellSafe-Inferred
LanguageHaskell2010

GI.Gtk.Objects.MenuButton

Description

The MenuButton widget is used to display a popup when clicked on. This popup can be provided either as a Popover or as an abstract MenuModel.

The MenuButton widget can show either an icon (set with the MenuButton:icon-name property) or a label (set with the MenuButton:label property). If neither is explicitly set, a Image is automatically created, using an arrow image oriented according to MenuButton:direction or the generic “open-menu-symbolic” icon if the direction is not set.

The positioning of the popup is determined by the MenuButton:direction property of the menu button.

For menus, the Widget:halign and Widget:valign properties of the menu are also taken into account. For example, when the direction is ArrowTypeDown and the horizontal alignment is AlignStart, the menu will be positioned below the button, with the starting edge (depending on the text direction) of the menu aligned with the starting edge of the button. If there is not enough space below the button, the menu is popped up above the button instead. If the alignment would move part of the menu offscreen, it is “pushed in”.

Direction = Down

  • halign = start

  • halign = center

  • halign = end

Direction = Up

  • halign = start

  • halign = center

  • halign = end

Direction = Left

  • valign = start

  • valign = center

  • valign = end

Direction = Right

  • valign = start

  • valign = center

  • valign = end

CSS nodes

plain code

menubutton
╰── button.toggle
    ╰── [content]

GtkMenuButton has a single CSS node with name menubutton which contains a toggle button node.

Accessibility

GtkMenuButton uses the GTK_ACCESSIBLE_ROLE_BUTTON role.

Synopsis

Exported types

newtype MenuButton Source #

Memory-managed wrapper type.

Constructors

MenuButton (ManagedPtr MenuButton) 

Instances

Instances details
Eq MenuButton Source # 
Instance details

Defined in GI.Gtk.Objects.MenuButton

GObject MenuButton Source # 
Instance details

Defined in GI.Gtk.Objects.MenuButton

ManagedPtrNewtype MenuButton Source # 
Instance details

Defined in GI.Gtk.Objects.MenuButton

Methods

toManagedPtr :: MenuButton -> ManagedPtr MenuButton

TypedObject MenuButton Source # 
Instance details

Defined in GI.Gtk.Objects.MenuButton

Methods

glibType :: IO GType

HasParentTypes MenuButton Source # 
Instance details

Defined in GI.Gtk.Objects.MenuButton

IsGValue (Maybe MenuButton) Source #

Convert MenuButton to and from GValue. See toGValue and fromGValue.

Instance details

Defined in GI.Gtk.Objects.MenuButton

Methods

gvalueGType_ :: IO GType

gvalueSet_ :: Ptr GValue -> Maybe MenuButton -> IO ()

gvalueGet_ :: Ptr GValue -> IO (Maybe MenuButton)

type ParentTypes MenuButton Source # 
Instance details

Defined in GI.Gtk.Objects.MenuButton

class (GObject o, IsDescendantOf MenuButton o) => IsMenuButton o Source #

Type class for types which can be safely cast to MenuButton, for instance with toMenuButton.

Instances

Instances details
(GObject o, IsDescendantOf MenuButton o) => IsMenuButton o Source # 
Instance details

Defined in GI.Gtk.Objects.MenuButton

toMenuButton :: (MonadIO m, IsMenuButton o) => o -> m MenuButton Source #

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

Methods

Click to display all available methods, including inherited ones

Expand

Methods

actionSetEnabled, activate, activateAction, activateDefault, addController, addCssClass, addMnemonicLabel, addTickCallback, allocate, bindProperty, bindPropertyFull, childFocus, computeBounds, computeExpand, computePoint, computeTransform, contains, createPangoContext, createPangoLayout, dragCheckThreshold, errorBell, forceFloating, freezeNotify, getv, grabFocus, hasCssClass, hasDefault, hasFocus, hasVisibleFocus, hide, inDestruction, initTemplate, insertActionGroup, insertAfter, insertBefore, isAncestor, isDrawable, isFloating, isFocus, isSensitive, isVisible, keynavFailed, listMnemonicLabels, map, measure, mnemonicActivate, notify, notifyByPspec, observeChildren, observeControllers, pick, popdown, popup, queueAllocate, queueDraw, queueResize, realize, ref, refSink, removeController, removeCssClass, removeMnemonicLabel, removeTickCallback, resetProperty, resetRelation, resetState, runDispose, shouldLayout, show, sizeAllocate, snapshotChild, stealData, stealQdata, thawNotify, translateCoordinates, triggerTooltipQuery, unmap, unparent, unrealize, unref, unsetStateFlags, updateProperty, updateRelation, updateState, watchClosure.

Getters

getAccessibleRole, getAllocatedBaseline, getAllocatedHeight, getAllocatedWidth, getAllocation, getAncestor, getBuildableId, getCanFocus, getCanTarget, getChildVisible, getClipboard, getCssClasses, getCssName, getCursor, getData, getDirection, getDisplay, getFirstChild, getFocusChild, getFocusOnClick, getFocusable, getFontMap, getFontOptions, getFrameClock, getHalign, getHasFrame, getHasTooltip, getHeight, getHexpand, getHexpandSet, getIconName, getLabel, getLastChild, getLayoutManager, getMapped, getMarginBottom, getMarginEnd, getMarginStart, getMarginTop, getMenuModel, getName, getNative, getNextSibling, getOpacity, getOverflow, getPangoContext, getParent, getPopover, getPreferredSize, getPrevSibling, getPrimaryClipboard, getProperty, getQdata, getRealized, getReceivesDefault, getRequestMode, getRoot, getScaleFactor, getSensitive, getSettings, getSize, getSizeRequest, getStateFlags, getStyleContext, getTemplateChild, getTooltipMarkup, getTooltipText, getUseUnderline, getValign, getVexpand, getVexpandSet, getVisible, getWidth.

Setters

setCanFocus, setCanTarget, setChildVisible, setCreatePopupFunc, setCssClasses, setCursor, setCursorFromName, setData, setDataFull, setDirection, setFocusChild, setFocusOnClick, setFocusable, setFontMap, setFontOptions, setHalign, setHasFrame, setHasTooltip, setHexpand, setHexpandSet, setIconName, setLabel, setLayoutManager, setMarginBottom, setMarginEnd, setMarginStart, setMarginTop, setMenuModel, setName, setOpacity, setOverflow, setParent, setPopover, setProperty, setReceivesDefault, setSensitive, setSizeRequest, setStateFlags, setTooltipMarkup, setTooltipText, setUseUnderline, setValign, setVexpand, setVexpandSet, setVisible.

getDirection

menuButtonGetDirection Source #

Arguments

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

menuButton: a MenuButton

-> m ArrowType

Returns: a ArrowType value

Returns the direction the popup will be pointing at when popped up.

getHasFrame

menuButtonGetHasFrame Source #

Arguments

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

menuButton: a MenuButton

-> m Bool

Returns: True if the button has a frame

Returns whether the button has a frame.

getIconName

menuButtonGetIconName Source #

Arguments

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

menuButton: a MenuButton

-> m Text

Returns: the name of the icon shown in the button

Gets the name of the icon shown in the button.

getLabel

menuButtonGetLabel Source #

Arguments

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

menuButton: a MenuButton

-> m Text

Returns: the label shown in the button

Gets the label shown in the button

getMenuModel

menuButtonGetMenuModel Source #

Arguments

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

menuButton: a MenuButton

-> m (Maybe MenuModel)

Returns: a MenuModel or Nothing

Returns the MenuModel used to generate the popup.

getPopover

menuButtonGetPopover Source #

Arguments

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

menuButton: a MenuButton

-> m (Maybe Popover)

Returns: a Popover or Nothing

Returns the Popover that pops out of the button. If the button is not using a Popover, this function returns Nothing.

getUseUnderline

menuButtonGetUseUnderline Source #

Arguments

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

menuButton: a MenuButton

-> m Bool

Returns: True whether an embedded underline in the text indicates the mnemonic accelerator keys.

Returns whether an embedded underline in the text indicates a mnemonic. See menuButtonSetUseUnderline.

new

menuButtonNew Source #

Arguments

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

Returns: The newly created MenuButton widget

Creates a new MenuButton widget with downwards-pointing arrow as the only child. You can replace the child widget with another Widget should you wish to.

popdown

menuButtonPopdown Source #

Arguments

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

menuButton: a MenuButton

-> m () 

Dismiss the menu.

popup

menuButtonPopup Source #

Arguments

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

menuButton: a MenuButton

-> m () 

Pop up the menu.

setCreatePopupFunc

menuButtonSetCreatePopupFunc Source #

Arguments

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

menuButton: a MenuButton

-> Maybe MenuButtonCreatePopupFunc

func: function to call when a popuop is about to be shown, but none has been provided via other means, or Nothing to reset to default behavior.

-> m () 

Sets func to be called when a popup is about to be shown. func should use one of

to set a popup for menuButton. If func is non-Nothing, menuButton will always be sensitive.

Using this function will not reset the menu widget attached to menuButton. Instead, this can be done manually in func.

setDirection

menuButtonSetDirection Source #

Arguments

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

menuButton: a MenuButton

-> ArrowType

direction: a ArrowType

-> m () 

Sets the direction in which the popup will be popped up, as well as changing the arrow’s direction. The child will not be changed to an arrow if it was customized.

If the does not fit in the available space in the given direction, GTK will its best to keep it inside the screen and fully visible.

If you pass ArrowTypeNone for a direction, the popup will behave as if you passed ArrowTypeDown (although you won’t see any arrows).

setHasFrame

menuButtonSetHasFrame Source #

Arguments

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

menuButton: a MenuButton

-> Bool

hasFrame: whether the button should have a visible frame

-> m () 

Sets the style of the button.

setIconName

menuButtonSetIconName Source #

Arguments

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

menuButton: a MenuButton

-> Text

iconName: the icon name

-> m () 

Sets the name of an icon to show inside the menu button.

setLabel

menuButtonSetLabel Source #

Arguments

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

menuButton: a MenuButton

-> Text

label: the label

-> m () 

Sets the label to show inside the menu button.

setMenuModel

menuButtonSetMenuModel Source #

Arguments

:: (HasCallStack, MonadIO m, IsMenuButton a, IsMenuModel b) 
=> a

menuButton: a MenuButton

-> Maybe b

menuModel: a MenuModel, or Nothing to unset and disable the button

-> m () 

Sets the MenuModel from which the popup will be constructed, or Nothing to dissociate any existing menu model and disable the button.

A Popover will be created from the menu model with popoverMenuNewFromModel. Actions will be connected as documented for this function.

If MenuButton:popover is already set, it will be dissociated from the menuButton, and the property is set to Nothing.

setPopover

menuButtonSetPopover Source #

Arguments

:: (HasCallStack, MonadIO m, IsMenuButton a, IsWidget b) 
=> a

menuButton: a MenuButton

-> Maybe b

popover: a Popover, or Nothing to unset and disable the button

-> m () 

Sets the Popover that will be popped up when the menuButton is clicked, or Nothing to dissociate any existing popover and disable the button.

If MenuButton:menu-model is set, the menu model is dissociated from the menuButton, and the property is set to Nothing.

setUseUnderline

menuButtonSetUseUnderline Source #

Arguments

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

menuButton: a MenuButton

-> Bool

useUnderline: 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.

Properties

direction

The ArrowType representing the direction in which the menu or popover will be popped out.

constructMenuButtonDirection :: (IsMenuButton o, MonadIO m) => ArrowType -> m (GValueConstruct o) Source #

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

getMenuButtonDirection :: (MonadIO m, IsMenuButton o) => o -> m ArrowType Source #

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

get menuButton #direction

setMenuButtonDirection :: (MonadIO m, IsMenuButton o) => o -> ArrowType -> m () Source #

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

set menuButton [ #direction := value ]

hasFrame

No description available in the introspection data.

constructMenuButtonHasFrame :: (IsMenuButton o, MonadIO m) => Bool -> m (GValueConstruct o) Source #

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

getMenuButtonHasFrame :: (MonadIO m, IsMenuButton o) => o -> m Bool Source #

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

get menuButton #hasFrame

setMenuButtonHasFrame :: (MonadIO m, IsMenuButton o) => o -> Bool -> m () Source #

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

set menuButton [ #hasFrame := value ]

iconName

No description available in the introspection data.

constructMenuButtonIconName :: (IsMenuButton o, MonadIO m) => Text -> m (GValueConstruct o) Source #

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

getMenuButtonIconName :: (MonadIO m, IsMenuButton o) => o -> m Text Source #

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

get menuButton #iconName

setMenuButtonIconName :: (MonadIO m, IsMenuButton o) => o -> Text -> m () Source #

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

set menuButton [ #iconName := value ]

label

No description available in the introspection data.

constructMenuButtonLabel :: (IsMenuButton o, MonadIO m) => Text -> m (GValueConstruct o) Source #

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

getMenuButtonLabel :: (MonadIO m, IsMenuButton o) => o -> m Text Source #

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

get menuButton #label

setMenuButtonLabel :: (MonadIO m, IsMenuButton o) => o -> Text -> m () Source #

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

set menuButton [ #label := value ]

menuModel

The MenuModel from which the popup will be created.

See menuButtonSetMenuModel for the interaction with the MenuButton:popup property.

clearMenuButtonMenuModel :: (MonadIO m, IsMenuButton o) => o -> m () Source #

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

clear #menuModel

constructMenuButtonMenuModel :: (IsMenuButton o, MonadIO m, IsMenuModel a) => a -> m (GValueConstruct o) Source #

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

getMenuButtonMenuModel :: (MonadIO m, IsMenuButton o) => o -> m (Maybe MenuModel) Source #

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

get menuButton #menuModel

setMenuButtonMenuModel :: (MonadIO m, IsMenuButton o, IsMenuModel a) => o -> a -> m () Source #

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

set menuButton [ #menuModel := value ]

popover

The Popover that will be popped up when the button is clicked.

clearMenuButtonPopover :: (MonadIO m, IsMenuButton o) => o -> m () Source #

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

clear #popover

constructMenuButtonPopover :: (IsMenuButton o, MonadIO m, IsPopover a) => a -> m (GValueConstruct o) Source #

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

getMenuButtonPopover :: (MonadIO m, IsMenuButton o) => o -> m (Maybe Popover) Source #

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

get menuButton #popover

setMenuButtonPopover :: (MonadIO m, IsMenuButton o, IsPopover a) => o -> a -> m () Source #

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

set menuButton [ #popover := value ]

useUnderline

No description available in the introspection data.

constructMenuButtonUseUnderline :: (IsMenuButton o, MonadIO m) => Bool -> m (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.

getMenuButtonUseUnderline :: (MonadIO m, IsMenuButton o) => o -> m Bool Source #

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

get menuButton #useUnderline

setMenuButtonUseUnderline :: (MonadIO m, IsMenuButton o) => o -> Bool -> m () Source #

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

set menuButton [ #useUnderline := value ]