| Copyright | Will Thompson Iñaki García Etxebarria and Jonas Platte | 
|---|---|
| License | LGPL-2.1 | 
| Maintainer | Iñaki García Etxebarria | 
| Safe Haskell | Safe-Inferred | 
| Language | Haskell2010 | 
GI.Gtk.Objects.Button
Description
The Button widget is generally used to trigger a callback function that is
 called when the button is pressed.  The various signals and how to use them
 are outlined below.
The Button widget can hold any valid child widget.  That is, it can hold
 almost any other standard Widget.  The most commonly used child is the
 Label.
CSS nodes
GtkButton has a single CSS node with name button. The node will get the style classes .image-button or .text-button, if the content is just an image or label, respectively. It may also receive the .flat style class.
Other style classes that are commonly used with GtkButton include .suggested-action and .destructive-action. In special cases, buttons can be made round by adding the .circular style class.
Button-like widgets like ToggleButton, MenuButton, VolumeButton,
 LockButton, ColorButton or FontButton use style classes such as
 .toggle, .popup, .scale, .lock, .color on the button node
 to differentiate themselves from a plain GtkButton.
Accessibility
GtkButton uses the GTK_ACCESSIBLE_ROLE_BUTTON role.
Synopsis
- newtype Button = Button (ManagedPtr Button)
- class (GObject o, IsDescendantOf Button o) => IsButton o
- toButton :: (MonadIO m, IsButton o) => o -> m Button
- buttonGetChild :: (HasCallStack, MonadIO m, IsButton a) => a -> m (Maybe Widget)
- buttonGetHasFrame :: (HasCallStack, MonadIO m, IsButton a) => a -> m Bool
- buttonGetIconName :: (HasCallStack, MonadIO m, IsButton a) => a -> m (Maybe Text)
- buttonGetLabel :: (HasCallStack, MonadIO m, IsButton a) => a -> m (Maybe Text)
- buttonGetUseUnderline :: (HasCallStack, MonadIO m, IsButton a) => a -> m Bool
- buttonNew :: (HasCallStack, MonadIO m) => m Button
- buttonNewFromIconName :: (HasCallStack, MonadIO m) => Maybe Text -> m Button
- buttonNewWithLabel :: (HasCallStack, MonadIO m) => Text -> m Button
- buttonNewWithMnemonic :: (HasCallStack, MonadIO m) => Text -> m Button
- buttonSetChild :: (HasCallStack, MonadIO m, IsButton a, IsWidget b) => a -> Maybe b -> m ()
- buttonSetHasFrame :: (HasCallStack, MonadIO m, IsButton a) => a -> Bool -> m ()
- buttonSetIconName :: (HasCallStack, MonadIO m, IsButton a) => a -> Text -> m ()
- buttonSetLabel :: (HasCallStack, MonadIO m, IsButton a) => a -> Text -> m ()
- buttonSetUseUnderline :: (HasCallStack, MonadIO m, IsButton a) => a -> Bool -> m ()
- clearButtonChild :: (MonadIO m, IsButton o) => o -> m ()
- constructButtonChild :: (IsButton o, MonadIO m, IsWidget a) => a -> m (GValueConstruct o)
- getButtonChild :: (MonadIO m, IsButton o) => o -> m (Maybe Widget)
- setButtonChild :: (MonadIO m, IsButton o, IsWidget a) => o -> a -> m ()
- constructButtonHasFrame :: (IsButton o, MonadIO m) => Bool -> m (GValueConstruct o)
- getButtonHasFrame :: (MonadIO m, IsButton o) => o -> m Bool
- setButtonHasFrame :: (MonadIO m, IsButton o) => o -> Bool -> m ()
- constructButtonIconName :: (IsButton o, MonadIO m) => Text -> m (GValueConstruct o)
- getButtonIconName :: (MonadIO m, IsButton o) => o -> m (Maybe Text)
- setButtonIconName :: (MonadIO m, IsButton o) => o -> Text -> m ()
- constructButtonLabel :: (IsButton o, MonadIO m) => Text -> m (GValueConstruct o)
- getButtonLabel :: (MonadIO m, IsButton o) => o -> m (Maybe Text)
- setButtonLabel :: (MonadIO m, IsButton o) => o -> Text -> m ()
- constructButtonUseUnderline :: (IsButton o, MonadIO m) => Bool -> m (GValueConstruct o)
- getButtonUseUnderline :: (MonadIO m, IsButton o) => o -> m Bool
- setButtonUseUnderline :: (MonadIO m, IsButton o) => o -> Bool -> m ()
- type ButtonActivateCallback = IO ()
- type C_ButtonActivateCallback = Ptr () -> Ptr () -> IO ()
- afterButtonActivate :: (IsButton a, MonadIO m) => a -> ButtonActivateCallback -> m SignalHandlerId
- genClosure_ButtonActivate :: MonadIO m => ButtonActivateCallback -> m (GClosure C_ButtonActivateCallback)
- mk_ButtonActivateCallback :: C_ButtonActivateCallback -> IO (FunPtr C_ButtonActivateCallback)
- noButtonActivateCallback :: Maybe ButtonActivateCallback
- onButtonActivate :: (IsButton a, MonadIO m) => a -> ButtonActivateCallback -> m SignalHandlerId
- wrap_ButtonActivateCallback :: ButtonActivateCallback -> C_ButtonActivateCallback
- type ButtonClickedCallback = IO ()
- type C_ButtonClickedCallback = Ptr () -> Ptr () -> IO ()
- afterButtonClicked :: (IsButton a, MonadIO m) => a -> ButtonClickedCallback -> m SignalHandlerId
- genClosure_ButtonClicked :: MonadIO m => ButtonClickedCallback -> m (GClosure C_ButtonClickedCallback)
- mk_ButtonClickedCallback :: C_ButtonClickedCallback -> IO (FunPtr C_ButtonClickedCallback)
- noButtonClickedCallback :: Maybe ButtonClickedCallback
- onButtonClicked :: (IsButton a, MonadIO m) => a -> ButtonClickedCallback -> m SignalHandlerId
- wrap_ButtonClickedCallback :: ButtonClickedCallback -> C_ButtonClickedCallback
Exported types
Memory-managed wrapper type.
Instances
| Eq Button Source # | |
| GObject Button Source # | |
| Defined in GI.Gtk.Objects.Button | |
| ManagedPtrNewtype Button Source # | |
| Defined in GI.Gtk.Objects.Button Methods toManagedPtr :: Button -> ManagedPtr Button | |
| TypedObject Button Source # | |
| Defined in GI.Gtk.Objects.Button | |
| HasParentTypes Button Source # | |
| Defined in GI.Gtk.Objects.Button | |
| IsGValue (Maybe Button) Source # | Convert  | 
| Defined in GI.Gtk.Objects.Button Methods gvalueGType_ :: IO GType gvalueSet_ :: Ptr GValue -> Maybe Button -> IO () gvalueGet_ :: Ptr GValue -> IO (Maybe Button) | |
| type ParentTypes Button Source # | |
| Defined in GI.Gtk.Objects.Button | |
class (GObject o, IsDescendantOf Button o) => IsButton o Source #
Instances
| (GObject o, IsDescendantOf Button o) => IsButton o Source # | |
| Defined in GI.Gtk.Objects.Button | |
Methods
Click to display all available methods, including inherited ones
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, 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, getActionName, getActionTargetValue, getAllocatedBaseline, getAllocatedHeight, getAllocatedWidth, getAllocation, getAncestor, getBuildableId, getCanFocus, getCanTarget, getChild, 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, getName, getNative, getNextSibling, getOpacity, getOverflow, getPangoContext, getParent, 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
setActionName, setActionTargetValue, setCanFocus, setCanTarget, setChild, setChildVisible, setCssClasses, setCursor, setCursorFromName, setData, setDataFull, setDetailedActionName, setDirection, setFocusChild, setFocusOnClick, setFocusable, setFontMap, setFontOptions, setHalign, setHasFrame, setHasTooltip, setHexpand, setHexpandSet, setIconName, setLabel, setLayoutManager, setMarginBottom, setMarginEnd, setMarginStart, setMarginTop, setName, setOpacity, setOverflow, setParent, setProperty, setReceivesDefault, setSensitive, setSizeRequest, setStateFlags, setTooltipMarkup, setTooltipText, setUseUnderline, setValign, setVexpand, setVexpandSet, setVisible.
getChild
Arguments
| :: (HasCallStack, MonadIO m, IsButton a) | |
| => a | 
 | 
