[][src]Trait gtk::LabelExt

pub trait LabelExt: 'static {
    fn get_angle(&self) -> f64;
fn get_attributes(&self) -> Option<AttrList>;
fn get_current_uri(&self) -> Option<GString>;
fn get_ellipsize(&self) -> EllipsizeMode;
fn get_justify(&self) -> Justification;
fn get_label(&self) -> Option<GString>;
fn get_layout(&self) -> Option<Layout>;
fn get_layout_offsets(&self) -> (i32, i32);
fn get_line_wrap(&self) -> bool;
fn get_line_wrap_mode(&self) -> WrapMode;
fn get_lines(&self) -> i32;
fn get_max_width_chars(&self) -> i32;
fn get_mnemonic_keyval(&self) -> u32;
fn get_mnemonic_widget(&self) -> Option<Widget>;
fn get_selectable(&self) -> bool;
fn get_selection_bounds(&self) -> Option<(i32, i32)>;
fn get_single_line_mode(&self) -> bool;
fn get_text(&self) -> Option<GString>;
fn get_track_visited_links(&self) -> bool;
fn get_use_markup(&self) -> bool;
fn get_use_underline(&self) -> bool;
fn get_width_chars(&self) -> i32;
fn get_xalign(&self) -> f32;
fn get_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<P: IsA<Widget>>(&self, widget: Option<&P>);
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 get_property_cursor_position(&self) -> i32;
fn get_property_selection_bound(&self) -> i32;
fn get_property_wrap(&self) -> bool;
fn set_property_wrap(&self, wrap: bool);
fn get_property_wrap_mode(&self) -> WrapMode;
fn set_property_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) -> Inhibit + '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_property_angle_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId;
fn connect_property_attributes_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId;
fn connect_property_cursor_position_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId;
fn connect_property_ellipsize_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId;
fn connect_property_justify_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId;
fn connect_property_label_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId;
fn connect_property_lines_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId;
fn connect_property_max_width_chars_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId;
fn connect_property_mnemonic_keyval_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId;
fn connect_property_mnemonic_widget_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId;
fn connect_property_pattern_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId;
fn connect_property_selectable_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId;
fn connect_property_selection_bound_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId;
fn connect_property_single_line_mode_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId;
fn connect_property_track_visited_links_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId;
fn connect_property_use_markup_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId;
fn connect_property_use_underline_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId;
fn connect_property_width_chars_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId;
fn connect_property_wrap_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId;
fn connect_property_wrap_mode_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId;
fn connect_property_xalign_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId;
fn connect_property_yalign_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId; }

Trait containing all Label methods.

Implementors

AccelLabel, Label

Required methods

fn get_angle(&self) -> f64

Gets the angle of rotation for the label. See LabelExt::set_angle.

Returns

the angle of rotation for the label

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

Gets the attribute list that was set on the label using LabelExt::set_attributes, if any. This function does not reflect attributes that come from the labels markup (see LabelExt::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.

fn get_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 Label::activate-link handler or for use in a Widget::query-tooltip handler.

Returns

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

fn get_ellipsize(&self) -> EllipsizeMode

Returns the ellipsizing position of the label. See LabelExt::set_ellipsize.

Returns

pango::EllipsizeMode

fn get_justify(&self) -> Justification

Returns the justification of the label. See LabelExt::set_justify.

Returns

Justification

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

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

Returns

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

fn get_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 LabelExt::get_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

fn get_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::get_has_window). Remember when using the pango::Layout functions you need to convert to and from pixels using PANGO_PIXELS() or PANGO_SCALE.

x

location to store X offset of layout, or None

y

location to store Y offset of layout, or None

fn get_line_wrap(&self) -> bool

Returns whether lines in the label are automatically wrapped. See LabelExt::set_line_wrap.

Returns

true if the lines of the label are automatically wrapped.

fn get_line_wrap_mode(&self) -> WrapMode

Returns line wrap mode used by the label. See LabelExt::set_line_wrap_mode.

Returns

true if the lines of the label are automatically wrapped.

fn get_lines(&self) -> i32

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

Returns

The number of lines

fn get_max_width_chars(&self) -> i32

Retrieves the desired maximum width of self, in characters. See LabelExt::set_width_chars.

Returns

the maximum width of the label in characters.

fn get_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

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

Retrieves the target of the mnemonic (keyboard shortcut) of this label. See LabelExt::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.

fn get_selectable(&self) -> bool

Gets the value set by LabelExt::set_selectable.

Returns

true if the user can copy text from the label

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

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

start

return location for start of selection, as a character offset

end

return location for end of selection, as a character offset

Returns

true if selection is non-empty

fn get_single_line_mode(&self) -> bool

Returns whether the label is in single line mode.

Returns

true when the label is in single line mode.

fn get_text(&self) -> Option<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 LabelExt::get_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

fn get_use_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.

fn get_use_underline(&self) -> bool

Returns whether an embedded underline in the label indicates a mnemonic. See LabelExt::set_use_underline.

Returns

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

fn get_width_chars(&self) -> i32

Retrieves the desired width of self, in characters. See LabelExt::set_width_chars.

Returns

the width of the label in characters.

fn get_xalign(&self) -> f32

Gets the Label:xalign property for self.

Feature: v3_16

Returns

the xalign property

fn get_yalign(&self) -> f32

Gets the Label:yalign property for self.

Feature: v3_16

Returns

the yalign property

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

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

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

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 Label:use-underline or Label: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

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

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. LabelExt::set_justify has no effect on labels containing only a single line.

jtype

a Justification

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 Label:use-underline and Label:use-markup properties.

str

the new text to set for the label

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

fn set_line_wrap_mode(&self, wrap_mode: WrapMode)

If line wrapping is on (see LabelExt::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

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

fn set_markup(&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 the str is external data, you may need to escape it with g_markup_escape_text or g_markup_printf_escaped:

GtkWidget *label = gtk_label_new (NULL);
const char *str = "some text";
const char *format = "<span style=\"italic\">\%s</span>";
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 Label:use-markup property to true as a side effect.

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

See also: LabelExt::set_text

str

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

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 LabelExt::set_mnemonic_widget.

str

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

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.

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

If the label has been set so that it has an mnemonic key (using i.e. LabelExt::set_markup_with_mnemonic, LabelExt::set_text_with_mnemonic, Label::new_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 Widget::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

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.

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

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

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 Label:use-underline property to false as a side effect.

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

See also: LabelExt::set_markup

str

The text you want to set

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

fn set_use_markup(&self, setting: bool)

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

setting

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

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

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.

fn set_xalign(&self, xalign: f32)

Sets the Label:xalign property for self.

Feature: v3_16

xalign

the new xalign value, between 0 and 1

fn set_yalign(&self, yalign: f32)

Sets the Label:yalign property for self.

Feature: v3_16

yalign

the new yalign value, between 0 and 1

fn get_property_cursor_position(&self) -> i32

fn get_property_selection_bound(&self) -> i32

fn get_property_wrap(&self) -> bool

fn set_property_wrap(&self, wrap: bool)

fn get_property_wrap_mode(&self) -> WrapMode

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

fn set_property_wrap_mode(&self, wrap_mode: WrapMode)

If line wrapping is on (see the Label: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][BindingSignal] 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 gtk_show_uri_on_window.

uri

the URI that is activated

Returns

true if the link has been activated

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

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

The default binding for this signal is Ctrl-c.

fn emit_copy_clipboard(&self)

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

The ::move-cursor signal is a [keybinding signal][BindingSignal] 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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Loading content...

Implementors

impl<O: IsA<Label>> LabelExt for O[src]

Loading content...