package ocgtk

  1. Overview
  2. Docs
OCaml bindings for GTK 4

Install

dune-project
 Dependency

Authors

Maintainers

Sources

v0.1-preview2.tar.gz
sha256=4e50fdb5093136a10fc8ffbe388e44cbcb70d52f8afdd48863ec7e22580ff054

doc/ocgtk.gtk/Ocgtk_gtk/Gtk/Wrappers/Label/index.html

Module Wrappers.Label

type t = [ `label | `widget | `initially_unowned | `object_ ] Gobject.obj
val new_ : string option -> t

Create a new Label

val new_with_mnemonic : string option -> t

Create a new Label

val set_yalign : t -> float -> unit

Sets the `yalign` of the label.

See the property@Gtk.Label:yalign property.

val set_xalign : t -> float -> unit

Sets the `xalign` of the label.

See the property@Gtk.Label:xalign property.

val set_wrap_mode : t -> Ocgtk_pango.Pango.wrapmode -> unit

Controls how line wrapping is done.

This only affects the label if line wrapping is on. (See method@Gtk.Label.set_wrap) The default is %PANGO_WRAP_WORD which means wrap on word boundaries.

For sizing behavior, also consider the property@Gtk.Label:natural-wrap-mode property.

val set_wrap : t -> bool -> unit

Toggles line wrapping within the `GtkLabel` 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 method@Gtk.Widget.set_size_request.

val set_width_chars : t -> int -> unit

Sets the desired width in characters of @label to @n_chars.

val set_use_underline : t -> bool -> unit

Sets whether underlines in the text indicate mnemonics.

val set_use_markup : t -> bool -> unit

Sets whether the text of the label contains markup.

See method@Gtk.Label.set_markup.

val set_text_with_mnemonic : t -> string -> unit

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 method@Gtk.Label.set_mnemonic_widget.

val set_text : t -> string -> unit

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 property@Gtk.Label:use-underline property to %FALSE as a side effect.

This function will set the property@Gtk.Label:use-markup property to %FALSE as a side effect.

See also: method@Gtk.Label.set_markup

val set_tabs : t -> Ocgtk_pango.Pango.Wrappers.Tab_array.t option -> unit

Sets the default tab stops for paragraphs in @self.

val set_single_line_mode : t -> bool -> unit

Sets whether the label is in single line mode.

val set_selectable : t -> bool -> unit

Makes text in the label selectable.

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

val set_natural_wrap_mode : t -> Gtk_enums.naturalwrapmode -> unit

Select the line wrapping for the natural size request.

This only affects the natural size requested, for the actual wrapping used, see the property@Gtk.Label:wrap-mode property.

val set_mnemonic_widget : t -> [ `widget | `initially_unowned | `object_ ] Gobject.obj option -> unit

Associate the label with its mnemonic target.

If the label has been set so that it has a mnemonic key (using i.e. method@Gtk.Label.set_markup_with_mnemonic, method@Gtk.Label.set_text_with_mnemonic, ctor@Gtk.Label.new_with_mnemonic 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 class@Gtk.Button or a class@Gtk.Notebook tab) it is automatically associated with the correct widget, but sometimes (i.e. when the target is a class@Gtk.Entry next to the label) you need to set it explicitly using this function.

The target widget will be accelerated by emitting the signal@Gtk.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.

val set_max_width_chars : t -> int -> unit

Sets the desired maximum width in characters of @label to @n_chars.

val set_markup_with_mnemonic : t -> string -> unit

Sets the labels text, attributes and mnemonic from markup.

Parses @str which is marked up with Pango markup (see func@Pango.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 method@Gtk.Label.set_mnemonic_widget.

val set_markup : t -> string -> unit

Sets the labels text and attributes from markup.

The string must be marked up with Pango markup (see func@Pango.parse_markup).

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

```c 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 property@Gtk.Label:use-markup property to %TRUE as a side effect.

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

See also: method@Gtk.Label.set_text

val set_lines : t -> int -> unit

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.

val set_label : t -> string -> unit

Sets the text of the label.

The label is interpreted as including embedded underlines and/or Pango markup depending on the values of the property@Gtk.Label:use-underline and property@Gtk.Label:use-markup properties.

val set_justify : t -> Gtk_enums.justification -> unit

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

%GTK_JUSTIFY_LEFT is the default value when the widget is first created with ctor@Gtk.Label.new. If you instead want to set the alignment of the label as a whole, use method@Gtk.Widget.set_halign instead. method@Gtk.Label.set_justify has no effect on labels containing only a single line.

val set_extra_menu : t -> Ocgtk_gio.Gio.Wrappers.Menu_model.t option -> unit

Sets a menu model to add when constructing the context menu for @label.

val set_ellipsize : t -> Ocgtk_pango.Pango.ellipsizemode -> unit

Sets the mode used to ellipsize the text.

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

val set_attributes : t -> Ocgtk_pango.Pango.Wrappers.Attr_list.t option -> unit

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 property@Gtk.Label:use-underline or property@Gtk.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.

val select_region : t -> int -> int -> unit

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

See method@Gtk.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.

val get_yalign : t -> float

Gets the `yalign` of the label.

See the property@Gtk.Label:yalign property.

val get_xalign : t -> float

Gets the `xalign` of the label.

See the property@Gtk.Label:xalign property.

val get_wrap_mode : t -> Ocgtk_pango.Pango.wrapmode

Returns line wrap mode used by the label.

See method@Gtk.Label.set_wrap_mode.

val get_wrap : t -> bool

Returns whether lines in the label are automatically wrapped.

See method@Gtk.Label.set_wrap.

val get_width_chars : t -> int

Retrieves the desired width of @label, in characters.

See method@Gtk.Label.set_width_chars.

val get_use_underline : t -> bool

Returns whether an embedded underlines in the label indicate mnemonics.

See method@Gtk.Label.set_use_underline.

val get_use_markup : t -> bool

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

See method@Gtk.Label.set_use_markup.

val get_text : t -> string

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 method@Gtk.Label.get_label)

