| 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.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 ();
  box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
  text = "Hi, I’m a toggle button.";
  toggle1 = gtk_toggle_button_new_with_label (text);
  g_signal_connect (toggle1, "toggled",
                    G_CALLBACK (output_state),
                    NULL);
  gtk_box_append (GTK_BOX (box), toggle1);
  text = "Hi, I’m a toggle button.";
  toggle2 = gtk_toggle_button_new_with_label (text);
  g_signal_connect (toggle2, "toggled",
                    G_CALLBACK (output_state),
                    NULL);
  gtk_box_append (GTK_BOX (box), toggle2);
  gtk_window_set_child (GTK_WINDOW (window), box);
  gtk_widget_show (window);
}Synopsis
- newtype ToggleButton = ToggleButton (ManagedPtr ToggleButton)
- class (GObject o, IsDescendantOf ToggleButton o) => IsToggleButton o
- toToggleButton :: (MonadIO m, IsToggleButton o) => o -> m ToggleButton
- toggleButtonGetActive :: (HasCallStack, MonadIO m, IsToggleButton a) => a -> m Bool
- toggleButtonNew :: (HasCallStack, MonadIO m) => m ToggleButton
- toggleButtonNewWithLabel :: (HasCallStack, MonadIO m) => Text -> m ToggleButton
- toggleButtonNewWithMnemonic :: (HasCallStack, MonadIO m) => Text -> m ToggleButton
- toggleButtonSetActive :: (HasCallStack, MonadIO m, IsToggleButton a) => a -> Bool -> m ()
- toggleButtonSetGroup :: (HasCallStack, MonadIO m, IsToggleButton a, IsToggleButton b) => a -> Maybe b -> m ()
- toggleButtonToggled :: (HasCallStack, MonadIO m, IsToggleButton a) => a -> m ()
- constructToggleButtonActive :: (IsToggleButton o, MonadIO m) => Bool -> m (GValueConstruct o)
- getToggleButtonActive :: (MonadIO m, IsToggleButton o) => o -> m Bool
- setToggleButtonActive :: (MonadIO m, IsToggleButton o) => o -> Bool -> m ()
- clearToggleButtonGroup :: (MonadIO m, IsToggleButton o) => o -> m ()
- constructToggleButtonGroup :: (IsToggleButton o, MonadIO m, IsToggleButton a) => a -> m (GValueConstruct o)
- setToggleButtonGroup :: (MonadIO m, IsToggleButton o, IsToggleButton a) => o -> a -> m ()
- type C_ToggleButtonToggledCallback = Ptr () -> Ptr () -> IO ()
- type ToggleButtonToggledCallback = IO ()
- afterToggleButtonToggled :: (IsToggleButton a, MonadIO m) => a -> ToggleButtonToggledCallback -> m SignalHandlerId
- genClosure_ToggleButtonToggled :: MonadIO m => ToggleButtonToggledCallback -> m (GClosure C_ToggleButtonToggledCallback)
- mk_ToggleButtonToggledCallback :: C_ToggleButtonToggledCallback -> IO (FunPtr C_ToggleButtonToggledCallback)
- noToggleButtonToggledCallback :: Maybe ToggleButtonToggledCallback
- onToggleButtonToggled :: (IsToggleButton a, MonadIO m) => a -> ToggleButtonToggledCallback -> m SignalHandlerId
- wrap_ToggleButtonToggledCallback :: ToggleButtonToggledCallback -> C_ToggleButtonToggledCallback
Exported types
newtype ToggleButton Source #
Memory-managed wrapper type.
Constructors
| ToggleButton (ManagedPtr ToggleButton) | 
Instances
| Eq ToggleButton Source # | |
| Defined in GI.Gtk.Objects.ToggleButton | |
| GObject ToggleButton Source # | |
| Defined in GI.Gtk.Objects.ToggleButton | |
| ManagedPtrNewtype ToggleButton Source # | |
| Defined in GI.Gtk.Objects.ToggleButton Methods toManagedPtr :: ToggleButton -> ManagedPtr ToggleButton | |
| TypedObject ToggleButton Source # | |
| Defined in GI.Gtk.Objects.ToggleButton | |
| HasParentTypes ToggleButton Source # | |
| Defined in GI.Gtk.Objects.ToggleButton | |
| IsGValue (Maybe ToggleButton) Source # | Convert  | 
| 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 # | |
| Defined in GI.Gtk.Objects.ToggleButton type ParentTypes ToggleButton = '[Button, Widget, Object, Accessible, Actionable, Buildable, ConstraintTarget] | |
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
| (GObject o, IsDescendantOf ToggleButton o) => IsToggleButton o Source # | |
| 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
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, toggled, translateCoordinates, triggerTooltipQuery, unmap, unparent, unrealize, unref, unsetStateFlags, updateProperty, updateRelation, updateState, watchClosure.
Getters
getAccessibleRole, getActionName, getActionTargetValue, getActive, 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, setActive, setCanFocus, setCanTarget, setChild, setChildVisible, setCssClasses, setCursor, setCursorFromName, setData, setDataFull, setDetailedActionName, setDirection, setFocusChild, setFocusOnClick, setFocusable, setFontMap, setFontOptions, setGroup, 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.
getActive
toggleButtonGetActive Source #
Arguments
| :: (HasCallStack, MonadIO m, IsToggleButton a) | |
| => a | 
 | 
