Copyright | Will Thompson Iñaki García Etxebarria and Jonas Platte |
---|---|
License | LGPL-2.1 |
Maintainer | Iñaki García Etxebarria |
Safe Haskell | None |
Language | Haskell2010 |
GI.Gtk.Objects.MenuButton
Contents
Description
The tMenuButton
widget is used to display a popup when clicked on.
This popup can be provided either as a tMenu
, a tPopover
or an
abstract tMenuModel
.
The tMenuButton
widget can hold any valid child widget. That is, it
can hold almost any other standard tWidget
. The most commonly used
child is tImage
. If no widget is explicitely added to the tMenuButton
,
a tImage
is automatically created, using an arrow image oriented
according to tMenuButton
:direction
or the generic “open-menu-symbolic”
icon if the direction is not set.
The positioning of the popup is determined by the tMenuButton
:direction
property of the menu button.
For menus, the tWidget
:halign
and tWidget
: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 tButton
, it gets the .popup style class.
Synopsis
- newtype MenuButton = MenuButton (ManagedPtr MenuButton)
- class (GObject o, IsDescendantOf MenuButton o) => IsMenuButton o
- toMenuButton :: (MonadIO m, IsMenuButton o) => o -> m MenuButton
- noMenuButton :: Maybe MenuButton
- menuButtonGetAlignWidget :: (HasCallStack, MonadIO m, IsMenuButton a) => a -> m (Maybe Widget)
- menuButtonGetDirection :: (HasCallStack, MonadIO m, IsMenuButton a) => a -> m ArrowType
- menuButtonGetMenuModel :: (HasCallStack, MonadIO m, IsMenuButton a) => a -> m (Maybe MenuModel)
- menuButtonGetPopover :: (HasCallStack, MonadIO m, IsMenuButton a) => a -> m (Maybe Popover)
- menuButtonGetPopup :: (HasCallStack, MonadIO m, IsMenuButton a) => a -> m (Maybe Menu)
- menuButtonGetUsePopover :: (HasCallStack, MonadIO m, IsMenuButton a) => a -> m Bool
- menuButtonNew :: (HasCallStack, MonadIO m) => m MenuButton
- menuButtonSetAlignWidget :: (HasCallStack, MonadIO m, IsMenuButton a, IsWidget b) => a -> Maybe b -> m ()
- menuButtonSetDirection :: (HasCallStack, MonadIO m, IsMenuButton a) => a -> ArrowType -> m ()
- menuButtonSetMenuModel :: (HasCallStack, MonadIO m, IsMenuButton a, IsMenuModel b) => a -> Maybe b -> m ()
- menuButtonSetPopover :: (HasCallStack, MonadIO m, IsMenuButton a, IsWidget b) => a -> Maybe b -> m ()
- menuButtonSetPopup :: (HasCallStack, MonadIO m, IsMenuButton a, IsWidget b) => a -> Maybe b -> m ()
- menuButtonSetUsePopover :: (HasCallStack, MonadIO m, IsMenuButton a) => a -> Bool -> m ()
- clearMenuButtonAlignWidget :: (MonadIO m, IsMenuButton o) => o -> m ()
- constructMenuButtonAlignWidget :: (IsMenuButton o, IsContainer a) => a -> IO (GValueConstruct o)
- getMenuButtonAlignWidget :: (MonadIO m, IsMenuButton o) => o -> m (Maybe Container)
- setMenuButtonAlignWidget :: (MonadIO m, IsMenuButton o, IsContainer a) => o -> a -> m ()
- constructMenuButtonDirection :: IsMenuButton o => ArrowType -> IO (GValueConstruct o)
- getMenuButtonDirection :: (MonadIO m, IsMenuButton o) => o -> m ArrowType
- setMenuButtonDirection :: (MonadIO m, IsMenuButton o) => o -> ArrowType -> m ()
- clearMenuButtonMenuModel :: (MonadIO m, IsMenuButton o) => o -> m ()
- constructMenuButtonMenuModel :: (IsMenuButton o, IsMenuModel a) => a -> IO (GValueConstruct o)
- getMenuButtonMenuModel :: (MonadIO m, IsMenuButton o) => o -> m (Maybe MenuModel)
- setMenuButtonMenuModel :: (MonadIO m, IsMenuButton o, IsMenuModel a) => o -> a -> m ()
- clearMenuButtonPopover :: (MonadIO m, IsMenuButton o) => o -> m ()
- constructMenuButtonPopover :: (IsMenuButton o, IsPopover a) => a -> IO (GValueConstruct o)
- getMenuButtonPopover :: (MonadIO m, IsMenuButton o) => o -> m (Maybe Popover)
- setMenuButtonPopover :: (MonadIO m, IsMenuButton o, IsPopover a) => o -> a -> m ()
- clearMenuButtonPopup :: (MonadIO m, IsMenuButton o) => o -> m ()
- constructMenuButtonPopup :: (IsMenuButton o, IsMenu a) => a -> IO (GValueConstruct o)
- getMenuButtonPopup :: (MonadIO m, IsMenuButton o) => o -> m (Maybe Menu)
- setMenuButtonPopup :: (MonadIO m, IsMenuButton o, IsMenu a) => o -> a -> m ()
- constructMenuButtonUsePopover :: IsMenuButton o => Bool -> IO (GValueConstruct o)
- getMenuButtonUsePopover :: (MonadIO m, IsMenuButton o) => o -> m Bool
- setMenuButtonUsePopover :: (MonadIO m, IsMenuButton o) => o -> Bool -> m ()
Exported types
newtype MenuButton Source #
Memory-managed wrapper type.
Constructors
MenuButton (ManagedPtr MenuButton) |
Instances
Eq MenuButton Source # | |
Defined in GI.Gtk.Objects.MenuButton | |
GObject MenuButton Source # | |
Defined in GI.Gtk.Objects.MenuButton Methods gobjectType :: IO GType | |
IsGValue MenuButton Source # | Convert |
Defined in GI.Gtk.Objects.MenuButton | |
HasParentTypes MenuButton Source # | |
Defined in GI.Gtk.Objects.MenuButton | |
type ParentTypes MenuButton Source # | |
Defined in GI.Gtk.Objects.MenuButton type ParentTypes MenuButton = ToggleButton ': (Button ': (Bin ': (Container ': (Widget ': (Object ': (ImplementorIface ': (Actionable ': (Activatable ': (Buildable ': ([] :: [Type])))))))))) |
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
(GObject o, IsDescendantOf MenuButton o) => IsMenuButton o Source # | |
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
.
noMenuButton :: Maybe MenuButton Source #
A convenience alias for Nothing
:: Maybe
MenuButton
.
Methods
Overloaded methods
getAlignWidget
menuButtonGetAlignWidget Source #
Arguments
:: (HasCallStack, MonadIO m, IsMenuButton a) | |
=> a |
|
-> m (Maybe Widget) | Returns: a t |
Returns the parent tWidget
to use to line up with menu.
Since: 3.6
getDirection
menuButtonGetDirection Source #
Arguments
:: (HasCallStack, MonadIO m, IsMenuButton a) | |
=> a |
|
-> m ArrowType | Returns: a t |
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 |
|
-> m (Maybe MenuModel) | Returns: a t |
Returns the tMenuModel
used to generate the popup.
Since: 3.6
getPopover
Arguments
:: (HasCallStack, MonadIO m, IsMenuButton a) | |
=> a |
|
-> m (Maybe Popover) | Returns: a t |
getPopup
Arguments
:: (HasCallStack, MonadIO m, IsMenuButton a) | |
=> a |
|
-> m (Maybe Menu) | Returns: a t |
getUsePopover
menuButtonGetUsePopover Source #
Arguments
:: (HasCallStack, MonadIO m, IsMenuButton a) | |
=> a |
|
-> m Bool | Returns: |
new
Arguments
:: (HasCallStack, MonadIO m) | |
=> m MenuButton | Returns: The newly created t |
Creates a new tMenuButton
widget with downwards-pointing
arrow as the only child. You can replace the child widget
with another tWidget
should you wish to.
Since: 3.6
setAlignWidget
menuButtonSetAlignWidget Source #
Arguments
:: (HasCallStack, MonadIO m, IsMenuButton a, IsWidget b) | |
=> a |
|
-> Maybe b |
|
-> m () |
Sets the tWidget
to use to line the menu with when popped up.
Note that the alignWidget
must contain the tMenuButton
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 |
|
-> 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 |
|
-> Maybe b |
|
-> m () |
Sets the tMenuModel
from which the popup will be constructed,
or Nothing
to dissociate any existing menu model and disable the button.
Depending on the value of tMenuButton
:use-popover
, either a
tMenu
will be created with menuNewFromModel
, or a
tPopover
with popoverNewFromModel
. In either case,
actions will be connected as documented for these functions.
If tMenuButton
:popup
or tMenuButton
:popover
are already set, those
widgets are dissociated from the menuButton
, and those properties are set
to Nothing
.
Since: 3.6
setPopover
Arguments
:: (HasCallStack, MonadIO m, IsMenuButton a, IsWidget b) | |
=> a |
|
-> Maybe b |
|
-> m () |
Sets the tPopover
that will be popped up when the menuButton
is clicked,
or Nothing
to dissociate any existing popover and disable the button.
If tMenuButton
:menu-model
or tMenuButton
:popup
are set, those objects
are dissociated from the menuButton
, and those properties are set to Nothing
.
Since: 3.12
setPopup
Arguments
:: (HasCallStack, MonadIO m, IsMenuButton a, IsWidget b) | |
=> a |
|
-> Maybe b |
|
-> m () |
Sets the tMenu
that will be popped up when the menuButton
is clicked, or
Nothing
to dissociate any existing menu and disable the button.
If tMenuButton
:menu-model
or tMenuButton
: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 |
|
-> Bool |
|
-> m () |
Sets whether to construct a tPopover
instead of tMenu
when menuButtonSetMenuModel
is called. Note that
this property is only consulted when a new menu model is set.
Since: 3.12
Properties
alignWidget
The tWidget
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 tArrowType
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 tMenuModel
from which the popup will be created.
Depending on the tMenuButton
:use-popover
property, that may
be a menu or a popover.
See menuButtonSetMenuModel
for the interaction with the
tMenuButton
: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 tPopover
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 tMenu
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
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 ]