| -> m (Maybe Widget) | Returns: the child widget of  | 
Gets the child widget of button.
getHasFrame
Arguments
| :: (HasCallStack, MonadIO m, IsButton a) | |
| => a | 
 | 
| -> m Bool | Returns:  | 
Returns whether the button has a frame.
getIconName
Arguments
| :: (HasCallStack, MonadIO m, IsButton a) | |
| => a | 
 | 
| -> m (Maybe Text) | Returns: The icon name set via  | 
Returns the icon name set via buttonSetIconName.
getLabel
Arguments
| :: (HasCallStack, MonadIO m, IsButton a) | |
| => a | 
 | 
| -> m (Maybe Text) | Returns: The text of the label widget. This string is owned by the widget and must not be modified or freed. | 
Fetches the text from the label of the button, as set by
 buttonSetLabel. If the label text has not
 been set the return value will be Nothing. This will be the
 case if you create an empty button with buttonNew to
 use as a container.
getUseUnderline
buttonGetUseUnderline Source #
Arguments
| :: (HasCallStack, MonadIO m, IsButton a) | |
| => a | 
 | 
| -> m Bool | Returns:  | 
Returns whether an embedded underline in the button label indicates a
 mnemonic. See buttonSetUseUnderline.
new
Arguments
| :: (HasCallStack, MonadIO m) | |
| => m Button | Returns: The newly created  | 
Creates a new Button widget. To add a child widget to the button,
 use buttonSetChild.
