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

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, FontButton or FileChooserButton use style classes such as .toggle, .popup, .scale, .lock, .color, .file to differentiate themselves from a plain GtkButton.

Synopsis

Exported types

newtype Button Source #

Memory-managed wrapper type.

Constructors

Button (ManagedPtr Button) 

Instances

Instances details
Eq Button Source # 
Instance details

Defined in GI.Gtk.Objects.Button

Methods

(==) :: Button -> Button -> Bool #

(/=) :: Button -> Button -> Bool #

IsGValue Button Source #

Convert Button to and from GValue with toGValue and fromGValue.

Instance details

Defined in GI.Gtk.Objects.Button

GObject Button Source # 
Instance details

Defined in GI.Gtk.Objects.Button

Methods

gobjectType :: IO GType #

HasParentTypes Button Source # 
Instance details

Defined in GI.Gtk.Objects.Button

type ParentTypes Button Source # 
Instance details

Defined in GI.Gtk.Objects.Button

class (GObject o, IsDescendantOf Button o) => IsButton o Source #

Type class for types which can be safely cast to Button, for instance with toButton.

Instances

Instances details
(GObject o, IsDescendantOf Button o) => IsButton o Source # 
Instance details

Defined in GI.Gtk.Objects.Button

toButton :: (MonadIO m, IsButton o) => o -> m Button Source #

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

noButton :: Maybe Button Source #

A convenience alias for Nothing :: Maybe Button.

Methods

Overloaded methods

clicked

buttonClicked Source #

Arguments

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

button: The Button you want to send the signal to.

-> m () 

Emits a clicked signal to the given Button.

getIconName

buttonGetIconName Source #

Arguments

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

button: A Button

-> m (Maybe Text)

Returns: The icon name set via buttonSetIconName

Returns the icon name set via buttonSetIconName.

getLabel

buttonGetLabel Source #

Arguments

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

button: a Button

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

getRelief

buttonGetRelief Source #

Arguments

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

button: The Button you want the ReliefStyle from.

-> m ReliefStyle

Returns: The current ReliefStyle

Returns the current relief style of the given Button.

getUseUnderline

buttonGetUseUnderline Source #

Arguments

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

button: a Button

-> m Bool

Returns: True if an embedded underline in the button label indicates the mnemonic accelerator keys.

Returns whether an embedded underline in the button label indicates a mnemonic. See buttonSetUseUnderline.

new

buttonNew Source #

Arguments

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

Returns: The newly created Button widget.

Creates a new Button widget. To add a child widget to the button, use containerAdd.

newFromIconName

buttonNewFromIconName Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Maybe Text

iconName: an icon name or Nothing

-> m Button

Returns: a new Button displaying the themed icon

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

buttonNewWithLabel Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Text

label: The text you want the Label to hold.

-> m Button

Returns: The newly created Button widget.

Creates a Button widget with a Label child containing the given text.

newWithMnemonic

buttonNewWithMnemonic Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Text

label: The text of the button, with an underscore in front of the mnemonic character

-> m Button

Returns: a new Button

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.

setIconName

buttonSetIconName Source #

Arguments

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

button: A Button

-> Text

iconName: A icon name

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

buttonSetLabel Source #

Arguments

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

button: a Button

-> Text

label: a string

-> m () 

Sets the text of the label of the button to label.

This will also clear any previously set labels.

setRelief

buttonSetRelief Source #

Arguments

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

button: The Button you want to set relief styles of

-> ReliefStyle

relief: The GtkReliefStyle as described above

-> m () 

Sets the relief style of the edges of the given Button widget. Two styles exist, ReliefStyleNormal and ReliefStyleNone. The default style is, as one can guess, ReliefStyleNormal.

setUseUnderline

buttonSetUseUnderline Source #

Arguments

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

button: a Button

-> Bool

useUnderline: True if underlines in the text indicate mnemonics

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

iconName

No description available in the introspection data.

constructButtonIconName :: IsButton o => Text -> IO (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

set button [ #iconName := value ]

label

No description available in the introspection data.

constructButtonLabel :: IsButton 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.

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

set button [ #label := value ]

relief

No description available in the introspection data.

constructButtonRelief :: IsButton o => ReliefStyle -> IO (GValueConstruct o) Source #

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

getButtonRelief :: (MonadIO m, IsButton o) => o -> m ReliefStyle Source #

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

get button #relief

setButtonRelief :: (MonadIO m, IsButton o) => o -> ReliefStyle -> m () Source #

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

set button [ #relief := value ]

useUnderline

No description available in the introspection data.

constructButtonUseUnderline :: IsButton 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.

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

set button [ #useUnderline := value ]

Signals

activate

type ButtonActivateCallback = IO () Source #

The activate signal on GtkButton is an action signal and emitting it causes the button to animate press then release. Applications should never connect to this signal, but use the clicked signal.

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

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

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

mk_ButtonClickedCallback :: C_ButtonClickedCallback -> IO (FunPtr C_ButtonClickedCallback) Source #

Generate a function pointer callable from C code, from a C_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