| -> m Bool | Returns: a  | 
Queries a ToggleButton and returns its current state. Returns True if
 the toggle button is pressed in and False if it is raised.
new
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 | 
 | 
| -> m ToggleButton | Returns: a new toggle button. | 
Creates a new toggle button with a text label.
newWithMnemonic
toggleButtonNewWithMnemonic Source #
Arguments
| :: (HasCallStack, MonadIO m) | |
| => Text | 
 | 
| -> m ToggleButton | Returns: a new  | 
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 | 
 | 
| -> Bool | |
| -> m () | 
setGroup
Arguments
| :: (HasCallStack, MonadIO m, IsToggleButton a, IsToggleButton b) | |
| => a | 
 | 
| -> Maybe b | 
 | 
| -> m () | 
Adds self to the group of group. In a group of multiple toggle buttons,
 only one button can be active at a time.
Note that the same effect can be achieved via the Actionable
 api, by using the same action with parameter type and state type 's'
 for all buttons in the group, and giving each button its own target
 value.
toggled
Arguments
| :: (HasCallStack, MonadIO m, IsToggleButton a) | |
| => a | 
 | 
| -> m () | 
Emits the 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
settoggleButton [ #active:=value ]
group
No description available in the introspection data.
clearToggleButtonGroup :: (MonadIO m, IsToggleButton o) => o -> m () Source #
Set the value of the “group” property to Nothing.
 When overloading is enabled, this is equivalent to
clear #group
constructToggleButtonGroup :: (IsToggleButton o, MonadIO m, IsToggleButton a) => a -> m (GValueConstruct o) Source #
Construct a GValueConstruct with valid value for the “group” property. This is rarely needed directly, but it is used by new.
setToggleButtonGroup :: (MonadIO m, IsToggleButton o, IsToggleButton a) => o -> a -> m () Source #
Set the value of the “group” property.
 When overloading is enabled, this is equivalent to
settoggleButton [ #group:=value ]
Signals
toggled
type C_ToggleButtonToggledCallback = Ptr () -> Ptr () -> IO () Source #
Type for the callback on the (unwrapped) C side.
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 -> 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
genClosure_ToggleButtonToggled :: MonadIO m => ToggleButtonToggledCallback -> m (GClosure C_ToggleButtonToggledCallback) Source #
Wrap the callback into a GClosure.
mk_ToggleButtonToggledCallback :: C_ToggleButtonToggledCallback -> IO (FunPtr C_ToggleButtonToggledCallback) Source #
Generate a function pointer callable from C code, from a C_ToggleButtonToggledCallback.
noToggleButtonToggledCallback :: Maybe ToggleButtonToggledCallback Source #
A convenience synonym for Nothing :: Maybe ToggleButtonToggledCallback
onToggleButtonToggled :: (IsToggleButton a, MonadIO m) => 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