gi-gtk4-4.0.12: Gtk 4.x bindings

Copyright | Will Thompson and Iñaki García Etxebarria
License | LGPL-2.1
Maintainer | Iñaki García Etxebarria
Safe Haskell | None
Language | Haskell2010

GI.Gtk.Objects.Label

Contents

- Exported types
- Methods
  - getAttributes
  - getCurrentUri
  - getEllipsize
  - getExtraMenu
  - getJustify
  - getLabel
  - getLayout
  - getLayoutOffsets
  - getLines
  - getMaxWidthChars
  - getMnemonicKeyval
  - getMnemonicWidget
  - getNaturalWrapMode
  - getSelectable
  - getSelectionBounds
  - getSingleLineMode
  - getTabs
  - getText
  - getUseMarkup
  - getUseUnderline
  - getWidthChars
  - getWrap
  - getWrapMode
  - getXalign
  - getYalign
  - new
  - newWithMnemonic
  - selectRegion
  - setAttributes
  - setEllipsize
  - setExtraMenu
  - setJustify
  - setLabel
  - setLines
  - setMarkup
  - setMarkupWithMnemonic
  - setMaxWidthChars
  - setMnemonicWidget
  - setNaturalWrapMode
  - setSelectable
  - setSingleLineMode
  - setTabs
  - setText
  - setTextWithMnemonic
  - setUseMarkup
  - setUseUnderline
  - setWidthChars
  - setWrap
  - setWrapMode
  - setXalign
  - setYalign
- Properties
  - attributes
  - ellipsize
  - extraMenu
  - justify
  - label
  - lines
  - maxWidthChars
  - mnemonicKeyval
  - mnemonicWidget
  - naturalWrapMode
  - selectable
  - singleLineMode
  - tabs
  - useMarkup
  - useUnderline
  - widthChars
  - wrap
  - wrapMode
  - xalign
  - yalign
- Signals
  - activateCurrentLink
  - activateLink
  - copyClipboard
  - moveCursor

Description

Displays a small amount of text.

Most labels are used to label another widget (such as an [class`entry`]).

<picture> <source srcset="label-dark.png" media="(prefers-color-scheme: dark)"> <img alt="An example GtkLabel" src="label.png"> </picture>

## Shortcuts and Gestures

`GtkLabel` supports the following keyboard shortcuts, when the cursor is visible:

- <kbd>Shift</kbd>+<kbd>F10</kbd> or <kbd>Menu</kbd> opens the context menu.
- <kbd>Ctrl</kbd>+<kbd>A</kbd> or <kbd>Ctrl</kbd>+<kbd>&sol;</kbd> selects all.
- <kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>A</kbd> or <kbd>Ctrl</kbd>+<kbd>&bsol;</kbd> unselects all.

Additionally, the following signals have default keybindings:

- Label::activateCurrentLink
- Label::copyClipboard
- Label::moveCursor

## Actions

`GtkLabel` defines a set of built-in actions:

- `clipboard.copy` copies the text to the clipboard.
- `clipboard.cut` doesn't do anything, since text in labels can't be deleted.
- `clipboard.paste` doesn't do anything, since text in labels can't be edited.
- `link.open` opens the link, when activated on a link inside the label.
- `link.copy` copies the link to the clipboard, when activated on a link inside the label.
- `menu.popup` opens the context menu.
- `selection.delete` doesn't do anything, since text in labels can't be deleted.
- `selection.select-all` selects all of the text, if the label allows selection.

## CSS nodes

    label
    ├── [selection]
    ├── [link]
    ┊
    ╰── [link]

`GtkLabel` has a single CSS node with the name label. A wide variety of style classes may be applied to labels, such as .title, .subtitle, .dim-label, etc. In the `GtkShortcutsWindow`, labels are used with the .keycap style class.

If the label has a selection, it gets a subnode with name selection.

If the label has links, there is one subnode per link. These subnodes carry the link or visited state depending on whether they have been visited. In this case, label node also gets a .link style class.

## GtkLabel as GtkBuildable

The GtkLabel implementation of the GtkBuildable interface supports a custom `<attributes>` element, which supports any number of `<attribute>` elements. The `<attribute>` element has attributes named “name“, “value“, “start“ and “end“ and allows you to specify `Attribute` values for this label.

An example of a UI definition fragment specifying Pango attributes:

### xml code

    <object class="GtkLabel">
      <attributes>
        <attribute name="weight" value="PANGO_WEIGHT_BOLD"/>
        <attribute name="background" value="red" start="5" end="10"/>
      </attributes>
    </object>

The start and end attributes specify the range of characters to which the Pango attribute applies. If start and end are not specified, the attribute is applied to the whole text. Note that specifying ranges does not make much sense with translatable attributes. Use markup embedded in the translatable content instead.

## Accessibility

`GtkLabel` uses the `AccessibleRoleLabel` role.

## Mnemonics

Labels may contain “mnemonics”. Mnemonics are underlined characters in the label, used for keyboard navigation. Mnemonics are created by providing a string with an underscore before the mnemonic character, such as `"_File"`, to the functions `labelNewWithMnemonic` or `labelSetTextWithMnemonic`.

Mnemonics automatically activate any activatable widget the label is inside, such as a `Button`; if the label is not inside the mnemonic’s target widget, you have to tell the label about the target using `labelSetMnemonicWidget`.

Here’s a simple example where the label is inside a button:

### c code

    // Pressing Alt+H will activate this button
    GtkWidget *button = gtk_button_new ();
    GtkWidget *label = gtk_label_new_with_mnemonic ("_Hello");
    gtk_button_set_child (GTK_BUTTON (button), label);

There’s a convenience function to create buttons with a mnemonic label already inside:

### c code

    // Pressing Alt+H will activate this button
    GtkWidget *button = gtk_button_new_with_mnemonic ("_Hello");

To create a mnemonic for a widget alongside the label, such as a `Entry`, you have to point the label at the entry with `labelSetMnemonicWidget`:

### c code

    // Pressing Alt+H will focus the entry
    GtkWidget *entry = gtk_entry_new ();
    GtkWidget *label = gtk_label_new_with_mnemonic ("_Hello");
    gtk_label_set_mnemonic_widget (GTK_LABEL (label), entry);

## Markup (styled text)

To make it easy to format text in a label (changing colors, fonts, etc.), label text can be provided in a simple markup format:

Here’s how to create a label with a small font:

### c code

    GtkWidget *label = gtk_label_new (NULL);
    gtk_label_set_markup (GTK_LABEL (label), "<small>Small text</small>");

(See the Pango manual for complete documentation] of available tags, `parseMarkup`)

The markup passed to `labelSetMarkup` must be valid XML; for example, literal `<`, `>` and `&` characters must be escaped as `&lt;`, `&gt;`, and `&amp;`. If you pass text obtained from the user, file, or a network to `labelSetMarkup`, you’ll want to escape it with `markupEscapeText` or `GLib.markup_printf_escaped`.

Markup strings are just a convenient way to set the `AttrList` on a label; `labelSetAttributes` may be a simpler way to set attributes in some cases. Be careful though; `AttrList` tends to cause internationalization problems, unless you’re applying attributes to the entire string (i.e. unless you set the range of each attribute to [0, `G_MAXINT`)). The reason is that specifying the `start_index` and `end_index` for a `Attribute` requires knowledge of the exact string being displayed, so translations will cause problems.

## Selectable labels

Labels can be made selectable with `labelSetSelectable`. Selectable labels allow the user to copy the label contents to the clipboard. Only labels that contain useful-to-copy information — such as error messages — should be made selectable.

## Text layout

A label can contain any number of paragraphs, but will have performance problems if it contains more than a small number. Paragraphs are separated by newlines or other paragraph separators understood by Pango.

Labels can automatically wrap text if you call `labelSetWrap`.

`labelSetJustify` sets how the lines in a label align with one another. If you want to set how the label as a whole aligns in its available space, see the Widget:halign and Widget:valign properties.

The Label:widthChars and Label:maxWidthChars properties can be used to control the size allocation of ellipsized or wrapped labels. For ellipsizing labels, if either is specified (and less than the actual text size), it is used as the minimum width, and the actual text size is used as the natural width of the label. For wrapping labels, width-chars is used as the minimum width, if specified, and max-width-chars is used as the natural width. Even if max-width-chars specified, wrapping labels will be rewrapped to use all of the available width.

