Skip to main content

LabelExt

Trait LabelExt 

Source
pub trait LabelExt: IsA<Label> + 'static {
Show 82 methods // Provided methods fn angle(&self) -> f64 { ... } fn attributes(&self) -> Option<AttrList> { ... } fn current_uri(&self) -> Option<GString> { ... } fn ellipsize(&self) -> EllipsizeMode { ... } fn justify(&self) -> Justification { ... } fn label(&self) -> GString { ... } fn layout(&self) -> Option<Layout> { ... } fn layout_offsets(&self) -> (i32, i32) { ... } fn is_line_wrap(&self) -> bool { ... } fn line_wrap_mode(&self) -> WrapMode { ... } fn lines(&self) -> i32 { ... } fn max_width_chars(&self) -> i32 { ... } fn mnemonic_keyval(&self) -> u32 { ... } fn mnemonic_widget(&self) -> Option<Widget> { ... } fn is_selectable(&self) -> bool { ... } fn selection_bounds(&self) -> Option<(i32, i32)> { ... } fn is_single_line_mode(&self) -> bool { ... } fn text(&self) -> GString { ... } fn tracks_visited_links(&self) -> bool { ... } fn uses_markup(&self) -> bool { ... } fn uses_underline(&self) -> bool { ... } fn width_chars(&self) -> i32 { ... } fn xalign(&self) -> f32 { ... } fn yalign(&self) -> f32 { ... } fn select_region(&self, start_offset: i32, end_offset: i32) { ... } fn set_angle(&self, angle: f64) { ... } fn set_attributes(&self, attrs: Option<&AttrList>) { ... } fn set_ellipsize(&self, mode: EllipsizeMode) { ... } fn set_justify(&self, jtype: Justification) { ... } fn set_label(&self, str: &str) { ... } fn set_line_wrap(&self, wrap: bool) { ... } fn set_line_wrap_mode(&self, wrap_mode: WrapMode) { ... } fn set_lines(&self, lines: i32) { ... } fn set_markup(&self, str: &str) { ... } fn set_markup_with_mnemonic(&self, str: &str) { ... } fn set_max_width_chars(&self, n_chars: i32) { ... } fn set_mnemonic_widget(&self, widget: Option<&impl IsA<Widget>>) { ... } fn set_pattern(&self, pattern: &str) { ... } fn set_selectable(&self, setting: bool) { ... } fn set_single_line_mode(&self, single_line_mode: bool) { ... } fn set_text(&self, str: &str) { ... } fn set_text_with_mnemonic(&self, str: &str) { ... } fn set_track_visited_links(&self, track_links: bool) { ... } fn set_use_markup(&self, setting: bool) { ... } fn set_use_underline(&self, setting: bool) { ... } fn set_width_chars(&self, n_chars: i32) { ... } fn set_xalign(&self, xalign: f32) { ... } fn set_yalign(&self, yalign: f32) { ... } fn cursor_position(&self) -> i32 { ... } fn selection_bound(&self) -> i32 { ... } fn wraps(&self) -> bool { ... } fn set_wrap(&self, wrap: bool) { ... } fn wrap_mode(&self) -> WrapMode { ... } fn set_wrap_mode(&self, wrap_mode: WrapMode) { ... } fn connect_activate_current_link<F: Fn(&Self) + 'static>( &self, f: F, ) -> SignalHandlerId { ... } fn emit_activate_current_link(&self) { ... } fn connect_activate_link<F: Fn(&Self, &str) -> Propagation + 'static>( &self, f: F, ) -> SignalHandlerId { ... } fn connect_copy_clipboard<F: Fn(&Self) + 'static>( &self, f: F, ) -> SignalHandlerId { ... } fn emit_copy_clipboard(&self) { ... } fn connect_move_cursor<F: Fn(&Self, MovementStep, i32, bool) + 'static>( &self, f: F, ) -> SignalHandlerId { ... } fn emit_move_cursor( &self, step: MovementStep, count: i32, extend_selection: bool, ) { ... } fn connect_populate_popup<F: Fn(&Self, &Menu) + 'static>( &self, f: F, ) -> SignalHandlerId { ... } fn connect_angle_notify<F: Fn(&Self) + 'static>( &self, f: F, ) -> SignalHandlerId { ... } fn connect_attributes_notify<F: Fn(&Self) + 'static>( &self, f: F, ) -> SignalHandlerId { ... } fn connect_cursor_position_notify<F: Fn(&Self) + 'static>( &self, f: F, ) -> SignalHandlerId { ... } fn connect_ellipsize_notify<F: Fn(&Self) + 'static>( &self, f: F, ) -> SignalHandlerId { ... } fn connect_justify_notify<F: Fn(&Self) + 'static>( &self, f: F, ) -> SignalHandlerId { ... } fn connect_label_notify<F: Fn(&Self) + 'static>( &self, f: F, ) -> SignalHandlerId { ... } fn connect_lines_notify<F: Fn(&Self) + 'static>( &self, f: F, ) -> SignalHandlerId { ... } fn connect_max_width_chars_notify<F: Fn(&Self) + 'static>( &self, f: F, ) -> SignalHandlerId { ... } fn connect_mnemonic_keyval_notify<F: Fn(&Self) + 'static>( &self, f: F, ) -> SignalHandlerId { ... } fn connect_mnemonic_widget_notify<F: Fn(&Self) + 'static>( &self, f: F, ) -> SignalHandlerId { ... } fn connect_pattern_notify<F: Fn(&Self) + 'static>( &self, f: F, ) -> SignalHandlerId { ... } fn connect_selectable_notify<F: Fn(&Self) + 'static>( &self, f: F, ) -> SignalHandlerId { ... } fn connect_selection_bound_notify<F: Fn(&Self) + 'static>( &self, f: F, ) -> SignalHandlerId { ... } fn connect_single_line_mode_notify<F: Fn(&Self) + 'static>( &self, f: F, ) -> SignalHandlerId { ... } fn connect_track_visited_links_notify<F: Fn(&Self) + 'static>( &self, f: F, ) -> SignalHandlerId { ... } fn connect_use_markup_notify<F: Fn(&Self) + 'static>( &self, f: F, ) -> SignalHandlerId { ... } fn connect_use_underline_notify<F: Fn(&Self) + 'static>( &self, f: F, ) -> SignalHandlerId { ... } fn connect_width_chars_notify<F: Fn(&Self) + 'static>( &self, f: F, ) -> SignalHandlerId { ... } fn connect_wrap_notify<F: Fn(&Self) + 'static>( &self, f: F, ) -> SignalHandlerId { ... } fn connect_wrap_mode_notify<F: Fn(&Self) + 'static>( &self, f: F, ) -> SignalHandlerId { ... }
}
Expand description