newFromIconName
buttonNewFromIconName Source #
Arguments
| :: (HasCallStack, MonadIO m) | |
| => Maybe Text | 
 | 
| -> m Button | Returns: a new  | 
Creates a new button containing an icon from the current icon theme.
If the icon name isn’t known, a “broken image” icon will be displayed instead. If the current icon theme is changed, the icon will be updated appropriately.
newWithLabel
newWithMnemonic
buttonNewWithMnemonic Source #
Arguments
| :: (HasCallStack, MonadIO m) | |
| => Text | 
 | 
| -> m Button | Returns: a new  | 
Creates a new Button containing a label.
 If characters in label are preceded by an underscore, they are underlined.
 If you need a literal underscore character in a label, use “__” (two
 underscores). The first underlined character represents a keyboard
 accelerator called a mnemonic.
 Pressing Alt and that key activates the button.
setChild
Arguments
| :: (HasCallStack, MonadIO m, IsButton a, IsWidget b) | |
| => a | 
 | 
| -> Maybe b | 
 | 
| -> m () | 
Sets the child widget of button.
setHasFrame
Arguments
| :: (HasCallStack, MonadIO m, IsButton a) | |
| => a | 
 | 
| -> Bool | 
 | 
| -> m () | 
Sets the style of the button. Buttons can has a flat appearance or have a frame drawn around them.
setIconName
Arguments
| :: (HasCallStack, MonadIO m, IsButton a) | |
| => a | 
 | 
| -> Text | 
 | 
| -> m () | 
Adds a Image with the given icon name as a child. If button already
 contains a child widget, that child widget will be removed and replaced
 with the image.
setLabel
Arguments
| :: (HasCallStack, MonadIO m, IsButton a) | |
| => a | 
 | 
| -> Text | 
 | 
| -> m () | 
Sets the text of the label of the button to label.
This will also clear any previously set labels.
setUseUnderline
buttonSetUseUnderline Source #
Arguments
| :: (HasCallStack, MonadIO m, IsButton a) | |
| => a | 
 | 
| -> Bool | 
 | 
| -> m () | 
If true, an underline in the text of the button label indicates the next character should be used for the mnemonic accelerator key.
Properties
child
No description available in the introspection data.
clearButtonChild :: (MonadIO m, IsButton o) => o -> m () Source #
Set the value of the “child” property to Nothing.
 When overloading is enabled, this is equivalent to
clear #child
constructButtonChild :: (IsButton o, MonadIO m, IsWidget a) => a -> m (GValueConstruct o) Source #
Construct a GValueConstruct with valid value for the “child” property. This is rarely needed directly, but it is used by new.
getButtonChild :: (MonadIO m, IsButton o) => o -> m (Maybe Widget) Source #
Get the value of the “child” property.
 When overloading is enabled, this is equivalent to
get button #child
setButtonChild :: (MonadIO m, IsButton o, IsWidget a) => o -> a -> m () Source #
Set the value of the “child” property.
 When overloading is enabled, this is equivalent to