## Links

GTK supports markup for clickable hyperlinks in addition to regular Pango markup. The markup for links is borrowed from HTML, using the `<a>` tag with “href“, “title“ and “class“ attributes. GTK renders links similar to the way they appear in web browsers, with colored, underlined text. The “title“ attribute is displayed as a tooltip on the link. The “class“ attribute is used as style class on the CSS node for the link.

An example of inline links looks like this:

### c code

    const char *text =
    "Go to the "
    "<a href=\"https://www.gtk.org\" title=\"&lt;i&gt;Our&lt;/i&gt; website\">"
    "GTK website</a> for more...";
    GtkWidget *label = gtk_label_new (NULL);
    gtk_label_set_markup (GTK_LABEL (label), text);

It is possible to implement custom handling for links and their tooltips with the Label::activateLink signal and the `labelGetCurrentUri` function.

Synopsis

- newtype Label = Label (ManagedPtr Label)
- class (GObject o, IsDescendantOf Label o) => IsLabel o
- toLabel :: (MonadIO m, IsLabel o) => o -> m Label
- labelGetAttributes :: (HasCallStack, MonadIO m, IsLabel a) => a -> m (Maybe AttrList)
- labelGetCurrentUri :: (HasCallStack, MonadIO m, IsLabel a) => a -> m (Maybe Text)
- labelGetEllipsize :: (HasCallStack, MonadIO m, IsLabel a) => a -> m EllipsizeMode
- labelGetExtraMenu :: (HasCallStack, MonadIO m, IsLabel a) => a -> m (Maybe MenuModel)
- labelGetJustify :: (HasCallStack, MonadIO m, IsLabel a) => a -> m Justification
- labelGetLabel :: (HasCallStack, MonadIO m, IsLabel a) => a -> m Text
- labelGetLayout :: (HasCallStack, MonadIO m, IsLabel a) => a -> m Layout
- labelGetLayoutOffsets :: (HasCallStack, MonadIO m, IsLabel a) => a -> m (Int32, Int32)
- labelGetLines :: (HasCallStack, MonadIO m, IsLabel a) => a -> m Int32
- labelGetMaxWidthChars :: (HasCallStack, MonadIO m, IsLabel a) => a -> m Int32
- labelGetMnemonicKeyval :: (HasCallStack, MonadIO m, IsLabel a) => a -> m Word32
- labelGetMnemonicWidget :: (HasCallStack, MonadIO m, IsLabel a) => a -> m (Maybe Widget)
- labelGetNaturalWrapMode :: (HasCallStack, MonadIO m, IsLabel a) => a -> m NaturalWrapMode
- labelGetSelectable :: (HasCallStack, MonadIO m, IsLabel a) => a -> m Bool
- labelGetSelectionBounds :: (HasCallStack, MonadIO m, IsLabel a) => a -> m (Bool, Int32, Int32)
- labelGetSingleLineMode :: (HasCallStack, MonadIO m, IsLabel a) => a -> m Bool
- labelGetTabs :: (HasCallStack, MonadIO m, IsLabel a) => a -> m (Maybe TabArray)
- labelGetText :: (HasCallStack, MonadIO m, IsLabel a) => a -> m Text
- labelGetUseMarkup :: (HasCallStack, MonadIO m, IsLabel a) => a -> m Bool
- labelGetUseUnderline :: (HasCallStack, MonadIO m, IsLabel a) => a -> m Bool
- labelGetWidthChars :: (HasCallStack, MonadIO m, IsLabel a) => a -> m Int32
- labelGetWrap :: (HasCallStack, MonadIO m, IsLabel a) => a -> m Bool
- labelGetWrapMode :: (HasCallStack, MonadIO m, IsLabel a) => a -> m WrapMode
- labelGetXalign :: (HasCallStack, MonadIO m, IsLabel a) => a -> m Float
- labelGetYalign :: (HasCallStack, MonadIO m, IsLabel a) => a -> m Float
- labelNew :: (HasCallStack, MonadIO m) => Maybe Text -> m Label
- labelNewWithMnemonic :: (HasCallStack, MonadIO m) => Maybe Text -> m Label
- labelSelectRegion :: (HasCallStack, MonadIO m, IsLabel a) => a -> Int32 -> Int32 -> m ()
- labelSetAttributes :: (HasCallStack, MonadIO m, IsLabel a) => a -> Maybe AttrList -> m ()
- labelSetEllipsize :: (HasCallStack, MonadIO m, IsLabel a) => a -> EllipsizeMode -> m ()
- labelSetExtraMenu :: (HasCallStack, MonadIO m, IsLabel a, IsMenuModel b) => a -> Maybe b -> m ()
- labelSetJustify :: (HasCallStack, MonadIO m, IsLabel a) => a -> Justification -> m ()
- labelSetLabel :: (HasCallStack, MonadIO m, IsLabel a) => a -> Text -> m ()
- labelSetLines :: (HasCallStack, MonadIO m, IsLabel a) => a -> Int32 -> m ()
- labelSetMarkup :: (HasCallStack, MonadIO m, IsLabel a) => a -> Text -> m ()
- labelSetMarkupWithMnemonic :: (HasCallStack, MonadIO m, IsLabel a) => a -> Text -> m ()
- labelSetMaxWidthChars :: (HasCallStack, MonadIO m, IsLabel a) => a -> Int32 -> m ()
- labelSetMnemonicWidget :: (HasCallStack, MonadIO m, IsLabel a, IsWidget b) => a -> Maybe b -> m ()
- labelSetNaturalWrapMode :: (HasCallStack, MonadIO m, IsLabel a) => a -> NaturalWrapMode -> m ()
- labelSetSelectable :: (HasCallStack, MonadIO m, IsLabel a) => a -> Bool -> m ()
- labelSetSingleLineMode :: (HasCallStack, MonadIO m, IsLabel a) => a -> Bool -> m ()
- labelSetTabs :: (HasCallStack, MonadIO m, IsLabel a) => a -> Maybe TabArray -> m ()
- labelSetText :: (HasCallStack, MonadIO m, IsLabel a) => a -> Text -> m ()
- labelSetTextWithMnemonic :: (HasCallStack, MonadIO m, IsLabel a) => a -> Text -> m ()
- labelSetUseMarkup :: (HasCallStack, MonadIO m, IsLabel a) => a -> Bool -> m ()
- labelSetUseUnderline :: (HasCallStack, MonadIO m, IsLabel a) => a -> Bool -> m ()
- labelSetWidthChars :: (HasCallStack, MonadIO m, IsLabel a) => a -> Int32 -> m ()
- labelSetWrap :: (HasCallStack, MonadIO m, IsLabel a) => a -> Bool -> m ()
- labelSetWrapMode :: (HasCallStack, MonadIO m, IsLabel a) => a -> WrapMode -> m ()
- labelSetXalign :: (HasCallStack, MonadIO m, IsLabel a) => a -> Float -> m ()
- labelSetYalign :: (HasCallStack, MonadIO m, IsLabel a) => a -> Float -> m ()
- clearLabelAttributes :: (MonadIO m, IsLabel o) => o -> m ()
- constructLabelAttributes :: (IsLabel o, MonadIO m) => AttrList -> m (GValueConstruct o)
- getLabelAttributes :: (MonadIO m, IsLabel o) => o -> m (Maybe AttrList)
- setLabelAttributes :: (MonadIO m, IsLabel o) => o -> AttrList -> m ()
- constructLabelEllipsize :: (IsLabel o, MonadIO m) => EllipsizeMode -> m (GValueConstruct o)
- getLabelEllipsize :: (MonadIO m, IsLabel o) => o -> m EllipsizeMode
- setLabelEllipsize :: (MonadIO m, IsLabel o) => o -> EllipsizeMode -> m ()
- clearLabelExtraMenu :: (MonadIO m, IsLabel o) => o -> m ()
- constructLabelExtraMenu :: (IsLabel o, MonadIO m, IsMenuModel a) => a -> m (GValueConstruct o)
- getLabelExtraMenu :: (MonadIO m, IsLabel o) => o -> m (Maybe MenuModel)
- setLabelExtraMenu :: (MonadIO m, IsLabel o, IsMenuModel a) => o -> a -> m ()
- constructLabelJustify :: (IsLabel o, MonadIO m) => Justification -> m (GValueConstruct o)
- getLabelJustify :: (MonadIO m, IsLabel o) => o -> m Justification
- setLabelJustify :: (MonadIO m, IsLabel o) => o -> Justification -> m ()
- constructLabelLabel :: (IsLabel o, MonadIO m) => Text -> m (GValueConstruct o)
- getLabelLabel :: (MonadIO m, IsLabel o) => o -> m Text
- setLabelLabel :: (MonadIO m, IsLabel o) => o -> Text -> m ()
- constructLabelLines :: (IsLabel o, MonadIO m) => Int32 -> m (GValueConstruct o)
- getLabelLines :: (MonadIO m, IsLabel o) => o -> m Int32
- setLabelLines :: (MonadIO m, IsLabel o) => o -> Int32 -> m ()
- constructLabelMaxWidthChars :: (IsLabel o, MonadIO m) => Int32 -> m (GValueConstruct o)
- getLabelMaxWidthChars :: (MonadIO m, IsLabel o) => o -> m Int32
- setLabelMaxWidthChars :: (MonadIO m, IsLabel o) => o -> Int32 -> m ()
- getLabelMnemonicKeyval :: (MonadIO m, IsLabel o) => o -> m Word32
- clearLabelMnemonicWidget :: (MonadIO m, IsLabel o) => o -> m ()
- constructLabelMnemonicWidget :: (IsLabel o, MonadIO m, IsWidget a) => a -> m (GValueConstruct o)
- getLabelMnemonicWidget :: (MonadIO m, IsLabel o) => o -> m (Maybe Widget)
- setLabelMnemonicWidget :: (MonadIO m, IsLabel o, IsWidget a) => o -> a -> m ()
- constructLabelNaturalWrapMode :: (IsLabel o, MonadIO m) => NaturalWrapMode -> m (GValueConstruct o)
- getLabelNaturalWrapMode :: (MonadIO m, IsLabel o) => o -> m NaturalWrapMode
- setLabelNaturalWrapMode :: (MonadIO m, IsLabel o) => o -> NaturalWrapMode -> m ()
- constructLabelSelectable :: (IsLabel o, MonadIO m) => Bool -> m (GValueConstruct o)
- getLabelSelectable :: (MonadIO m, IsLabel o) => o -> m Bool
- setLabelSelectable :: (MonadIO m, IsLabel o) => o -> Bool -> m ()
- constructLabelSingleLineMode :: (IsLabel o, MonadIO m) => Bool -> m (GValueConstruct o)
- getLabelSingleLineMode :: (MonadIO m, IsLabel o) => o -> m Bool
- setLabelSingleLineMode :: (MonadIO m, IsLabel o) => o -> Bool -> m ()
- clearLabelTabs :: (MonadIO m, IsLabel o) => o -> m ()
- constructLabelTabs :: (IsLabel o, MonadIO m) => TabArray -> m (GValueConstruct o)
- getLabelTabs :: (MonadIO m, IsLabel o) => o -> m (Maybe TabArray)
- setLabelTabs :: (MonadIO m, IsLabel o) => o -> TabArray -> m ()
- constructLabelUseMarkup :: (IsLabel o, MonadIO m) => Bool -> m (GValueConstruct o)
- getLabelUseMarkup :: (MonadIO m, IsLabel o) => o -> m Bool
- setLabelUseMarkup :: (MonadIO m, IsLabel o) => o -> Bool -> m ()
- constructLabelUseUnderline :: (IsLabel o, MonadIO m) => Bool -> m (GValueConstruct o)
- getLabelUseUnderline :: (MonadIO m, IsLabel o) => o -> m Bool
- setLabelUseUnderline :: (MonadIO m, IsLabel o) => o -> Bool -> m ()
- constructLabelWidthChars :: (IsLabel o, MonadIO m) => Int32 -> m (GValueConstruct o)
- getLabelWidthChars :: (MonadIO m, IsLabel o) => o -> m Int32
- setLabelWidthChars :: (MonadIO m, IsLabel o) => o -> Int32 -> m ()
- constructLabelWrap :: (IsLabel o, MonadIO m) => Bool -> m (GValueConstruct o)
- getLabelWrap :: (MonadIO m, IsLabel o) => o -> m Bool
- setLabelWrap :: (MonadIO m, IsLabel o) => o -> Bool -> m ()
- constructLabelWrapMode :: (IsLabel o, MonadIO m) => WrapMode -> m (GValueConstruct o)
- getLabelWrapMode :: (MonadIO m, IsLabel o) => o -> m WrapMode
- setLabelWrapMode :: (MonadIO m, IsLabel o) => o -> WrapMode -> m ()
- constructLabelXalign :: (IsLabel o, MonadIO m) => Float -> m (GValueConstruct o)
- getLabelXalign :: (MonadIO m, IsLabel o) => o -> m Float
- setLabelXalign :: (MonadIO m, IsLabel o) => o -> Float -> m ()
- constructLabelYalign :: (IsLabel o, MonadIO m) => Float -> m (GValueConstruct o)
- getLabelYalign :: (MonadIO m, IsLabel o) => o -> m Float
- setLabelYalign :: (MonadIO m, IsLabel o) => o -> Float -> m ()
- type LabelActivateCurrentLinkCallback = IO ()
- afterLabelActivateCurrentLink :: (IsLabel a, MonadIO m) => a -> ((?self :: a) => LabelActivateCurrentLinkCallback) -> m SignalHandlerId
- onLabelActivateCurrentLink :: (IsLabel a, MonadIO m) => a -> ((?self :: a) => LabelActivateCurrentLinkCallback) -> m SignalHandlerId
- type LabelActivateLinkCallback = Text -> IO Bool
- afterLabelActivateLink :: (IsLabel a, MonadIO m) => a -> ((?self :: a) => LabelActivateLinkCallback) -> m SignalHandlerId
- onLabelActivateLink :: (IsLabel a, MonadIO m) => a -> ((?self :: a) => LabelActivateLinkCallback) -> m SignalHandlerId
- type LabelCopyClipboardCallback = IO ()
- afterLabelCopyClipboard :: (IsLabel a, MonadIO m) => a -> ((?self :: a) => LabelCopyClipboardCallback) -> m SignalHandlerId
- onLabelCopyClipboard :: (IsLabel a, MonadIO m) => a -> ((?self :: a) => LabelCopyClipboardCallback) -> m SignalHandlerId
- type LabelMoveCursorCallback = MovementStep -> Int32 -> Bool -> IO ()
- afterLabelMoveCursor :: (IsLabel a, MonadIO m) => a -> ((?self :: a) => LabelMoveCursorCallback) -> m SignalHandlerId
- onLabelMoveCursor :: (IsLabel a, MonadIO m) => a -> ((?self :: a) => LabelMoveCursorCallback) -> m SignalHandlerId