val get_tabs : t -> Ocgtk_pango.Pango.Wrappers.Tab_array.t option

Gets the tabs for @self.

The returned array will be %NULL if “standard” (8-space) tabs are used. Free the return value with method@Pango.TabArray.free.

val get_single_line_mode : t -> bool

Returns whether the label is in single line mode.

val get_selection_bounds : t -> bool * int * int

Gets the selected range of characters in the label.

val get_selectable : t -> bool

Returns whether the label is selectable.

val get_natural_wrap_mode : t -> Gtk_enums.naturalwrapmode

Returns line wrap mode used by the label.

See method@Gtk.Label.set_natural_wrap_mode.

val get_mnemonic_widget : t -> [ `widget | `initially_unowned | `object_ ] Gobject.obj option

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

See method@Gtk.Label.set_mnemonic_widget.

val get_mnemonic_keyval : t -> int

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`.

val get_max_width_chars : t -> int

Retrieves the desired maximum width of @label, in characters.

See method@Gtk.Label.set_width_chars.

val get_lines : t -> int

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

See method@Gtk.Label.set_lines.

val get_layout_offsets : t -> int * int

Obtains the coordinates where the label will draw its `PangoLayout`.

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

Gets the `PangoLayout` used to display the label.

The layout is useful to e.g. convert text positions to pixel positions, in combination with method@Gtk.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.

val get_label : t -> string

Fetches the text from a label.

The returned text includes any embedded underlines indicating mnemonics and Pango markup. (See method@Gtk.Label.get_text).

val get_justify : t -> Gtk_enums.justification

Returns the justification of the label.

See method@Gtk.Label.set_justify.

val get_extra_menu : t -> Ocgtk_gio.Gio.Wrappers.Menu_model.t option

Gets the extra menu model of @label.

See method@Gtk.Label.set_extra_menu.

val get_ellipsize : t -> Ocgtk_pango.Pango.ellipsizemode

Returns the ellipsizing position of the label.

See method@Gtk.Label.set_ellipsize.

val get_current_uri : t -> string option

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

val get_attributes : t -> Ocgtk_pango.Pango.Wrappers.Attr_list.t option

Gets the label's attribute list.

This is the struct@Pango.AttrList that was set on the label using method@Gtk.Label.set_attributes, if any. This function does not reflect attributes that come from the label's markup (see method@Gtk.Label.set_markup). If you want to get the effective attributes for the label, use `pango_layout_get_attributes (gtk_label_get_layout (self))`.

val on_copy_clipboard : ?after:bool -> t -> callback:(unit -> unit) -> Gobject.Signal.handler_id
val on_move_cursor : ?after:bool -> t -> callback: (step:Gtk_enums.movementstep -> count:int -> extend_selection:bool -> unit) -> Gobject.Signal.handler_id