Trait containing all Label methods.

§Implementors

AccelLabel, Label

Provided Methods§

Source

fn angle(&self) -> f64

Gets the angle of rotation for the label. See set_angle().

§Returns

the angle of rotation for the label

Source

fn attributes(&self) -> Option<AttrList>

Gets the attribute list that was set on the label using set_attributes(), if any. This function does not reflect attributes that come from the labels markup (see set_markup()). If you want to get the effective attributes for the label, use pango_layout_get_attribute (gtk_label_get_layout (label)).

§Returns

the attribute list, or None if none was set.

Source

fn current_uri(&self) -> Option<GString>

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 activate-link handler or for use in a query-tooltip handler.

§Returns

the currently active URI. The string is owned by GTK+ and must not be freed or modified.

Source

fn ellipsize(&self) -> EllipsizeMode

Returns the ellipsizing position of the label. See set_ellipsize().

§Returns

pango::EllipsizeMode

Source

fn justify(&self) -> Justification

Returns the justification of the label. See set_justify().

§Returns

Justification

Source

fn label(&self) -> GString

Fetches the text from a label widget including any embedded underlines indicating mnemonics and Pango markup. (See text()).

§Returns

the text of the label widget. This string is owned by the widget and must not be modified or freed.

Source

fn layout(&self) -> Option<Layout>

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 layout_offsets(). The returned layout is owned by the self so need not be freed by the caller. The self is free to recreate its layout at any time, so it should be considered read-only.

§Returns

the pango::Layout for this label

Source

fn layout_offsets(&self) -> (i32, i32)