# Exported types

newtype Label Source #

Memory-managed wrapper type.

Constructors

Label (ManagedPtr Label) |

#### Instances

Instances details

Eq Label Source # |
Instance details Defined in GI.Gtk.Objects.Label Methods (==) :: Label -> Label -> Bool Source # (/=) :: Label -> Label -> Bool Source #
GObject Label Source # |
Instance details Defined in GI.Gtk.Objects.Label
ManagedPtrNewtype Label Source # |
Instance details Defined in GI.Gtk.Objects.Label Methods toManagedPtr :: Label -> ManagedPtr Label Source #
TypedObject Label Source # |
Instance details Defined in GI.Gtk.Objects.Label Methods glibType :: IO GType Source #
HasParentTypes Label Source # |
Instance details Defined in GI.Gtk.Objects.Label
IsGValue (Maybe Label) Source # | Convert `Label` to and from `GValue`. See `toGValue` and `fromGValue`.
Instance details Defined in GI.Gtk.Objects.Label Methods gvalueGType_ :: IO GType Source # gvalueSet_ :: Ptr GValue -> Maybe Label -> IO () Source # gvalueGet_ :: Ptr GValue -> IO (Maybe Label) Source #
type ParentTypes Label Source # |
Instance details Defined in GI.Gtk.Objects.Label type ParentTypes Label = '[Widget, Object, Accessible, AccessibleHypertext, AccessibleText, Buildable, ConstraintTarget]