setbutton [ #child:=value ]
hasFrame
No description available in the introspection data.
constructButtonHasFrame :: (IsButton 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.
getButtonHasFrame :: (MonadIO m, IsButton o) => o -> m Bool Source #
Get the value of the “has-frame” property.
 When overloading is enabled, this is equivalent to
get button #hasFrame
setButtonHasFrame :: (MonadIO m, IsButton o) => o -> Bool -> m () Source #
Set the value of the “has-frame” property.
 When overloading is enabled, this is equivalent to
setbutton [ #hasFrame:=value ]
iconName
No description available in the introspection data.
constructButtonIconName :: (IsButton 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.
getButtonIconName :: (MonadIO m, IsButton o) => o -> m (Maybe Text) Source #
Get the value of the “icon-name” property.
 When overloading is enabled, this is equivalent to
get button #iconName
setButtonIconName :: (MonadIO m, IsButton o) => o -> Text -> m () Source #
Set the value of the “icon-name” property.
 When overloading is enabled, this is equivalent to
setbutton [ #iconName:=value ]
label
No description available in the introspection data.
constructButtonLabel :: (IsButton 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.
getButtonLabel :: (MonadIO m, IsButton o) => o -> m (Maybe Text) Source #
Get the value of the “label” property.
 When overloading is enabled, this is equivalent to
get button #label
setButtonLabel :: (MonadIO m, IsButton o) => o -> Text -> m () Source #
Set the value of the “label” property.
 When overloading is enabled, this is equivalent to
setbutton [ #label:=value ]
useUnderline
No description available in the introspection data.
constructButtonUseUnderline :: (IsButton 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.
getButtonUseUnderline :: (MonadIO m, IsButton o) => o -> m Bool Source #
Get the value of the “use-underline” property.
 When overloading is enabled, this is equivalent to
get button #useUnderline
setButtonUseUnderline :: (MonadIO m, IsButton o) => o -> Bool -> m () Source #
Set the value of the “use-underline” property.
 When overloading is enabled, this is equivalent to
setbutton [ #useUnderline:=value ]
Signals
activate
type ButtonActivateCallback = IO () Source #
type C_ButtonActivateCallback = Ptr () -> Ptr () -> IO () Source #
Type for the callback on the (unwrapped) C side.
afterButtonActivate :: (IsButton a, MonadIO m) => a -> ButtonActivateCallback -> 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 button #activate callback
genClosure_ButtonActivate :: MonadIO m => ButtonActivateCallback -> m (GClosure C_ButtonActivateCallback) Source #
Wrap the callback into a GClosure.
mk_ButtonActivateCallback :: C_ButtonActivateCallback -> IO (FunPtr C_ButtonActivateCallback) Source #
Generate a function pointer callable from C code, from a C_ButtonActivateCallback.
noButtonActivateCallback :: Maybe ButtonActivateCallback Source #
A convenience synonym for Nothing :: Maybe ButtonActivateCallback
onButtonActivate :: (IsButton a, MonadIO m) => a -> ButtonActivateCallback -> 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 button #activate callback
wrap_ButtonActivateCallback :: ButtonActivateCallback -> C_ButtonActivateCallback Source #
Wrap a ButtonActivateCallback into a C_ButtonActivateCallback.
clicked
type ButtonClickedCallback = IO () Source #
Emitted when the button has been activated (pressed and released).
type C_ButtonClickedCallback = Ptr () -> Ptr () -> IO () Source #
Type for the callback on the (unwrapped) C side.
afterButtonClicked :: (IsButton a, MonadIO m) => a -> ButtonClickedCallback -> m SignalHandlerId Source #
Connect a signal handler for the clicked signal, to be run after the default handler. When overloading is enabled, this is equivalent to
after button #clicked callback
genClosure_ButtonClicked :: MonadIO m => ButtonClickedCallback -> m (GClosure C_ButtonClickedCallback) Source #
Wrap the callback into a GClosure.
mk_ButtonClickedCallback :: C_ButtonClickedCallback -> IO (FunPtr C_ButtonClickedCallback) Source #
Generate a function pointer callable from C code, from a C_ButtonClickedCallback.
noButtonClickedCallback :: Maybe ButtonClickedCallback Source #
A convenience synonym for Nothing :: Maybe ButtonClickedCallback
onButtonClicked :: (IsButton a, MonadIO m) => a -> ButtonClickedCallback -> m SignalHandlerId Source #
Connect a signal handler for the clicked signal, to be run before the default handler. When overloading is enabled, this is equivalent to
on button #clicked callback