Obtains the coordinates where the label will draw the pango::Layout representing the text in the label; useful to convert mouse events into coordinates inside the pango::Layout, e.g. to take some action if some part of the label is clicked. Of course you will need to create a EventBox to receive the events, and pack the label inside it, since labels are windowless (they return false from WidgetExt::has_window()). Remember when using the pango::Layout functions you need to convert to and from pixels using PANGO_PIXELS() or PANGO_SCALE.

§Returns
§x

location to store X offset of layout, or None

§y

location to store Y offset of layout, or None

Source

fn is_line_wrap(&self) -> bool

Returns whether lines in the label are automatically wrapped. See set_line_wrap().

§Returns

true if the lines of the label are automatically wrapped.

Source

fn line_wrap_mode(&self) -> WrapMode

Returns line wrap mode used by the label. See set_line_wrap_mode().

§Returns

true if the lines of the label are automatically wrapped.

Source

fn lines(&self) -> i32

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

§Returns

The number of lines

Source

fn max_width_chars(&self) -> i32

Retrieves the desired maximum width of self, in characters. See set_width_chars().

§Returns

the maximum width of the label in characters.

Source

fn mnemonic_keyval(&self) -> u32

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

§Returns

GDK keyval usable for accelerators, or GDK_KEY_VoidSymbol

Source

fn mnemonic_widget(&self) -> Option<Widget>

Retrieves the target of the mnemonic (keyboard shortcut) of this label. See set_mnemonic_widget().

§Returns

the target of the label’s mnemonic, or None if none has been set and the default algorithm will be used.

Source

fn is_selectable(&self) -> bool

Gets the value set by set_selectable().

§Returns

true if the user can copy text from the label

Source

fn selection_bounds(&self) -> Option<(i32, i32)>

Gets the selected range of characters in the label, returning true if there’s a selection.

§Returns

true if selection is non-empty

§start

return location for start of selection, as a character offset

§end

return location for end of selection, as a character offset

Source

fn is_single_line_mode(&self) -> bool

Returns whether the label is in single line mode.

§Returns

true when the label is in single line mode.

Source

fn text(&self) -> GString

Fetches the text from a label widget, as displayed on the screen. This does not include any embedded underlines indicating mnemonics or Pango markup. (See label())

§Returns

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

Returns whether the label is currently keeping track of clicked links.

§Returns

true if clicked links are remembered

Source

fn uses_markup(&self) -> bool

Returns whether the label’s text is interpreted as marked up with the [Pango text markup language][PangoMarkupFormat]. See gtk_label_set_use_markup ().

§Returns

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

Source

fn uses_underline(&self) -> bool

Returns whether an embedded underline in the label indicates a mnemonic. See set_use_underline().

§Returns

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

Source

fn width_chars(&self) -> i32

Retrieves the desired width of self, in characters. See set_width_chars().

§Returns

the width of the label in characters.

Source

fn xalign(&self) -> f32

Gets the xalign property for self.

§Returns

the xalign property

Source

fn yalign(&self) -> f32

Gets the yalign property for self.

§Returns

the yalign property

Source

fn select_region(&self, start_offset: i32, end_offset: i32)

Selects a range of characters in the label, if the label is selectable. See 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.

§start_offset

start offset (in characters not bytes)

§end_offset

end offset (in characters not bytes)

Source

fn set_angle(&self, angle: f64)

Sets the angle of rotation for the label. An angle of 90 reads from from bottom to top, an angle of 270, from top to bottom. The angle setting for the label is ignored if the label is selectable, wrapped, or ellipsized.

§angle

the angle that the baseline of the label makes with the horizontal, in degrees, measured counterclockwise

Source

fn set_attributes(&self, attrs: Option<&AttrList>)

Sets a pango::AttrList; the attributes in the list are applied 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 use-underline or use-markup 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.

§attrs

a pango::AttrList, or None

Source

fn set_ellipsize(&self, mode: EllipsizeMode)

Sets the mode used to ellipsize (add an ellipsis: “…”) to the text if there is not enough space to render the entire string.

§mode

a pango::EllipsizeMode

Source

fn set_justify(&self, jtype: Justification)

Sets the alignment of the lines in the text of the label relative to each other. Justification::Left is the default value when the widget is first created with Label::new(). If you instead want to set the alignment of the label as a whole, use WidgetExt::set_halign() instead. set_justify() has no effect on labels containing only a single line.