class (GObject o, IsDescendantOf Label o) => IsLabel o Source #

Type class for types which can be safely cast to `Label`, for instance with `toLabel`.

#### Instances

Instances details

(GObject o, IsDescendantOf Label o) => IsLabel o Source # |
Instance details Defined in GI.Gtk.Objects.Label

toLabel :: (MonadIO m, IsLabel o) => o -> m Label Source #

Cast to `Label`, 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

actionSetEnabled, activate, activateAction, activateDefault, addController, addCssClass, addMnemonicLabel, addTickCallback, allocate, announce, bindProperty, bindPropertyFull, childFocus, computeBounds, computeExpand, computePoint, computeTransform, contains, createPangoContext, createPangoLayout, disposeTemplate, 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, selectRegion, shouldLayout, show, sizeAllocate, snapshotChild, stealData, stealQdata, thawNotify, translateCoordinates, triggerTooltipQuery, unmap, unparent, unrealize, unref, unsetStateFlags, updateCaretPosition, updateContents, updateNextAccessibleSibling, updatePlatformState, updateProperty, updateRelation, updateSelectionBound, updateState, watchClosure.

#### Getters

getAccessibleId, getAccessibleParent, getAccessibleRole, getAllocatedBaseline, getAllocatedHeight, getAllocatedWidth, getAllocation, getAncestor, getAtContext, getAttributes, getBaseline, getBounds, getBuildableId, getCanFocus, getCanTarget, getChildVisible, getClipboard, getColor, getCssClasses, getCssName, getCurrentUri, getCursor, getData, getDirection, getDisplay, getEllipsize, getExtraMenu, getFirstAccessibleChild, getFirstChild, getFocusChild, getFocusOnClick, getFocusable, getFontMap, getFontOptions, getFrameClock, getHalign, getHasTooltip, getHeight, getHexpand, getHexpandSet, getJustify, getLabel, getLastChild, getLayout, getLayoutManager, getLayoutOffsets, getLimitEvents, getLines, getMapped, getMarginBottom, getMarginEnd, getMarginStart, getMarginTop, getMaxWidthChars, getMnemonicKeyval, getMnemonicWidget, getName, getNative, getNaturalWrapMode, getNextAccessibleSibling, getNextSibling, getOpacity, getOverflow, getPangoContext, getParent, getPlatformState, getPreferredSize, getPrevSibling, getPrimaryClipboard, getProperty, getQdata, getRealized, getReceivesDefault, getRequestMode, getRoot, getScaleFactor, getSelectable, getSelectionBounds, getSensitive, getSettings, getSingleLineMode, getSize, getSizeRequest, getStateFlags, getStyleContext, getTabs, getTemplateChild, getText, getTooltipMarkup, getTooltipText, getUseMarkup, getUseUnderline, getValign, getVexpand, getVexpandSet, getVisible, getWidth, getWidthChars, getWrap, getWrapMode, getXalign, getYalign.

#### Setters

setAccessibleParent, setAttributes, setCanFocus, setCanTarget, setChildVisible, setCssClasses, setCursor, setCursorFromName, setData, setDataFull, setDirection, setEllipsize, setExtraMenu, setFocusChild, setFocusOnClick, setFocusable, setFontMap, setFontOptions, setHalign, setHasTooltip, setHexpand, setHexpandSet, setJustify, setLabel, setLayoutManager, setLimitEvents, setLines, setMarginBottom, setMarginEnd, setMarginStart, setMarginTop, setMarkup, setMarkupWithMnemonic, setMaxWidthChars, setMnemonicWidget, setName, setNaturalWrapMode, setOpacity, setOverflow, setParent, setProperty, setReceivesDefault, setSelectable, setSensitive, setSingleLineMode, setSizeRequest, setStateFlags, setTabs, setText, setTextWithMnemonic, setTooltipMarkup, setTooltipText, setUseMarkup, setUseUnderline, setValign, setVexpand, setVexpandSet, setVisible, setWidthChars, setWrap, setWrapMode, setXalign, setYalign.

## getAttributes

labelGetAttributes Source #

Arguments

:: (HasCallStack, MonadIO m, IsLabel a) |
=> a | `self`: a label
-> m (Maybe AttrList) | Returns: the attribute list

Gets the label's attribute list.

This is the `AttrList` that was set on the label using `labelSetAttributes`, if any. This function does not reflect attributes that come from the label's markup (see `labelSetMarkup`). If you want to get the effective attributes for the label, use `pango_layout_get_attributes (gtk_label_get_layout (self))`.

## getCurrentUri

labelGetCurrentUri Source #

Arguments

:: (HasCallStack, MonadIO m, IsLabel a) |
=> a | `self`: a label
-> m (Maybe Text) | Returns: the active URI

Returns the URI for the active link in the label.

The active link is the one under the mouse pointer or, in a selectable label, the link in which the text cursor is currently positioned.

This function is intended for use in a Label::activateLink handler or for use in a Widget::queryTooltip handler.

## getEllipsize

labelGetEllipsize Source #

Arguments

:: (HasCallStack, MonadIO m, IsLabel a) |
=> a | `self`: a label
-> m EllipsizeMode | Returns: the ellipsization mode

Returns the ellipsization mode of the label.

See `labelSetEllipsize`.

## getExtraMenu

labelGetExtraMenu Source #

Arguments

:: (HasCallStack, MonadIO m, IsLabel a) |
=> a | `self`: a label
-> m (Maybe MenuModel) | Returns: the menu model

Gets the extra menu model of the label.

See `labelSetExtraMenu`.

## getJustify

labelGetJustify Source #

Arguments

:: (HasCallStack, MonadIO m, IsLabel a) |
=> a | `self`: a label
-> m Justification | Returns: the justification value

Returns the justification of the label.

See `labelSetJustify`.

## getLabel

labelGetLabel Source #

Arguments

:: (HasCallStack, MonadIO m, IsLabel a) |
=> a | `self`: a label
-> m Text | Returns: the text of the label widget

Fetches the text from a label.

The returned text includes any embedded underlines indicating mnemonics and Pango markup. (See `labelGetText`).

## getLayout

labelGetLayout Source #

Arguments

:: (HasCallStack, MonadIO m, IsLabel a) |
=> a | `self`: a label
-> m Layout | Returns: the `Layout` for this label

Gets the Pango layout used to display the label.

The layout is useful to e.g. convert text positions to pixel positions, in combination with `labelGetLayoutOffsets`. The returned layout is owned by the `label` so need not be freed by the caller. The `label` is free to recreate its layout at any time, so it should be considered read-only.

## getLayoutOffsets

labelGetLayoutOffsets Source #

Arguments

:: (HasCallStack, MonadIO m, IsLabel a) |
=> a | `self`: a label
-> m (Int32, Int32) |

Obtains the coordinates where the label will draw its Pango layout.

The coordinates are useful to convert mouse events into coordinates inside the `Layout`, e.g. to take some action if some part of the label is clicked. Remember when using the `Layout` functions you need to convert to and from pixels using `PANGO_PIXELS()` or [const`pango`.SCALE].

## getLines

labelGetLines Source #

Arguments

:: (HasCallStack, MonadIO m, IsLabel a) |
=> a | `self`: a label
-> m Int32 | Returns: the number of lines

Gets the number of lines to which an ellipsized, wrapping label should be limited.

See `labelSetLines`.

## getMaxWidthChars

labelGetMaxWidthChars Source #

Arguments

:: (HasCallStack, MonadIO m, IsLabel a) |
=> a | `self`: a label
-> m Int32 | Returns: the maximum width of the label, in characters

Retrieves the maximum width of the label in characters.

See `labelSetWidthChars`.

## getMnemonicKeyval

labelGetMnemonicKeyval Source #

Arguments

:: (HasCallStack, MonadIO m, IsLabel a) |
=> a | `self`: a label
-> m Word32 | Returns: GDK keyval usable for accelerators, or `GDK_KEY_VoidSymbol`

