Class: Gtk::Label

Inherits:
Widget
  • Object
show all
Defined in:
(unknown)

Overview

The GtkLabel widget displays a small amount of text.

As the name implies, most labels are used to label another widget such as a [classButton].

An example GtkLabel

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 [structPango.Attribute] values for this label.

An example of a UI definition fragment specifying Pango attributes:

<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 %GTK_ACCESSIBLE_ROLE_LABEL 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 [ctorGtk.Label.new_with_mnemonic] or [methodGtk.Label.set_text_with_mnemonic].

Mnemonics automatically activate any activatable widget the label is inside, such as a [classGtk.Button]; if the label is not inside the mnemonic’s target widget, you have to tell the label about the target using [methodGtk.Label.set_mnemonic_widget].

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

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

// 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 [classGtk.Entry], you have to point the label at the entry with [methodGtk.Label.set_mnemonic_widget]:

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

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, [funcPango.parse_markup])

The markup passed to [methodGtk.Label.set_markup] must be valid; 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 [methodGtk.Label.set_markup], you’ll want to escape it with [funcGLib.markup_escape_text] or [funcGLib.markup_printf_escaped].

Markup strings are just a convenient way to set the [structPango.AttrList] on a label; [methodGtk.Label.set_attributes] may be a simpler way to set attributes in some cases. Be careful though; [structPango.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 [structPango.Attribute] requires knowledge of the exact string being displayed, so translations will cause problems.

Selectable labels

Labels can be made selectable with [methodGtk.Label.set_selectable]. 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 [methodGtk.Label.set_wrap].

[methodGtk.Label.set_justify] 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 [propertyGtk.Widget:halign] and [propertyGtk.Widget:valign] properties.

The [propertyGtk.Label:width-chars] and [propertyGtk.Label:max-width-chars] 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> 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:

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 [signalGtk.Label::activate-link] signal and the [methodGtk.Label.get_current_uri] function.

Instance Method Summary collapse

Methods inherited from Widget

#accessible_role, #accessible_role=, #action_set_enabled, #activate, #activate_action, #activate_action_variant, #activate_default, #activate_signal, #activate_signal=, #activate_signal_from_name=, #add_binding, #add_binding_action, #add_binding_signal, #add_controller, #add_css_class, #add_mnemonic_label, #add_shortcut, #add_tick_callback, #allocate, #allocated_baseline, #allocated_height, #allocated_width, #baseline, #bind_template_callback_full, #bind_template_child_full, #can_focus, #can_focus=, #can_focus?, #can_target, #can_target=, #can_target?, #child_focus, #child_visible, #child_visible=, #clipboard, #compute_bounds, #compute_expand, #compute_point, #compute_transform, #contains, #create_pango_context, #create_pango_layout, #css_classes, #css_classes=, #css_name, #css_name=, #cursor, #cursor=, #cursor_from_name=, default_direction, default_direction=, #direction, #direction=, #display, #dispose_template, #drag_check_threshold, #error_bell, #first_child, #focus_child, #focus_child=, #focus_on_click, #focus_on_click=, #focus_on_click?, #focusable, #focusable=, #focusable?, #font_map, #font_map=, #font_options, #font_options=, #frame_clock, #get_allocation, #get_ancestor, #get_color, #get_preferred_size, #get_size, #get_size_request, #get_template_child, #grab_focus, #halign, #halign=, #has_css_class, #has_default, #has_default=, #has_default?, #has_focus, #has_focus=, #has_focus?, #has_tooltip, #has_tooltip=, #has_tooltip?, #has_visible_focus, #height, #height_request, #height_request=, #hexpand, #hexpand=, #hexpand?, #hexpand_set, #hexpand_set=, #hexpand_set?, #hide, #in_destruction, #init_template, #insert_action_group, #insert_after, #insert_before, #install_action, #install_property_action, #is_ancestor, #is_drawable, #is_focus, #is_sensitive, #is_visible, #keynav_failed, #last_child, #layout_manager, #layout_manager=, #layout_manager_type, #layout_manager_type=, #list_mnemonic_labels, #map, #mapped, #margin_bottom, #margin_bottom=, #margin_end, #margin_end=, #margin_start, #margin_start=, #margin_top, #margin_top=, #measure, #mnemonic_activate, #name, #name=, #native, #next_sibling, #observe_children, #observe_controllers, #opacity, #opacity=, #overflow, #overflow=, #pango_context, #parent, #parent=, #pick, #prev_sibling, #primary_clipboard, #query_action, #queue_allocate, #queue_draw, #queue_resize, #realize, #realized, #receives_default, #receives_default=, #receives_default?, #remove_controller, #remove_css_class, #remove_mnemonic_label, #remove_tick_callback, #request_mode, #root, #root=, #scale_factor, #scale_factor=, #sensitive, #sensitive=, #sensitive?, #set_size_request, #set_state_flags, #settings, #should_layout, #show, #size_allocate, #snapshot_child, #state_flags, #style_context, #template=, #template_from_resource=, #template_scope=, #tooltip_markup, #tooltip_markup=, #tooltip_text, #tooltip_text=, #translate_coordinates, #trigger_tooltip_query, #unmap, #unparent, #unrealize, #unset_state_flags, #valign, #valign=, #vexpand, #vexpand=, #vexpand?, #vexpand_set, #vexpand_set=, #vexpand_set?, #visible, #visible=, #visible?, #width, #width_request, #width_request=

Constructor Details

#initialize(str) ⇒ Gtk::Widget

Creates a new GtkLabel, containing the text in str.

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 [methodGtk.Label.set_mnemonic_widget].

If [methodGtk.Label.set_mnemonic_widget] is not called, then the first activatable ancestor of the GtkLabel 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.

Parameters:

  • str (String)

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

Instance Method Details

#attributesPango::AttrList

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

Returns:

  • (Pango::AttrList)

    attributes

#attributes=(attributes) ⇒ Pango::AttrList

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

Parameters:

  • attributes (Pango::AttrList)

Returns:

  • (Pango::AttrList)

    attributes

  • (Pango::AttrList)

    attributes

#current_uriString

Returns the URI for the currently 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 [signalGtk.Label::activate-link] handler or for use in a [signalGtk.Widget::query-tooltip] handler.

Returns:

  • (String)

    the currently active URI

#ellipsizePango::EllipsizeMode

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 %PANGO_ELLIPSIZE_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 [propertyGtk.NotebookPage:tab-expand] child property is set to true. Other ways to set a label's width are [methodGtk.Widget.set_size_request] and [methodGtk.Label.set_width_chars].

Returns:

  • (Pango::EllipsizeMode)

    ellipsize

#ellipsize=(ellipsize) ⇒ Pango::EllipsizeMode

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 %PANGO_ELLIPSIZE_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 [propertyGtk.NotebookPage:tab-expand] child property is set to true. Other ways to set a label's width are [methodGtk.Widget.set_size_request] and [methodGtk.Label.set_width_chars].

Parameters:

  • ellipsize (Pango::EllipsizeMode)

Returns:

  • (Pango::EllipsizeMode)

    ellipsize

  • (Pango::EllipsizeMode)

    ellipsize

#extra_menuGio::MenuModel

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

Returns:

  • (Gio::MenuModel)

    extra-menu

#extra_menu=(extra_menu) ⇒ Gio::MenuModel

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

Parameters:

  • extra_menu (Gio::MenuModel)

Returns:

  • (Gio::MenuModel)

    extra-menu

  • (Gio::MenuModel)

    extra-menu

#get_layout_offsets(x, y) ⇒ nil

Obtains the coordinates where the label will draw its PangoLayout.

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

Parameters:

  • x (Integer)

    location to store X offset of layout

  • y (Integer)

    location to store Y offset of layout

Returns:

  • (nil)

#get_selection_bounds(start, end) ⇒ Boolean

Gets the selected range of characters in the label.

Parameters:

  • start (Integer)

    return location for start of selection, as a character offset

  • end (Integer)

    return location for end of selection, as a character offset

Returns:

  • (Boolean)

    true if selection is non-empty

#justifyGtk::Justification

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 [propertyGtk.Label:xalign] for that.

Returns:

#justify=(justify) ⇒ Gtk::Justification

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 [propertyGtk.Label:xalign] for that.

Parameters:

Returns:

#labelString

The contents of the label.

If the string contains Pango markup (see [funcPango.parse_markup]), you will have to set the [propertyGtk.Label:use-markup] property to true in order for the label to display the markup attributes. See also [methodGtk.Label.set_markup] for a convenience function that sets both this property and the [propertyGtk.Label:use-markup] property at the same time.

If the string contains underlines acting as mnemonics, you will have to set the [propertyGtk.Label:use-underline] property to true in order for the label to display them.

Returns:

  • (String)

    label

#label=(label) ⇒ String

The contents of the label.

If the string contains Pango markup (see [funcPango.parse_markup]), you will have to set the [propertyGtk.Label:use-markup] property to true in order for the label to display the markup attributes. See also [methodGtk.Label.set_markup] for a convenience function that sets both this property and the [propertyGtk.Label:use-markup] property at the same time.

If the string contains underlines acting as mnemonics, you will have to set the [propertyGtk.Label:use-underline] property to true in order for the label to display them.

Parameters:

  • label (String)

Returns:

  • (String)

    label

  • (String)

    label

#layoutPango::Layout

Gets the PangoLayout used to display the label.

The layout is useful to e.g. convert text positions to pixel positions, in combination with [methodGtk.Label.get_layout_offsets]. 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.

Returns:

  • (Pango::Layout)

    the [classPango.Layout] for this label

#linesInteger

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

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.

Returns:

  • (Integer)

    lines

#lines=(lines) ⇒ Integer

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

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.

Parameters:

  • lines (Integer)

Returns:

  • (Integer)

    lines

  • (Integer)

    lines

#markup=(str) ⇒ nil

Sets the labels text and attributes from markup.

The string must be marked up with Pango markup (see [funcPango.parse_markup]).

If the str is external data, you may need to escape it with g_markup_escape_text() or g_markup_printf_escaped():

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 will set the [propertyGtk.Label:use-markup] property to true as a side effect.

If you set the label contents using the [propertyGtk.Label:label] property you should also ensure that you set the [propertyGtk.Label:use-markup] property accordingly.

See also: [methodGtk.Label.set_text]

Parameters:

  • str (String)

    a markup string

Returns:

  • (nil)

#markup_with_mnemonic=(str) ⇒ nil

Sets the labels text, attributes and mnemonic from markup.

Parses str which is marked up with Pango markup (see [funcPango.parse_markup]), 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 [methodGtk.Label.set_mnemonic_widget].

Parameters:

  • str (String)

    a markup string

Returns:

  • (nil)

#max_width_charsInteger

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 [propertyGtk.Label:width-chars] and [propertyGtk.Label:max-width-chars] determine the width of ellipsized and wrapped labels.

Returns:

  • (Integer)

    max-width-chars

#max_width_chars=(max_width_chars) ⇒ Integer

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 [propertyGtk.Label:width-chars] and [propertyGtk.Label:max-width-chars] determine the width of ellipsized and wrapped labels.

Parameters:

  • max_width_chars (Integer)

Returns:

  • (Integer)

    max-width-chars

  • (Integer)

    max-width-chars

#mnemonic_keyvalInteger

The mnemonic accelerator key for the label.

Returns:

  • (Integer)

    mnemonic-keyval

#mnemonic_keyval=(mnemonic_keyval) ⇒ Integer

The mnemonic accelerator key for the label.

Parameters:

  • mnemonic_keyval (Integer)

Returns:

  • (Integer)

    mnemonic-keyval

  • (Integer)

    mnemonic-keyval

#mnemonic_widgetGtk::Widget

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

Returns:

#mnemonic_widget=(mnemonic_widget) ⇒ Gtk::Widget

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

Parameters:

Returns:

#natural_wrap_modeGtk::NaturalWrapMode

Select the line wrapping for the natural size request.

This only affects the natural size requested. For the actual wrapping used, see the [propertyGtk.Label:wrap-mode] property.

The default is %GTK_NATURAL_WRAP_INHERIT, which inherits the behavior of the [propertyGtk.Label:wrap-mode] property.

Returns:

#natural_wrap_mode=(natural_wrap_mode) ⇒ Gtk::NaturalWrapMode

Select the line wrapping for the natural size request.

This only affects the natural size requested. For the actual wrapping used, see the [propertyGtk.Label:wrap-mode] property.

The default is %GTK_NATURAL_WRAP_INHERIT, which inherits the behavior of the [propertyGtk.Label:wrap-mode] property.

Parameters:

Returns:

#select_region(start_offset, end_offset) ⇒ nil

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

See [methodGtk.Label.set_selectable]. If the label is not selectable, this function has no effect. If start_offset or end_offset are -1, then the end of the label will be substituted.

Parameters:

  • start_offset (Integer)

    start offset (in characters not bytes)

  • end_offset (Integer)

    end offset (in characters not bytes)

Returns:

  • (nil)

#selectableBoolean

Returns whether the label is selectable.

Returns:

  • (Boolean)

    true if the user can copy text from the label

#selectable=(selectable) ⇒ Boolean

Whether the label text can be selected with the mouse.

Parameters:

  • selectable (Boolean)

Returns:

  • (Boolean)

    selectable

  • (Boolean)

    selectable

#selectable?Boolean

Whether the label text can be selected with the mouse.

Returns:

  • (Boolean)

    selectable

#single_line_modeBoolean

Returns whether the label is in single line mode.

Returns:

  • (Boolean)

    true when the label is in single line mode.

#single_line_mode=(single_line_mode) ⇒ Boolean

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.

Parameters:

  • single_line_mode (Boolean)

Returns:

  • (Boolean)

    single-line-mode

  • (Boolean)

    single-line-mode

#single_line_mode?Boolean

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.

Returns:

  • (Boolean)

    single-line-mode

#tabsPango::TabArray

Custom tabs for this label.

Returns:

  • (Pango::TabArray)

    tabs

#tabs=(tabs) ⇒ Pango::TabArray

Custom tabs for this label.

Parameters:

  • tabs (Pango::TabArray)

Returns:

  • (Pango::TabArray)

    tabs

  • (Pango::TabArray)

    tabs

#textString

Fetches the text from a label.

The returned text is as it appears on screen. This does not include any embedded underlines indicating mnemonics or Pango markup. (See [methodGtk.Label.get_label])

Returns:

  • (String)

    the text in the label widget. This is the internal string used by the label, and must not be modified.

#text=(str) ⇒ nil

Sets the text within the GtkLabel widget.

It overwrites any text that was there before.

This function will clear any previously set mnemonic accelerators, and set the [propertyGtk.Label:use-underline] property to false as a side effect.

This function will set the [propertyGtk.Label:use-markup] property to false as a side effect.

See also: [methodGtk.Label.set_markup]

Parameters:

  • str (String)

    The text you want to set

Returns:

  • (nil)

#text_with_mnemonic=(str) ⇒ nil

Sets the label’s text from the string str.

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 [methodGtk.Label.set_mnemonic_widget].

Parameters:

  • str (String)

    a string

Returns:

  • (nil)

#use_markupBoolean

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

See [methodGtk.Label.set_use_markup].

Returns:

  • (Boolean)

    true if the label’s text will be parsed for markup.

#use_markup=(use_markup) ⇒ Boolean

true if the text of the label includes Pango markup.

See [funcPango.parse_markup].

Parameters:

  • use_markup (Boolean)

Returns:

  • (Boolean)

    use-markup

  • (Boolean)

    use-markup

#use_markup?Boolean

true if the text of the label includes Pango markup.

See [funcPango.parse_markup].

Returns:

  • (Boolean)

    use-markup

#use_underlineBoolean

Returns whether an embedded underlines in the label indicate mnemonics.

See [methodGtk.Label.set_use_underline].

Returns:

  • (Boolean)

    true whether an embedded underline in the label indicates the mnemonic accelerator keys.

#use_underline=(use_underline) ⇒ Boolean

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

Parameters:

  • use_underline (Boolean)

Returns:

  • (Boolean)

    use-underline

  • (Boolean)

    use-underline

#use_underline?Boolean

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

Returns:

  • (Boolean)

    use-underline

#width_charsInteger

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 [propertyGtk.Label:width-chars] and [propertyGtk.Label:max-width-chars] determine the width of ellipsized and wrapped labels.

Returns:

  • (Integer)

    width-chars

#width_chars=(width_chars) ⇒ Integer

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 [propertyGtk.Label:width-chars] and [propertyGtk.Label:max-width-chars] determine the width of ellipsized and wrapped labels.

Parameters:

  • width_chars (Integer)

Returns:

  • (Integer)

    width-chars

  • (Integer)

    width-chars

#wrapBoolean

Returns whether lines in the label are automatically wrapped.

See [methodGtk.Label.set_wrap].

Returns:

  • (Boolean)

    true if the lines of the label are automatically wrapped.

#wrap=(wrap) ⇒ Boolean

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

Parameters:

  • wrap (Boolean)

Returns:

  • (Boolean)

    wrap

  • (Boolean)

    wrap

#wrap?Boolean

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

Returns:

  • (Boolean)

    wrap

#wrap_modePango::WrapMode

Controls how the line wrapping is done.

This only affects the formatting if line wrapping is on (see the [propertyGtk.Label:wrap] property). The default is %PANGO_WRAP_WORD, which means wrap on word boundaries.

For sizing behavior, also consider the [propertyGtk.Label:natural-wrap-mode] property.

Returns:

  • (Pango::WrapMode)

    wrap-mode

#wrap_mode=(wrap_mode) ⇒ Pango::WrapMode

Controls how the line wrapping is done.

This only affects the formatting if line wrapping is on (see the [propertyGtk.Label:wrap] property). The default is %PANGO_WRAP_WORD, which means wrap on word boundaries.

For sizing behavior, also consider the [propertyGtk.Label:natural-wrap-mode] property.

Parameters:

  • wrap_mode (Pango::WrapMode)

Returns:

  • (Pango::WrapMode)

    wrap-mode

  • (Pango::WrapMode)

    wrap-mode

#xalignGtk::gfloat

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

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

Returns:

  • (Gtk::gfloat)

    xalign

#xalign=(xalign) ⇒ Gtk::gfloat

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

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

Parameters:

  • xalign (Gtk::gfloat)

Returns:

  • (Gtk::gfloat)

    xalign

  • (Gtk::gfloat)

    xalign

#yalignGtk::gfloat

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

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

Returns:

  • (Gtk::gfloat)

    yalign

#yalign=(yalign) ⇒ Gtk::gfloat

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

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

Parameters:

  • yalign (Gtk::gfloat)

Returns:

  • (Gtk::gfloat)

    yalign

  • (Gtk::gfloat)

    yalign