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.MenuButton

Contents

Description

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

The MenuButton widget can hold any valid child widget. That is, it can hold almost any other standard Widget. The most commonly used child is Image. If no widget is explicitely added to the MenuButton, 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

GtkMenuButton has a single CSS node with name button. To differentiate it from a plain Button, it gets the .popup style class.

Synopsis

Exported types

newtype MenuButton Source #

Memory-managed wrapper type.

class GObject o => IsMenuButton o Source #

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

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

getAlignWidget

menuButtonGetAlignWidget Source #

Arguments

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

menuButton: a MenuButton

-> m (Maybe Widget)

Returns: a Widget value or Nothing

Returns the parent Widget to use to line up with menu.

Since: 3.6

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.

Since: 3.6

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.

Since: 3.6

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.

Since: 3.12

getPopup

menuButtonGetPopup Source #

Arguments

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

menuButton: a MenuButton

-> m (Maybe Menu)

Returns: a Menu or Nothing

Returns the Menu that pops out of the button. If the button does not use a Menu, this function returns Nothing.

Since: 3.6

getUsePopover

menuButtonGetUsePopover Source #

Arguments

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

menuButton: a MenuButton

-> m Bool

Returns: True if using a Popover

Returns whether a Popover or a Menu will be constructed from the menu model.

Since: 3.12

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.

Since: 3.6

setAlignWidget

menuButtonSetAlignWidget Source #

Arguments

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

menuButton: a MenuButton

-> Maybe b

alignWidget: a Widget

-> m () 

Sets the Widget to use to line the menu with when popped up. Note that the alignWidget must contain the MenuButton itself.

Setting it to Nothing means that the menu will be aligned with the button itself.

Note that this property is only used with menus currently, and not for popovers.

Since: 3.6

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

Since: 3.6

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.

Depending on the value of MenuButton:use-popover, either a Menu will be created with menuNewFromModel, or a Popover with popoverNewFromModel. In either case, actions will be connected as documented for these functions.

If MenuButton:popup or MenuButton:popover are already set, those widgets are dissociated from the menuButton, and those properties are set to Nothing.

Since: 3.6

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 or MenuButton:popup are set, those objects are dissociated from the menuButton, and those properties are set to Nothing.

Since: 3.12

setPopup

menuButtonSetPopup Source #

Arguments

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

menuButton: a MenuButton

-> Maybe b

menu: a Menu, or Nothing to unset and disable the button

-> m () 

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

If MenuButton:menu-model or MenuButton:popover are set, those objects are dissociated from the menuButton, and those properties are set to Nothing.

Since: 3.6

setUsePopover

menuButtonSetUsePopover Source #

Arguments

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

menuButton: a MenuButton

-> Bool

usePopover: True to construct a popover from the menu model

-> m () 

Sets whether to construct a Popover instead of Menu when menuButtonSetMenuModel is called. Note that this property is only consulted when a new menu model is set.

Since: 3.12

Properties

alignWidget

The Widget to use to align the menu with.

Since: 3.6

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

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

clear #alignWidget

constructMenuButtonAlignWidget :: (IsMenuButton o, IsContainer a) => a -> IO (GValueConstruct o) Source #

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

getMenuButtonAlignWidget :: (MonadIO m, IsMenuButton o) => o -> m (Maybe Container) Source #

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

get menuButton #alignWidget

setMenuButtonAlignWidget :: (MonadIO m, IsMenuButton o, IsContainer a) => o -> a -> m () Source #

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

set menuButton [ #alignWidget := value ]

direction

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

Since: 3.6

constructMenuButtonDirection :: IsMenuButton o => ArrowType -> IO (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 ]

menuModel

The MenuModel from which the popup will be created. Depending on the MenuButton:use-popover property, that may be a menu or a popover.

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

Since: 3.6

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, IsMenuModel a) => a -> IO (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.

Since: 3.12

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, IsPopover a) => a -> IO (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 ]

popup

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

Since: 3.6

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

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

clear #popup

constructMenuButtonPopup :: (IsMenuButton o, IsMenu a) => a -> IO (GValueConstruct o) Source #

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

getMenuButtonPopup :: (MonadIO m, IsMenuButton o) => o -> m (Maybe Menu) Source #

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

get menuButton #popup

setMenuButtonPopup :: (MonadIO m, IsMenuButton o, IsMenu a) => o -> a -> m () Source #

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

set menuButton [ #popup := value ]

usePopover

Whether to construct a Popover from the menu model, or a Menu.

Since: 3.12

constructMenuButtonUsePopover :: IsMenuButton o => Bool -> IO (GValueConstruct o) Source #

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

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

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

get menuButton #usePopover

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

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

set menuButton [ #usePopover := value ]