Return the mnemonic accelerator.

If the label has been set so that it has a mnemonic key this function returns the keyval used for the mnemonic accelerator. If there is no mnemonic set up it returns `GDK_KEY_VoidSymbol`.

## getMnemonicWidget

labelGetMnemonicWidget Source #

Arguments

:: (HasCallStack, MonadIO m, IsLabel a) |
=> a | `self`: a label
-> m (Maybe Widget) | Returns: the target of the label’s mnemonic, or `NULL` if none has been set and the default algorithm will be used.

Retrieves the mnemonic target of this label.

See `labelSetMnemonicWidget`.

## getNaturalWrapMode

labelGetNaturalWrapMode Source #

Arguments

:: (HasCallStack, MonadIO m, IsLabel a) |
=> a | `self`: a label
-> m NaturalWrapMode | Returns: the natural line wrap mode

Returns natural line wrap mode used by the label.

See `labelSetNaturalWrapMode`.

Since: 4.6

## getSelectable

labelGetSelectable Source #

Arguments

:: (HasCallStack, MonadIO m, IsLabel a) |
=> a | `self`: a label
-> m Bool | Returns: true if the user can copy text from the label

Returns whether the label is selectable.

## getSelectionBounds

labelGetSelectionBounds Source #

Arguments

:: (HasCallStack, MonadIO m, IsLabel a) |
=> a | `self`: a label
-> m (Bool, Int32, Int32) | Returns: true if selection is non-empty

Gets the selected range of characters in the label.

The returned `start` and `end` positions are in characters.

## getSingleLineMode

labelGetSingleLineMode Source #

Arguments

:: (HasCallStack, MonadIO m, IsLabel a) |
=> a | `self`: a label
-> m Bool | Returns: true if the label is in single line mode

Returns whether the label is in single line mode.

## getTabs

labelGetTabs Source #

Arguments

:: (HasCallStack, MonadIO m, IsLabel a) |
=> a | `self`: a label
-> m (Maybe TabArray) | Returns: copy of default tab array, or `NULL` if standard tabs are used

Gets the tab stops for the label.

The returned array will be `NULL` if “standard” (8-space) tabs are used.

Since: 4.8

## getText

labelGetText Source #

Arguments

:: (HasCallStack, MonadIO m, IsLabel a) |
=> a | `self`: a label
-> m Text | Returns: the text in the label widget

Gets the text of the label.

The returned text is as it appears on screen. This does not include any embedded underlines indicating mnemonics or Pango markup. (See `labelGetLabel`)

## getUseMarkup

labelGetUseMarkup Source #

Arguments

:: (HasCallStack, MonadIO m, IsLabel a) |
=> a | `self`: a label
-> m Bool | Returns: true if the label’s text will be parsed for markup

Returns whether the label’s text is interpreted as Pango markup.

See `labelSetUseMarkup`.

## getUseUnderline

labelGetUseUnderline Source #

Arguments

:: (HasCallStack, MonadIO m, IsLabel a) |
=> a | `self`: a label
-> m Bool | Returns: true if underlines in the label indicate mnemonics

Returns whether underlines in the label indicate mnemonics.

See `labelSetUseUnderline`.

## getWidthChars

labelGetWidthChars Source #

Arguments

:: (HasCallStack, MonadIO m, IsLabel a) |
=> a | `self`: a label
-> m Int32 | Returns: the desired width of the label, in characters

Retrieves the desired width of the label in characters.

See `labelSetWidthChars`.

## getWrap

labelGetWrap Source #

Arguments

:: (HasCallStack, MonadIO m, IsLabel a) |
=> a | `self`: a label
-> m Bool | Returns: true if the lines of the label are automatically wrapped

Returns whether lines in the label are automatically wrapped.

See `labelSetWrap`.

## getWrapMode

labelGetWrapMode Source #

Arguments

:: (HasCallStack, MonadIO m, IsLabel a) |
=> a | `self`: a label
-> m WrapMode | Returns: the line wrap mode

Returns line wrap mode used by the label.

See `labelSetWrapMode`.

## getXalign

labelGetXalign Source #

Arguments

:: (HasCallStack, MonadIO m, IsLabel a) |
=> a | `self`: a label
-> m Float | Returns: the xalign value

Gets the `xalign` of the label.

See the Label:xalign property.

## getYalign

labelGetYalign Source #

Arguments

:: (HasCallStack, MonadIO m, IsLabel a) |
=> a | `self`: a label
-> m Float | Returns: the yalign value

Gets the `yalign` of the label.

See the Label:yalign property.

## new

labelNew Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Maybe Text | `str`: the text of the label
-> m Label | Returns: the new label

Creates a new label with the given text inside it.

You can pass `NULL` to get an empty label widget.

## newWithMnemonic

labelNewWithMnemonic Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Maybe Text | `str`: the text of the label, with an underscore in front of the mnemonic character
-> m Label | Returns: the new label

Creates a new label with the given text inside it, and a mnemonic.

If characters in `str` 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. The mnemonic key can be used to activate another widget, chosen automatically, or explicitly using `labelSetMnemonicWidget`.

If `labelSetMnemonicWidget` is not called, then the first activatable ancestor of the label will be chosen as the mnemonic widget. For instance, if the label is inside a button or menu item, the button or menu item will automatically become the mnemonic widget and be activated by the mnemonic.

## selectRegion

labelSelectRegion Source #

Arguments

:: (HasCallStack, MonadIO m, IsLabel a) |
=> a | `self`: a label
-> Int32 | `startOffset`: start offset, in characters
-> Int32 | `endOffset`: end offset, in characters
-> m () |

Selects a range of characters in the label, if the label is selectable.

See `labelSetSelectable`. If the label is not selectable, this function has no effect. If `startOffset` or `endOffset` are -1, then the end of the label will be substituted.

## setAttributes

labelSetAttributes Source #

Arguments

:: (HasCallStack, MonadIO m, IsLabel a) |
=> a | `self`: a label
-> Maybe AttrList | `attrs`: a list of style attributes
-> m () |

Apply attributes to the label text.

The attributes set with this function will be applied and merged with any other attributes previously effected by way of the Label:useUnderline or Label:useMarkup properties

While it is not recommended to mix markup strings with manually set attributes, if you must; know that the attributes will be applied to the label after the markup string is parsed.

## setEllipsize

labelSetEllipsize Source #

Arguments

:: (HasCallStack, MonadIO m, IsLabel a) |
=> a | `self`: a label
-> EllipsizeMode | `mode`: the ellipsization mode
-> m () |

Sets the mode used to ellipsize the text.

The text will be ellipsized if there is not enough space to render the entire string.

## setExtraMenu

labelSetExtraMenu Source #

Arguments

:: (HasCallStack, MonadIO m, IsLabel a, IsMenuModel b) |
=> a | `self`: a label
-> Maybe b | `model`: a menu model
-> m () |

Sets a menu model to add to the context menu of the label.

## setJustify

labelSetJustify Source #

Arguments

:: (HasCallStack, MonadIO m, IsLabel a) |
=> a | `self`: a label
-> Justification | `jtype`: the new justification
-> m () |

Sets the alignment of lines in the label relative to each other.

This function has no effect on labels containing only a single line.

`JustificationLeft` is the default value when the widget is first created with `labelNew`.

If you instead want to set the alignment of the label as a whole, use `widgetSetHalign` instead.

## setLabel

labelSetLabel Source #

Arguments

:: (HasCallStack, MonadIO m, IsLabel a) |
=> a | `self`: a label
-> Text | `str`: the new text to set for the label
-> m () |

Sets the text of the label.

The label is interpreted as including embedded underlines and/or Pango markup depending on the values of the Label:useUnderline and Label:useMarkup properties.

## setLines

labelSetLines Source #

Arguments

:: (HasCallStack, MonadIO m, IsLabel a) |
=> a | `self`: a label
-> Int32 | `lines`: the desired number of lines, or -1
-> m () |

Sets the number of lines to which an ellipsized, wrapping label should be limited.

This has no effect if the label is not wrapping or ellipsized. Set this to -1 if you don’t want to limit the number of lines.

## setMarkup

labelSetMarkup Source #

Arguments