§jtype

a Justification

Source

fn set_label(&self, str: &str)

Sets the text of the label. The label is interpreted as including embedded underlines and/or Pango markup depending on the values of the use-underline and use-markup properties.

§str

the new text to set for the label

Source

fn set_line_wrap(&self, wrap: bool)

Toggles line wrapping within the Label widget. 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 container’s width, because GTK+ widgets conceptually can’t make their requisition depend on the parent container’s size. For a label that wraps at a specific position, set the label’s width using WidgetExt::set_size_request().

§wrap

the setting

Source

fn set_line_wrap_mode(&self, wrap_mode: WrapMode)

If line wrapping is on (see set_line_wrap()) this controls how the line wrapping is done. The default is pango::WrapMode::Word which means wrap on word boundaries.

§wrap_mode

the line wrapping mode

Source

fn set_lines(&self, lines: i32)

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.

§lines

the desired number of lines, or -1

Source

fn set_markup(&self, str: &str)

“; char *markup;

markup = g_markup_printf_escaped (format, str); gtk_label_set_markup (GTK_LABEL (label), markup); g_free (markup); ]|

This function will set the use-markup property to true as a side effect.

If you set the label contents using the label property you should also ensure that you set the use-markup property accordingly.

See also: set_text()

§str

a markup string (see [Pango markup format][PangoMarkupFormat])

Source

fn set_markup_with_mnemonic(&self, str: &str)

Parses str which is marked up with the [Pango text markup language][PangoMarkupFormat], 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 set_mnemonic_widget().

§str

a markup string (see [Pango markup format][PangoMarkupFormat])

Source

fn set_max_width_chars(&self, n_chars: i32)

Sets the desired maximum width in characters of self to n_chars.

§n_chars

the new desired maximum width, in characters.

Source

fn set_mnemonic_widget(&self, widget: Option<&impl IsA<Widget>>)

