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

GI.Gtk.Objects.ToggleButton

Description

A ToggleButton is a Button which will remain “pressed-in” when clicked. Clicking again will cause the toggle button to return to its normal state.

A toggle button is created by calling either toggleButtonNew or toggleButtonNewWithLabel. If using the former, it is advisable to pack a widget, (such as a Label and/or a Image), into the toggle button’s container. (See Button for more information).

The state of a ToggleButton can be set specifically using toggleButtonSetActive, and retrieved using toggleButtonGetActive.

To simply switch the state of a toggle button, use toggleButtonToggled.

CSS nodes

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

## Creating two ToggleButton widgets.

C code

static void output_state (GtkToggleButton *source, gpointer user_data) {
  printf ("Active: %d\n", gtk_toggle_button_get_active (source));
}

void make_toggles (void) {
  GtkWidget *window, *toggle1, *toggle2;
  GtkWidget *box;
  const char *text;

  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);

  text = "Hi, I’m a toggle button.";
  toggle1 = gtk_toggle_button_new_with_label (text);

  // Makes this toggle button invisible
  gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (toggle1),
                              TRUE);

  g_signal_connect (toggle1, "toggled",
                    G_CALLBACK (output_state),
                    NULL);
  gtk_container_add (GTK_CONTAINER (box), toggle1);

  text = "Hi, I’m a toggle button.";
  toggle2 = gtk_toggle_button_new_with_label (text);
  gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (toggle2),
                              FALSE);
  g_signal_connect (toggle2, "toggled",
                    G_CALLBACK (output_state),
                    NULL);
  gtk_container_add (GTK_CONTAINER (box), toggle2);

  gtk_container_add (GTK_CONTAINER (window), box);
  gtk_widget_show_all (window);
}
Synopsis

Exported types

newtype ToggleButton Source #

Memory-managed wrapper type.

Constructors

ToggleButton (ManagedPtr ToggleButton) 

Instances

Instances details
Eq ToggleButton Source # 
Instance details

Defined in GI.Gtk.Objects.ToggleButton

GObject ToggleButton Source # 
Instance details

Defined in GI.Gtk.Objects.ToggleButton

ManagedPtrNewtype ToggleButton Source # 
Instance details

Defined in GI.Gtk.Objects.ToggleButton

Methods

toManagedPtr :: ToggleButton -> ManagedPtr ToggleButton

TypedObject ToggleButton Source # 
Instance details

Defined in GI.Gtk.Objects.ToggleButton

Methods

glibType :: IO GType

HasParentTypes ToggleButton Source # 
Instance details

Defined in GI.Gtk.Objects.ToggleButton

IsGValue (Maybe ToggleButton) Source #

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

Instance details

Defined in GI.Gtk.Objects.ToggleButton

Methods

gvalueGType_ :: IO GType

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

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

type ParentTypes ToggleButton Source # 
Instance details

Defined in GI.Gtk.Objects.ToggleButton

type ParentTypes ToggleButton = '[Button, Bin, Container, Widget, Object, ImplementorIface, Actionable, Activatable, Buildable]

class (GObject o, IsDescendantOf ToggleButton o) => IsToggleButton o Source #

Type class for types which can be safely cast to ToggleButton, for instance with toToggleButton.

Instances

Instances details
(GObject o, IsDescendantOf ToggleButton o) => IsToggleButton o Source # 
Instance details

Defined in GI.Gtk.Objects.ToggleButton

toToggleButton :: (MonadIO m, IsToggleButton o) => o -> m ToggleButton Source #

Cast to ToggleButton, 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

activate, add, addAccelerator, addChild, addDeviceEvents, addEvents, addMnemonicLabel, addTickCallback, bindProperty, bindPropertyFull, canActivateAccel, checkResize, childFocus, childGetProperty, childNotify, childNotifyByPspec, childSetProperty, childType, classPath, clicked, computeExpand, constructChild, createPangoContext, createPangoLayout, customFinished, customTagEnd, customTagStart, destroy, destroyed, deviceIsShadowed, doSetRelatedAction, dragBegin, dragBeginWithCoordinates, dragCheckThreshold, dragDestAddImageTargets, dragDestAddTextTargets, dragDestAddUriTargets, dragDestFindTarget, dragDestGetTargetList, dragDestGetTrackMotion, dragDestSet, dragDestSetProxy, dragDestSetTargetList, dragDestSetTrackMotion, dragDestUnset, dragGetData, dragHighlight, dragSourceAddImageTargets, dragSourceAddTextTargets, dragSourceAddUriTargets, dragSourceGetTargetList, dragSourceSet, dragSourceSetIconGicon, dragSourceSetIconName, dragSourceSetIconPixbuf, dragSourceSetIconStock, dragSourceSetTargetList, dragSourceUnset, dragUnhighlight, draw, ensureStyle, enter, errorBell, event, forall, forceFloating, foreach, freezeChildNotify, freezeNotify, getv, grabAdd, grabDefault, grabFocus, grabRemove, hasDefault, hasFocus, hasGrab, hasRcStyle, hasScreen, hasVisibleFocus, hide, hideOnDelete, inDestruction, initTemplate, inputShapeCombineRegion, insertActionGroup, intersect, isAncestor, isComposited, isDrawable, isFloating, isFocus, isSensitive, isToplevel, isVisible, keynavFailed, leave, listAccelClosures, listActionPrefixes, listMnemonicLabels, map, mnemonicActivate, modifyBase, modifyBg, modifyCursor, modifyFg, modifyFont, modifyStyle, modifyText, notify, notifyByPspec, overrideBackgroundColor, overrideColor, overrideCursor, overrideFont, overrideSymbolicColor, parserFinished, path, pressed, propagateDraw, queueAllocate, queueComputeExpand, queueDraw, queueDrawArea, queueDrawRegion, queueResize, queueResizeNoRedraw, realize, ref, refSink, regionIntersect, registerWindow, released, remove, removeAccelerator, removeMnemonicLabel, removeTickCallback, renderIcon, renderIconPixbuf, reparent, resetRcStyles, resetStyle, resizeChildren, runDispose, sendExpose, sendFocusChange, shapeCombineRegion, show, showAll, showNow, sizeAllocate, sizeAllocateWithBaseline, sizeRequest, stealData, stealQdata, styleAttach, styleGetProperty, syncActionProperties, thawChildNotify, thawNotify, toggled, translateCoordinates, triggerTooltipQuery, unmap, unparent, unrealize, unref, unregisterWindow, unsetFocusChain, unsetStateFlags, watchClosure.