:: (HasCallStack, MonadIO m, IsLabel a) |
=> a | `self`: a label
-> Text | `str`: the markup string
-> m () |

Sets the labels text and attributes from markup.

The string must be marked up with Pango markup (see `parseMarkup`).

If `str` is external data, you may need to escape it with `markupEscapeText` or `GLib.markup_printf_escaped`:

### c code

    GtkWidget *self = gtk_label_new (NULL);
    const char *str = "...";
    const char *format = "<span style=\"italic\">\%s</span>";
    char *markup;

    markup = g_markup_printf_escaped (format, str);
    gtk_label_set_markup (GTK_LABEL (self), markup);
    g_free (markup);

This function sets the Label:useMarkup property to true.

Also see `labelSetText`.

## setMarkupWithMnemonic

labelSetMarkupWithMnemonic Source #

Arguments

:: (HasCallStack, MonadIO m, IsLabel a) |
=> a | `self`: a label
-> Text | `str`: the markup string
-> m () |

Sets the labels text, attributes and mnemonic from markup.

Parses `str` which is marked up with Pango markup (see `parseMarkup`), setting the label’s text and attribute list based on the parse results. If characters in `str` are preceded by an underscore, they are underlined indicating that they represent a keyboard accelerator called a mnemonic.

The mnemonic key can be used to activate another widget, chosen automatically, or explicitly using `labelSetMnemonicWidget`.

## setMaxWidthChars

labelSetMaxWidthChars Source #

Arguments

:: (HasCallStack, MonadIO m, IsLabel a) |
=> a | `self`: a label
-> Int32 | `nChars`: the new maximum width, in characters.
-> m () |

Sets the maximum width of the label in characters.

## setMnemonicWidget

labelSetMnemonicWidget Source #

Arguments

:: (HasCallStack, MonadIO m, IsLabel a, IsWidget b) |
=> a | `self`: a label
-> Maybe b | `widget`: the target widget
-> m () |

Associate the label with its mnemonic target.

If the label has been set so that it has a mnemonic key (using i.e. `labelSetMarkupWithMnemonic`, `labelSetTextWithMnemonic`, `labelNewWithMnemonic` or the [property`gtk`.Label:use_underline] property) the label can be associated with a widget that is the target of the mnemonic. When the label is inside a widget (like a `Button` or a `Notebook` tab) it is automatically associated with the correct widget, but sometimes (i.e. when the target is a `Entry` next to the label) you need to set it explicitly using this function.

The target widget will be accelerated by emitting the Widget::mnemonicActivate signal on it. The default handler for this signal will activate the widget if there are no mnemonic collisions and toggle focus between the colliding widgets otherwise.

## setNaturalWrapMode

labelSetNaturalWrapMode Source #

Arguments

:: (HasCallStack, MonadIO m, IsLabel a) |
=> a | `self`: a label
-> NaturalWrapMode | `wrapMode`: the line wrapping mode
-> m () |

Selects the line wrapping for the natural size request.

This only affects the natural size requested, for the actual wrapping used, see the Label:wrapMode property.

Since: 4.6

## setSelectable

labelSetSelectable Source #

Arguments

:: (HasCallStack, MonadIO m, IsLabel a) |
=> a | `self`: a label
-> Bool | `setting`: true to allow selecting text in the label
-> m () |

Makes text in the label selectable.

Selectable labels allow the user to select text from the label, for copy-and-paste.

## setSingleLineMode

labelSetSingleLineMode Source #

Arguments

:: (HasCallStack, MonadIO m, IsLabel a) |
=> a | `self`: a label
-> Bool | `singleLineMode`: true to enable single line mode
-> m () |

Sets whether the label is in single line mode.

## setTabs

labelSetTabs Source #

Arguments

:: (HasCallStack, MonadIO m, IsLabel a) |
=> a | `self`: a label
-> Maybe TabArray | `tabs`: tab stops
-> m () |

Sets tab stops for the label.

Since: 4.8

## setText

labelSetText Source #

Arguments

:: (HasCallStack, MonadIO m, IsLabel a) |
=> a | `self`: a label
-> Text | `str`: the text to show in `self`
-> m () |

Sets the text for the label.

It overwrites any text that was there before and clears any previously set mnemonic accelerators, and sets the Label:useUnderline and Label:useMarkup properties to false.

Also see `labelSetMarkup`.

## setTextWithMnemonic

labelSetTextWithMnemonic Source #

Arguments

:: (HasCallStack, MonadIO m, IsLabel a) |
=> a | `self`: a label
-> Text | `str`: the text
-> m () |

Sets the text for the label, with mnemonics.

If characters in `str` are preceded by an underscore, they are underlined indicating that they represent a keyboard accelerator called a mnemonic. The mnemonic key can be used to activate another widget, chosen automatically, or explicitly using `labelSetMnemonicWidget`.

## setUseMarkup

labelSetUseMarkup Source #

Arguments

:: (HasCallStack, MonadIO m, IsLabel a) |
=> a | `self`: a label
-> Bool | `setting`: true if the label’s text should be parsed for markup.
-> m () |

Sets whether the text of the label contains markup.

See `labelSetMarkup`.

## setUseUnderline

labelSetUseUnderline Source #

Arguments

:: (HasCallStack, MonadIO m, IsLabel a) |
=> a | `self`: a label
-> Bool | `setting`: true if underlines in the text indicate mnemonics
-> m () |

Sets whether underlines in the text indicate mnemonics.

## setWidthChars

labelSetWidthChars Source #

Arguments

:: (HasCallStack, MonadIO m, IsLabel a) |
=> a | `self`: a label
-> Int32 | `nChars`: the new desired width, in characters.
-> m () |

Sets the desired width in characters of the label.

## setWrap

labelSetWrap Source #

Arguments

:: (HasCallStack, MonadIO m, IsLabel a) |
=> a | `self`: a label
-> Bool | `wrap`: whether to wrap lines
-> m () |

Toggles line wrapping within the label.

True makes it break lines if text exceeds the widget’s size. false lets the text get cut off by the edge of the widget if it exceeds the widget size.

Note that setting line wrapping to true does not make the label wrap at its parent widget’s width, because GTK widgets conceptually can’t make their requisition depend on the parent widget’s size. For a label that wraps at a specific position, set the label’s width using `widgetSetSizeRequest`.

## setWrapMode

labelSetWrapMode Source #

Arguments

:: (HasCallStack, MonadIO m, IsLabel a) |
=> a | `self`: a label
-> WrapMode | `wrapMode`: the line wrapping mode
-> m () |

Controls how line wrapping is done.

This only affects the label if line wrapping is on. (See `labelSetWrap`)

The default is `WrapModeWord`, which means wrap on word boundaries.

For sizing behavior, also consider the Label:naturalWrapMode property.

## setXalign

labelSetXalign Source #

Arguments

:: (HasCallStack, MonadIO m, IsLabel a) |
=> a | `self`: a label
-> Float | `xalign`: the new xalign value, between 0 and 1
-> m () |

Sets the `xalign` of the label.

See the Label:xalign property.

## setYalign

labelSetYalign Source #

Arguments

:: (HasCallStack, MonadIO m, IsLabel a) |
=> a | `self`: a label
-> Float | `yalign`: the new yalign value, between 0 and 1
-> m () |

Sets the `yalign` of the label.

See the Label:yalign property.

# Properties

## attributes

A list of style attributes to apply to the text of the label.

clearLabelAttributes :: (MonadIO m, IsLabel o) => o -> m () Source #

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

    clear #attributes

constructLabelAttributes :: (IsLabel o, MonadIO m) => AttrList -> m (GValueConstruct o) Source #

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

getLabelAttributes :: (MonadIO m, IsLabel o) => o -> m (Maybe AttrList) Source #

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

    get label #attributes