If the label has been set so that it has an mnemonic key (using i.e. set_markup_with_mnemonic(), set_text_with_mnemonic(), Label::with_mnemonic() or the “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 GtkWidget::mnemonic-activate 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.

§widget

the target Widget, or None to unset

Source

fn set_pattern(&self, pattern: &str)

The pattern of underlines you want under the existing text within the Label widget. For example if the current text of the label says “FooBarBaz” passing a pattern of “___ ___” will underline “Foo” and “Baz” but not “Bar”.

§pattern

The pattern as described above.

Source

fn set_selectable(&self, setting: bool)

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

§setting

true to allow selecting text in the label

Source

fn set_single_line_mode(&self, single_line_mode: bool)

Sets whether the label is in single line mode.

§single_line_mode

true if the label should be in single line mode

Source

fn set_text(&self, str: &str)

Sets the text within the Label widget. It overwrites any text that was there before.

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

This function will set the use-markup property to false as a side effect.

See also: set_markup()

§str

The text you want to set

Source

fn set_text_with_mnemonic(&self, str: &str)

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 set_mnemonic_widget().

§str

a string

Sets whether the label should keep track of clicked links (and use a different color for them).

true to track visited links

Source

fn set_use_markup(&self, setting: bool)

Sets whether the text of the label contains markup in [Pango’s text markup language][PangoMarkupFormat]. See set_markup().

§setting

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

Source

fn set_use_underline(&self, setting: bool)

If true, an underline in the text indicates the next character should be used for the mnemonic accelerator key.

§setting

true if underlines in the text indicate mnemonics

Source

fn set_width_chars(&self, n_chars: i32)

Sets the desired width in characters of self to n_chars.

§n_chars

the new desired width, in characters.

Source

fn set_xalign(&self, xalign: f32)

Sets the xalign property for self.

§xalign

the new xalign value, between 0 and 1

Source

fn set_yalign(&self, yalign: f32)

Sets the yalign property for self.

§yalign

the new yalign value, between 0 and 1

Source

fn cursor_position(&self) -> i32

Source

fn selection_bound(&self) -> i32

Source

fn wraps(&self) -> bool

Source

fn set_wrap(&self, wrap: bool)

Source

fn wrap_mode(&self) -> WrapMode

If line wrapping is on (see the wrap property) this controls how the line wrapping is done. The default is pango::WrapMode::Word, which means wrap on word boundaries.

Source

fn set_wrap_mode(&self, wrap_mode: WrapMode)

If line wrapping is on (see the wrap property) this controls how the line wrapping is done. The default is pango::WrapMode::Word, which means wrap on word boundaries.

A [keybinding signal][GtkBindingSignal] which gets emitted when the user activates a link in the label.

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 Enter key.

The signal which gets emitted to activate a URI. Applications may connect to it to override the default behaviour, which is to call show_uri_on_window().

§uri

the URI that is activated

§Returns

true if the link has been activated

Source

fn connect_copy_clipboard<F: Fn(&Self) + 'static>( &self, f: F, ) -> SignalHandlerId

The ::copy-clipboard signal is a [keybinding signal][GtkBindingSignal] which gets emitted to copy the selection to the clipboard.

The default binding for this signal is Ctrl-c.

Source

fn emit_copy_clipboard(&self)

Source

fn connect_move_cursor<F: Fn(&Self, MovementStep, i32, bool) + 'static>( &self, f: F, ) -> SignalHandlerId

The ::move-cursor signal is a [keybinding signal][GtkBindingSignal] which gets emitted when the user initiates a cursor movement. 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 g_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 Shift modifier extends the selection, the variant without the Shift modifer does not. There are too many key combinations to list them all here.

  • Arrow keys move by individual characters/lines
  • Ctrl-arrow key combinations move by words/paragraphs
  • Home/End keys move to the ends of the buffer
§step

the granularity of the move, as a MovementStep

§count

the number of step units to move

§extend_selection

true if the move should extend the selection

Source

fn emit_move_cursor( &self, step: MovementStep, count: i32, extend_selection: bool, )

Source

fn connect_populate_popup<F: Fn(&Self, &Menu) + 'static>( &self, f: F, ) -> SignalHandlerId

The ::populate-popup signal gets emitted before showing the context menu of the label. Note that only selectable labels have context menus.

If you need to add items to the context menu, connect to this signal and append your menuitems to the menu.

the menu that is being populated

Source

fn connect_angle_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId

Source

fn connect_attributes_notify<F: Fn(&Self) + 'static>( &self, f: F, ) -> SignalHandlerId

Source

fn connect_cursor_position_notify<F: Fn(&Self) + 'static>( &self, f: F, ) -> SignalHandlerId

Source

fn connect_ellipsize_notify<F: Fn(&Self) + 'static>( &self, f: F, ) -> SignalHandlerId

Source

fn connect_justify_notify<F: Fn(&Self) + 'static>( &self, f: F, ) -> SignalHandlerId

Source

fn connect_label_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId

Source

fn connect_lines_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId

Source

fn connect_max_width_chars_notify<F: Fn(&Self) + 'static>( &self, f: F, ) -> SignalHandlerId

Source

fn connect_mnemonic_keyval_notify<F: Fn(&Self) + 'static>( &self, f: F, ) -> SignalHandlerId

Source

fn connect_mnemonic_widget_notify<F: Fn(&Self) + 'static>( &self, f: F, ) -> SignalHandlerId

Source

fn connect_pattern_notify<F: Fn(&Self) + 'static>( &self, f: F, ) -> SignalHandlerId

Source

fn connect_selectable_notify<F: Fn(&Self) + 'static>( &self, f: F, ) -> SignalHandlerId

Source

fn connect_selection_bound_notify<F: Fn(&Self) + 'static>( &self, f: F, ) -> SignalHandlerId

Source

fn connect_single_line_mode_notify<F: Fn(&Self) + 'static>( &self, f: F, ) -> SignalHandlerId

Source

fn connect_use_markup_notify<F: Fn(&Self) + 'static>( &self, f: F, ) -> SignalHandlerId

Source

fn connect_use_underline_notify<F: Fn(&Self) + 'static>( &self, f: F, ) -> SignalHandlerId

Source

fn connect_width_chars_notify<F: Fn(&Self) + 'static>( &self, f: F, ) -> SignalHandlerId

Source

fn connect_wrap_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId

Source

fn connect_wrap_mode_notify<F: Fn(&Self) + 'static>( &self, f: F, ) -> SignalHandlerId

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<O: IsA<Label>> LabelExt for O