Getters

getAccessible, getActionGroup, getActionName, getActionTargetValue, getActive, getAlignment, getAllocatedBaseline, getAllocatedHeight, getAllocatedSize, getAllocatedWidth, getAllocation, getAlwaysShowImage, getAncestor, getAppPaintable, getBorderWidth, getCanDefault, getCanFocus, getChild, getChildRequisition, getChildVisible, getChildren, getClip, getClipboard, getCompositeName, getData, getDeviceEnabled, getDeviceEvents, getDirection, getDisplay, getDoubleBuffered, getEventWindow, getEvents, getFocusChain, getFocusChild, getFocusHadjustment, getFocusOnClick, getFocusVadjustment, getFontMap, getFontOptions, getFrameClock, getHalign, getHasTooltip, getHasWindow, getHexpand, getHexpandSet, getImage, getImagePosition, getInconsistent, getInternalChild, getLabel, getMapped, getMarginBottom, getMarginEnd, getMarginLeft, getMarginRight, getMarginStart, getMarginTop, getMode, getModifierMask, getModifierStyle, getName, getNoShowAll, getOpacity, getPangoContext, getParent, getParentWindow, getPath, getPathForChild, getPointer, getPreferredHeight, getPreferredHeightAndBaselineForWidth, getPreferredHeightForWidth, getPreferredSize, getPreferredWidth, getPreferredWidthForHeight, getProperty, getQdata, getRealized, getReceivesDefault, getRelatedAction, getRelief, getRequestMode, getRequisition, getResizeMode, getRootWindow, getScaleFactor, getScreen, getSensitive, getSettings, getSizeRequest, getState, getStateFlags, getStyle, getStyleContext, getSupportMultidevice, getTemplateChild, getTooltipMarkup, getTooltipText, getTooltipWindow, getToplevel, getUseActionAppearance, getUseStock, getUseUnderline, getValign, getValignWithBaseline, getVexpand, getVexpandSet, getVisible, getVisual, getWindow.

Setters

setAccelPath, setActionName, setActionTargetValue, setActive, setAlignment, setAllocation, setAlwaysShowImage, setAppPaintable, setBorderWidth, setBuildableProperty, setCanDefault, setCanFocus, setChildVisible, setClip, setCompositeName, setData, setDataFull, setDetailedActionName, setDeviceEnabled, setDeviceEvents, setDirection, setDoubleBuffered, setEvents, setFocusChain, setFocusChild, setFocusHadjustment, setFocusOnClick, setFocusVadjustment, setFontMap, setFontOptions, setHalign, setHasTooltip, setHasWindow, setHexpand, setHexpandSet, setImage, setImagePosition, setInconsistent, setLabel, setMapped, setMarginBottom, setMarginEnd, setMarginLeft, setMarginRight, setMarginStart, setMarginTop, setMode, setName, setNoShowAll, setOpacity, setParent, setParentWindow, setProperty, setRealized, setReallocateRedraws, setReceivesDefault, setRedrawOnAllocate, setRelatedAction, setRelief, setResizeMode, setSensitive, setSizeRequest, setState, setStateFlags, setStyle, setSupportMultidevice, setTooltipMarkup, setTooltipText, setTooltipWindow, setUseActionAppearance, setUseStock, setUseUnderline, setValign, setVexpand, setVexpandSet, setVisible, setVisual, setWindow.

getActive

toggleButtonGetActive Source #

Arguments

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

toggleButton: a ToggleButton.

-> m Bool

Returns: a Bool value.

Queries a ToggleButton and returns its current state. Returns True if the toggle button is pressed in and False if it is raised.

getInconsistent

toggleButtonGetInconsistent Source #

Arguments

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

toggleButton: a ToggleButton