setLabelAttributes :: (MonadIO m, IsLabel o) => o -> AttrList -> m () Source #

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

    set label [ #attributes := value ]

## ellipsize

The preferred place to ellipsize the string, if the label does not have enough room to display the entire string.

Note that setting this property to a value other than [enum.Pango.EllipsizeMode.none] has the side-effect that the label requests only enough space to display the ellipsis "...". In particular, this means that ellipsizing labels do not work well in notebook tabs, unless the NotebookPage:tabExpand child property is set to true.

Other ways to set a label's width are `widgetSetSizeRequest` and `labelSetWidthChars`.

constructLabelEllipsize :: (IsLabel o, MonadIO m) => EllipsizeMode -> m (GValueConstruct o) Source #

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

getLabelEllipsize :: (MonadIO m, IsLabel o) => o -> m EllipsizeMode Source #

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

    get label #ellipsize

setLabelEllipsize :: (MonadIO m, IsLabel o) => o -> EllipsizeMode -> m () Source #

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

    set label [ #ellipsize := value ]

## extraMenu

A menu model whose contents will be appended to the context menu.

clearLabelExtraMenu :: (MonadIO m, IsLabel o) => o -> m () Source #

Set the value of the “`extra-menu`” property to `Nothing`. When overloading is enabled, this is equivalent to

    clear #extraMenu

constructLabelExtraMenu :: (IsLabel o, MonadIO m, IsMenuModel a) => a -> m (GValueConstruct o) Source #

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

getLabelExtraMenu :: (MonadIO m, IsLabel o) => o -> m (Maybe MenuModel) Source #

Get the value of the “`extra-menu`” property. When overloading is enabled, this is equivalent to

    get label #extraMenu

setLabelExtraMenu :: (MonadIO m, IsLabel o, IsMenuModel a) => o -> a -> m () Source #

Set the value of the “`extra-menu`” property. When overloading is enabled, this is equivalent to

    set label [ #extraMenu := value ]

## justify

The alignment of the lines in the text of the label, relative to each other.

This does *not* affect the alignment of the label within its allocation. See Label:xalign for that.

constructLabelJustify :: (IsLabel o, MonadIO m) => Justification -> m (GValueConstruct o) Source #

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

getLabelJustify :: (MonadIO m, IsLabel o) => o -> m Justification Source #

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

    get label #justify

setLabelJustify :: (MonadIO m, IsLabel o) => o -> Justification -> m () Source #

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

    set label [ #justify := value ]

## label

The contents of the label.

If the string contains Pango markup (see `parseMarkup`), you will have to set the Label:useMarkup property to true in order for the label to display the markup attributes. See also `labelSetMarkup` for a convenience function that sets both this property and the Label:useMarkup property at the same time.

If the string contains underlines acting as mnemonics, you will have to set the Label:useUnderline property to true in order for the label to display them.

constructLabelLabel :: (IsLabel 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`.

getLabelLabel :: (MonadIO m, IsLabel o) => o -> m Text Source #

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

    get label #label

setLabelLabel :: (MonadIO m, IsLabel o) => o -> Text -> m () Source #

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

    set label [ #label := value ]

## lines

The number of lines to which an ellipsized, wrapping label should display before it gets ellipsized. This both prevents the label from ellipsizing before this many lines are displayed, and limits the height request of the label to this many lines.

::: warning Setting this property has unintuitive and unfortunate consequences for the minimum _width_ of the label. Specifically, if the height of the label is such that it fits a smaller number of lines than the value of this property, the label can not be ellipsized at all, which means it must be wide enough to fit all the text fully.

This property has no effect if the label is not wrapping or ellipsized.

Set this property to -1 if you don't want to limit the number of lines.

constructLabelLines :: (IsLabel o, MonadIO m) => Int32 -> m (GValueConstruct o) Source #

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

getLabelLines :: (MonadIO m, IsLabel o) => o -> m Int32 Source #

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

    get label #lines

setLabelLines :: (MonadIO m, IsLabel o) => o -> Int32 -> m () Source #

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

    set label [ #lines := value ]

## maxWidthChars

The desired maximum width of the label, in characters.

If this property is set to -1, the width will be calculated automatically.

See the section on text layout for details of how Label:widthChars and Label:maxWidthChars determine the width of ellipsized and wrapped labels.

constructLabelMaxWidthChars :: (IsLabel o, MonadIO m) => Int32 -> m (GValueConstruct o) Source #

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

getLabelMaxWidthChars :: (MonadIO m, IsLabel o) => o -> m Int32 Source #

Get the value of the “`max-width-chars`” property. When overloading is enabled, this is equivalent to

    get label #maxWidthChars

setLabelMaxWidthChars :: (MonadIO m, IsLabel o) => o -> Int32 -> m () Source #

Set the value of the “`max-width-chars`” property. When overloading is enabled, this is equivalent to

    set label [ #maxWidthChars := value ]

## mnemonicKeyval

The mnemonic accelerator key for the label.

getLabelMnemonicKeyval :: (MonadIO m, IsLabel o) => o -> m Word32 Source #

Get the value of the “`mnemonic-keyval`” property. When overloading is enabled, this is equivalent to

    get label #mnemonicKeyval

## mnemonicWidget

The widget to be activated when the labels mnemonic key is pressed.

clearLabelMnemonicWidget :: (MonadIO m, IsLabel o) => o -> m () Source #

Set the value of the “`mnemonic-widget`” property to `Nothing`. When overloading is enabled, this is equivalent to

    clear #mnemonicWidget

constructLabelMnemonicWidget :: (IsLabel o, MonadIO m, IsWidget a) => a -> m (GValueConstruct o) Source #

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

getLabelMnemonicWidget :: (MonadIO m, IsLabel o) => o -> m (Maybe Widget) Source #

Get the value of the “`mnemonic-widget`” property. When overloading is enabled, this is equivalent to

    get label #mnemonicWidget

setLabelMnemonicWidget :: (MonadIO m, IsLabel o, IsWidget a) => o -> a -> m () Source #

Set the value of the “`mnemonic-widget`” property. When overloading is enabled, this is equivalent to

    set label [ #mnemonicWidget := value ]

## naturalWrapMode

Select the line wrapping for the natural size request.

This only affects the natural size requested. For the actual wrapping used, see the Label:wrapMode property.

The default is `NaturalWrapModeInherit`, which inherits the behavior of the Label:wrapMode property.

Since: 4.6

constructLabelNaturalWrapMode :: (IsLabel o, MonadIO m) => NaturalWrapMode -> m (GValueConstruct o) Source #

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

getLabelNaturalWrapMode :: (MonadIO m, IsLabel o) => o -> m NaturalWrapMode Source #

Get the value of the “`natural-wrap-mode`” property. When overloading is enabled, this is equivalent to

    get label #naturalWrapMode

setLabelNaturalWrapMode :: (MonadIO m, IsLabel o) => o -> NaturalWrapMode -> m () Source #

Set the value of the “`natural-wrap-mode`” property. When overloading is enabled, this is equivalent to

    set label [ #naturalWrapMode := value ]

## selectable

Whether the label text can be selected with the mouse.

constructLabelSelectable :: (IsLabel o, MonadIO m) => Bool -> m (GValueConstruct o) Source #

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

getLabelSelectable :: (MonadIO m, IsLabel o) => o -> m Bool Source #

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

    get label #selectable

setLabelSelectable :: (MonadIO m, IsLabel o) => o -> Bool -> m () Source #

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

    set label [ #selectable := value ]

## singleLineMode

Whether the label is in single line mode.

In single line mode, the height of the label does not depend on the actual text, it is always set to ascent + descent of the font. This can be an advantage in situations where resizing the label because of text changes would be distracting, e.g. in a statusbar.

constructLabelSingleLineMode :: (IsLabel o, MonadIO m) => Bool -> m (GValueConstruct o) Source #

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

getLabelSingleLineMode :: (MonadIO m, IsLabel o) => o -> m Bool Source #

Get the value of the “`single-line-mode`” property. When overloading is enabled, this is equivalent to

    get label #singleLineMode

setLabelSingleLineMode :: (MonadIO m, IsLabel o) => o -> Bool -> m () Source #

Set the value of the “`single-line-mode`” property. When overloading is enabled, this is equivalent to

    set label [ #singleLineMode := value ]

## tabs

Custom tabs for this label.

Since: 4.8

clearLabelTabs :: (MonadIO m, IsLabel o) => o -> m () Source #

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

    clear #tabs

constructLabelTabs :: (IsLabel o, MonadIO m) => TabArray -> m (GValueConstruct o) Source #

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

getLabelTabs :: (MonadIO m, IsLabel o) => o -> m (Maybe TabArray) Source #

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

    get label #tabs

setLabelTabs :: (MonadIO m, IsLabel o) => o -> TabArray -> m () Source #

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

    set label [ #tabs := value ]

## useMarkup

True if the text of the label includes Pango markup.

See `parseMarkup`.

constructLabelUseMarkup :: (IsLabel o, MonadIO m) => Bool -> m (GValueConstruct o) Source #

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

getLabelUseMarkup :: (MonadIO m, IsLabel o) => o -> m Bool Source #

Get the value of the “`use-markup`” property. When overloading is enabled, this is equivalent to

    get label #useMarkup

setLabelUseMarkup :: (MonadIO m, IsLabel o) => o -> Bool -> m () Source #

Set the value of the “`use-markup`” property. When overloading is enabled, this is equivalent to

    set label [ #useMarkup := value ]

## useUnderline

True if the text of the label indicates a mnemonic with an `_` before the mnemonic character.

constructLabelUseUnderline :: (IsLabel 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`.

getLabelUseUnderline :: (MonadIO m, IsLabel o) => o -> m Bool Source #

Get the value of the “`use-underline`” property. When overloading is enabled, this is equivalent to

    get label #useUnderline

setLabelUseUnderline :: (MonadIO m, IsLabel o) => o -> Bool -> m () Source #

Set the value of the “`use-underline`” property. When overloading is enabled, this is equivalent to

    set label [ #useUnderline := value ]

## widthChars

The desired width of the label, in characters.

If this property is set to -1, the width will be calculated automatically.

See the section on text layout for details of how Label:widthChars and Label:maxWidthChars determine the width of ellipsized and wrapped labels.

constructLabelWidthChars :: (IsLabel o, MonadIO m) => Int32 -> m (GValueConstruct o) Source #

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

getLabelWidthChars :: (MonadIO m, IsLabel o) => o -> m Int32 Source #

Get the value of the “`width-chars`” property. When overloading is enabled, this is equivalent to

    get label #widthChars

setLabelWidthChars :: (MonadIO m, IsLabel o) => o -> Int32 -> m () Source #

Set the value of the “`width-chars`” property. When overloading is enabled, this is equivalent to

    set label [ #widthChars := value ]

## wrap

True if the label text will wrap if it gets too wide.

constructLabelWrap :: (IsLabel o, MonadIO m) => Bool -> m (GValueConstruct o) Source #

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

getLabelWrap :: (MonadIO m, IsLabel o) => o -> m Bool Source #

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

    get label #wrap

setLabelWrap :: (MonadIO m, IsLabel o) => o -> Bool -> m () Source #

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

    set label [ #wrap := value ]

## wrapMode

Controls how the line wrapping is done.

This only affects the formatting if line wrapping is on (see the Label:wrap property). The default is `WrapModeWord`, which means wrap on word boundaries.

For sizing behavior, also consider the Label:naturalWrapMode property.

constructLabelWrapMode :: (IsLabel o, MonadIO m) => WrapMode -> m (GValueConstruct o) Source #

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

getLabelWrapMode :: (MonadIO m, IsLabel o) => o -> m WrapMode Source #

Get the value of the “`wrap-mode`” property. When overloading is enabled, this is equivalent to

    get label #wrapMode

setLabelWrapMode :: (MonadIO m, IsLabel o) => o -> WrapMode -> m () Source #

Set the value of the “`wrap-mode`” property. When overloading is enabled, this is equivalent to

    set label [ #wrapMode := value ]

## xalign

The horizontal alignment of the label text inside its size allocation.

Compare this to Widget:halign, which determines how the labels size allocation is positioned in the space available for the label.

constructLabelXalign :: (IsLabel o, MonadIO m) => Float -> m (GValueConstruct o) Source #

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

getLabelXalign :: (MonadIO m, IsLabel o) => o -> m Float Source #

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

    get label #xalign

setLabelXalign :: (MonadIO m, IsLabel o) => o -> Float -> m () Source #

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

    set label [ #xalign := value ]

## yalign

The vertical alignment of the label text inside its size allocation.

Compare this to Widget:valign, which determines how the labels size allocation is positioned in the space available for the label.

constructLabelYalign :: (IsLabel o, MonadIO m) => Float -> m (GValueConstruct o) Source #

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

getLabelYalign :: (MonadIO m, IsLabel o) => o -> m Float Source #

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

    get label #yalign

setLabelYalign :: (MonadIO m, IsLabel o) => o -> Float -> m () Source #

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

    set label [ #yalign := value ]

# Signals

## activateCurrentLink

type LabelActivateCurrentLinkCallback = IO () Source #

Gets emitted when the user activates a link in the label.

The `::activate-current-link` is a keybinding signal.

Applications may also emit the signal with `g_signal_emit_by_name()` if they need to control activation of URIs programmatically.

The default bindings for this signal are all forms of the <kbd>Enter</kbd> key.

afterLabelActivateCurrentLink :: (IsLabel a, MonadIO m) => a -> ((?self :: a) => LabelActivateCurrentLinkCallback) -> m SignalHandlerId Source #

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

    after label #activateCurrentLink 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.

onLabelActivateCurrentLink :: (IsLabel a, MonadIO m) => a -> ((?self :: a) => LabelActivateCurrentLinkCallback) -> m SignalHandlerId Source #

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

    on label #activateCurrentLink callback

## activateLink

type LabelActivateLinkCallback Source #

Arguments

= Text | `uri`: the URI that is activated
-> IO Bool | Returns: true if the link has been activated

Gets emitted to activate a URI.

Applications may connect to it to override the default behaviour, which is to call `fileLauncherLaunch`.

afterLabelActivateLink :: (IsLabel a, MonadIO m) => a -> ((?self :: a) => LabelActivateLinkCallback) -> m SignalHandlerId Source #

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

    after label #activateLink 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.

onLabelActivateLink :: (IsLabel a, MonadIO m) => a -> ((?self :: a) => LabelActivateLinkCallback) -> m SignalHandlerId Source #

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

    on label #activateLink callback

## copyClipboard

type LabelCopyClipboardCallback = IO () Source #

Gets emitted to copy the selection to the clipboard.

The `::copy-clipboard` signal is a keybinding signal.

The default binding for this signal is <kbd>Ctrl</kbd>+<kbd>c</kbd>.

afterLabelCopyClipboard :: (IsLabel a, MonadIO m) => a -> ((?self :: a) => LabelCopyClipboardCallback) -> m SignalHandlerId Source #

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

    after label #copyClipboard 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.

onLabelCopyClipboard :: (IsLabel a, MonadIO m) => a -> ((?self :: a) => LabelCopyClipboardCallback) -> m SignalHandlerId Source #

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

    on label #copyClipboard callback

## moveCursor

type LabelMoveCursorCallback Source #

Arguments

= MovementStep | `step`: the granularity of the move, as a `GtkMovementStep`
-> Int32 | `count`: the number of `step` units to move
-> Bool | `extendSelection`: true if the move should extend the selection
-> IO () |

Gets emitted when the user initiates a cursor movement.

The `::move-cursor` signal is a keybinding signal. If the cursor is not visible in `entry`, this signal causes the viewport to be moved instead.

Applications should not connect to it, but may emit it with `GObject.signal_emit_by_name` if they need to control the cursor programmatically.

The default bindings for this signal come in two variants, the variant with the <kbd>Shift</kbd> modifier extends the selection, the variant without the <kbd>Shift</kbd> modifier does not. There are too many key combinations to list them all here.

- <kbd>←</kbd>, <kbd>→</kbd>, <kbd>↑</kbd>, <kbd>↓</kbd> move by individual characters/lines
- <kbd>Ctrl</kbd>+<kbd>←</kbd>, etc. move by words/paragraphs
- <kbd>Home</kbd> and <kbd>End</kbd> move to the ends of the buffer

afterLabelMoveCursor :: (IsLabel a, MonadIO m) => a -> ((?self :: a) => LabelMoveCursorCallback) -> m SignalHandlerId Source #

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

    after label #moveCursor 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.

onLabelMoveCursor :: (IsLabel a, MonadIO m) => a -> ((?self :: a) => LabelMoveCursorCallback) -> m SignalHandlerId Source #

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

    on label #moveCursor callback