Struct gtk4::builders::LabelBuilder

source ·
pub struct LabelBuilder { /* private fields */ }
Expand description

A builder-pattern type to construct Label objects.

Implementations§

source§

impl LabelBuilder

source

pub fn attributes(self, attributes: &AttrList) -> Self

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

source

pub fn ellipsize(self, ellipsize: EllipsizeMode) -> Self

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::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 tab-expand child property is set to true. Other ways to set a label’s width are WidgetExt::set_size_request() and Label::set_width_chars().

source

pub fn extra_menu(self, extra_menu: &impl IsA<MenuModel>) -> Self

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

source

pub fn justify(self, justify: Justification) -> Self

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 xalign for that.

source

pub fn label(self, label: impl Into<GString>) -> Self

The contents of the label.

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

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

source

pub fn lines(self, lines: i32) -> Self

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.

source

pub fn max_width_chars(self, max_width_chars: i32) -> Self

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 width-chars and max-width-chars determine the width of ellipsized and wrapped labels.

source

pub fn mnemonic_widget(self, mnemonic_widget: &impl IsA<Widget>) -> Self

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

source

pub fn natural_wrap_mode(self, natural_wrap_mode: NaturalWrapMode) -> Self

Available on crate feature v4_6 only.

Select the line wrapping for the natural size request.

This only affects the natural size requested. For the actual wrapping used, see the wrap-mode property.

The default is NaturalWrapMode::Inherit, which inherits the behavior of the wrap-mode property.

source

pub fn selectable(self, selectable: bool) -> Self

Whether the label text can be selected with the mouse.

source

pub fn single_line_mode(self, single_line_mode: bool) -> Self

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.

source

pub fn tabs(self, tabs: &TabArray) -> Self

Available on crate feature v4_8 only.

Custom tabs for this label.

source

pub fn use_markup(self, use_markup: bool) -> Self

true if the text of the label includes Pango markup.

See parse_markup().

source

pub fn use_underline(self, use_underline: bool) -> Self

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

source

pub fn width_chars(self, width_chars: i32) -> Self

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 width-chars and max-width-chars determine the width of ellipsized and wrapped labels.

source

pub fn wrap(self, wrap: bool) -> Self

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

source

pub fn wrap_mode(self, wrap_mode: WrapMode) -> Self

Controls how the line wrapping is done.

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

For sizing behavior, also consider the natural-wrap-mode property.

source

pub fn xalign(self, xalign: f32) -> Self

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

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

source

pub fn yalign(self, yalign: f32) -> Self

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

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

source

pub fn can_focus(self, can_focus: bool) -> Self

Whether the widget or any of its descendents can accept the input focus.

This property is meant to be set by widget implementations, typically in their instance init function.

source

pub fn can_target(self, can_target: bool) -> Self

Whether the widget can receive pointer events.

source

pub fn css_classes(self, css_classes: impl Into<StrV>) -> Self

A list of css classes applied to this widget.

source

pub fn css_name(self, css_name: impl Into<GString>) -> Self

The name of this widget in the CSS tree.

This property is meant to be set by widget implementations, typically in their instance init function.

source

pub fn cursor(self, cursor: &Cursor) -> Self

The cursor used by @widget.

source

pub fn focus_on_click(self, focus_on_click: bool) -> Self

Whether the widget should grab focus when it is clicked with the mouse.

This property is only relevant for widgets that can take focus.

source

pub fn focusable(self, focusable: bool) -> Self

Whether this widget itself will accept the input focus.

source

pub fn halign(self, halign: Align) -> Self

How to distribute horizontal space if widget gets extra space.

source

pub fn has_tooltip(self, has_tooltip: bool) -> Self

Enables or disables the emission of the ::query-tooltip signal on @widget.

A value of true indicates that @widget can have a tooltip, in this case the widget will be queried using query-tooltip to determine whether it will provide a tooltip or not.

source

pub fn height_request(self, height_request: i32) -> Self

Override for height request of the widget.

If this is -1, the natural request will be used.

source

pub fn hexpand(self, hexpand: bool) -> Self

Whether to expand horizontally.

source

pub fn hexpand_set(self, hexpand_set: bool) -> Self

Whether to use the hexpand property.

source

pub fn layout_manager(self, layout_manager: &impl IsA<LayoutManager>) -> Self

The LayoutManager instance to use to compute the preferred size of the widget, and allocate its children.

This property is meant to be set by widget implementations, typically in their instance init function.

source

pub fn margin_bottom(self, margin_bottom: i32) -> Self

Margin on bottom side of widget.

This property adds margin outside of the widget’s normal size request, the margin will be added in addition to the size from WidgetExt::set_size_request() for example.

source

pub fn margin_end(self, margin_end: i32) -> Self

Margin on end of widget, horizontally.

This property supports left-to-right and right-to-left text directions.

This property adds margin outside of the widget’s normal size request, the margin will be added in addition to the size from WidgetExt::set_size_request() for example.

source

pub fn margin_start(self, margin_start: i32) -> Self

Margin on start of widget, horizontally.

This property supports left-to-right and right-to-left text directions.

This property adds margin outside of the widget’s normal size request, the margin will be added in addition to the size from WidgetExt::set_size_request() for example.

source

pub fn margin_top(self, margin_top: i32) -> Self

Margin on top side of widget.

This property adds margin outside of the widget’s normal size request, the margin will be added in addition to the size from WidgetExt::set_size_request() for example.

source

pub fn name(self, name: impl Into<GString>) -> Self

The name of the widget.

source

pub fn opacity(self, opacity: f64) -> Self

The requested opacity of the widget.

source

pub fn overflow(self, overflow: Overflow) -> Self

How content outside the widget’s content area is treated.

This property is meant to be set by widget implementations, typically in their instance init function.

source

pub fn receives_default(self, receives_default: bool) -> Self

Whether the widget will receive the default action when it is focused.

source

pub fn sensitive(self, sensitive: bool) -> Self

Whether the widget responds to input.

source

pub fn tooltip_markup(self, tooltip_markup: impl Into<GString>) -> Self

Sets the text of tooltip to be the given string, which is marked up with Pango markup.

Also see Tooltip::set_markup().

This is a convenience property which will take care of getting the tooltip shown if the given string is not None: has-tooltip will automatically be set to true and there will be taken care of query-tooltip in the default signal handler.

Note that if both tooltip-text and tooltip-markup are set, the last one wins.

source

pub fn tooltip_text(self, tooltip_text: impl Into<GString>) -> Self

Sets the text of tooltip to be the given string.

Also see Tooltip::set_text().

This is a convenience property which will take care of getting the tooltip shown if the given string is not None: has-tooltip will automatically be set to true and there will be taken care of query-tooltip in the default signal handler.

Note that if both tooltip-text and tooltip-markup are set, the last one wins.

source

pub fn valign(self, valign: Align) -> Self

How to distribute vertical space if widget gets extra space.

source

pub fn vexpand(self, vexpand: bool) -> Self

Whether to expand vertically.

source

pub fn vexpand_set(self, vexpand_set: bool) -> Self

Whether to use the vexpand property.

source

pub fn visible(self, visible: bool) -> Self

Whether the widget is visible.

source

pub fn width_request(self, width_request: i32) -> Self

Override for width request of the widget.

If this is -1, the natural request will be used.

source

pub fn accessible_role(self, accessible_role: AccessibleRole) -> Self

The accessible role of the given Accessible implementation.

The accessible role cannot be changed once set.

source

pub fn build(self) -> Label

Build the Label.

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.