-> m Bool

Returns: True if the button is displayed as inconsistent, False otherwise

Gets the value set by toggleButtonSetInconsistent.

getMode

toggleButtonGetMode Source #

Arguments

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

toggleButton: a ToggleButton

-> m Bool

Returns: True if the togglebutton is drawn as a separate indicator and label.

Retrieves whether the button is displayed as a separate indicator and label. See toggleButtonSetMode.

new

toggleButtonNew Source #

Arguments

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

Returns: a new toggle button.

Creates a new toggle button. A widget should be packed into the button, as in buttonNew.

newWithLabel

toggleButtonNewWithLabel Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Text

label: a string containing the message to be placed in the toggle button.

-> m ToggleButton

Returns: a new toggle button.

Creates a new toggle button with a text label.

newWithMnemonic

toggleButtonNewWithMnemonic Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Text

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

-> m ToggleButton

Returns: a new ToggleButton

Creates a new ToggleButton containing a label. The label will be created using labelNewWithMnemonic, so underscores in label indicate the mnemonic for the button.

setActive

toggleButtonSetActive Source #

Arguments

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

toggleButton: a ToggleButton.

-> Bool

isActive: True or False.

-> m () 

Sets the status of the toggle button. Set to True if you want the GtkToggleButton to be “pressed in”, and False to raise it. This action causes the ToggleButton::toggled signal and the Button::clicked signal to be emitted.

setInconsistent

toggleButtonSetInconsistent Source #

Arguments

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

toggleButton: a ToggleButton

-> Bool

setting: True if state is inconsistent

-> m () 

If the user has selected a range of elements (such as some text or spreadsheet cells) that are affected by a toggle button, and the current values in that range are inconsistent, you may want to display the toggle in an “in between” state. This function turns on “in between” display. Normally you would turn off the inconsistent state again if the user toggles the toggle button. This has to be done manually, toggleButtonSetInconsistent only affects visual appearance, it doesn’t affect the semantics of the button.

setMode

toggleButtonSetMode Source #

Arguments

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

toggleButton: a ToggleButton

-> Bool

drawIndicator: if True, draw the button as a separate indicator and label; if False, draw the button like a normal button

-> m () 

Sets whether the button is displayed as a separate indicator and label. You can call this function on a checkbutton or a radiobutton with drawIndicator = False to make the button look like a normal button.

This can be used to create linked strip of buttons that work like a StackSwitcher.

This function only affects instances of classes like CheckButton and RadioButton that derive from ToggleButton, not instances of ToggleButton itself.

toggled

toggleButtonToggled Source #

Arguments

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

toggleButton: a ToggleButton.

-> m () 

Emits the ToggleButton::toggled signal on the ToggleButton. There is no good reason for an application ever to call this function.

Properties

active

No description available in the introspection data.

constructToggleButtonActive :: (IsToggleButton o, MonadIO m) => Bool -> m (GValueConstruct o) Source #

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

getToggleButtonActive :: (MonadIO m, IsToggleButton o) => o -> m Bool Source #

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

get toggleButton #active

setToggleButtonActive :: (MonadIO m, IsToggleButton o) => o -> Bool -> m () Source #

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

set toggleButton [ #active := value ]

drawIndicator

No description available in the introspection data.

constructToggleButtonDrawIndicator :: (IsToggleButton o, MonadIO m) => Bool -> m (GValueConstruct o) Source #

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

getToggleButtonDrawIndicator :: (MonadIO m, IsToggleButton o) => o -> m Bool Source #

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

get toggleButton #drawIndicator

setToggleButtonDrawIndicator :: (MonadIO m, IsToggleButton o) => o -> Bool -> m () Source #

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

set toggleButton [ #drawIndicator := value ]

inconsistent

No description available in the introspection data.

constructToggleButtonInconsistent :: (IsToggleButton o, MonadIO m) => Bool -> m (GValueConstruct o) Source #

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

getToggleButtonInconsistent :: (MonadIO m, IsToggleButton o) => o -> m Bool Source #

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

get toggleButton #inconsistent

setToggleButtonInconsistent :: (MonadIO m, IsToggleButton o) => o -> Bool -> m () Source #

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

set toggleButton [ #inconsistent := value ]

Signals

toggled

type ToggleButtonToggledCallback = IO () Source #

Should be connected if you wish to perform an action whenever the ToggleButton's state is changed.

afterToggleButtonToggled :: (IsToggleButton a, MonadIO m) => a -> ((?self :: a) => ToggleButtonToggledCallback) -> m SignalHandlerId Source #

Connect a signal handler for the toggled signal, to be run after the default handler. When overloading is enabled, this is equivalent to

after toggleButton #toggled callback

By default the object invoking the signal is not passed to the callback. If you need to access it, you can use the implit ?self parameter. Note that this requires activating the ImplicitParams GHC extension.

onToggleButtonToggled :: (IsToggleButton a, MonadIO m) => a -> ((?self :: a) => ToggleButtonToggledCallback) -> m SignalHandlerId Source #

Connect a signal handler for the toggled signal, to be run before the default handler. When overloading is enabled, this is equivalent to

on toggleButton #toggled callback