package ocgtk
Install
dune-project
Dependency
Authors
Maintainers
Sources
sha256=4e50fdb5093136a10fc8ffbe388e44cbcb70d52f8afdd48863ec7e22580ff054
doc/ocgtk.gtk/Ocgtk_gtk/Gtk/Wrappers/Label/index.html
Module Wrappers.Label
type t = [ `label | `widget | `initially_unowned | `object_ ] Gobject.objval new_ : string option -> tCreate a new Label
val new_with_mnemonic : string option -> tCreate a new Label
val set_yalign : t -> float -> unitSets the `yalign` of the label.
See the property@Gtk.Label:yalign property.
val set_xalign : t -> float -> unitSets the `xalign` of the label.
See the property@Gtk.Label:xalign property.
val set_wrap_mode : t -> Ocgtk_pango.Pango.wrapmode -> unitControls 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 -> unitToggles 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 -> unitSets the desired width in characters of @label to @n_chars.
val set_use_underline : t -> bool -> unitSets whether underlines in the text indicate mnemonics.
val set_use_markup : t -> bool -> unitSets whether the text of the label contains markup.
See method@Gtk.Label.set_markup.
val set_text_with_mnemonic : t -> string -> unitSets 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 -> unitSets 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 -> unitSets the default tab stops for paragraphs in @self.
val set_single_line_mode : t -> bool -> unitSets whether the label is in single line mode.
val set_selectable : t -> bool -> unitMakes 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 -> unitSelect 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 ->
unitAssociate 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 -> unitSets the desired maximum width in characters of @label to @n_chars.
val set_markup_with_mnemonic : t -> string -> unitSets 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 -> unitSets 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 -> unitSets 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 -> unitSets 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 -> unitSets 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.
Sets a menu model to add when constructing the context menu for @label.
val set_ellipsize : t -> Ocgtk_pango.Pango.ellipsizemode -> unitSets 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 -> unitApply 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 -> unitSelects 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 -> floatGets the `yalign` of the label.
See the property@Gtk.Label:yalign property.
val get_xalign : t -> floatGets the `xalign` of the label.
See the property@Gtk.Label:xalign property.
val get_wrap_mode : t -> Ocgtk_pango.Pango.wrapmodeReturns line wrap mode used by the label.
See method@Gtk.Label.set_wrap_mode.
val get_wrap : t -> boolReturns whether lines in the label are automatically wrapped.
See method@Gtk.Label.set_wrap.
val get_width_chars : t -> intRetrieves the desired width of @label, in characters.
See method@Gtk.Label.set_width_chars.
val get_use_underline : t -> boolReturns whether an embedded underlines in the label indicate mnemonics.
See method@Gtk.Label.set_use_underline.
val get_use_markup : t -> boolReturns whether the label’s text is interpreted as Pango markup.
See method@Gtk.Label.set_use_markup.
val get_text : t -> stringFetches 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 optionGets 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 -> boolReturns whether the label is in single line mode.
val get_selection_bounds : t -> bool * int * intGets the selected range of characters in the label.
val get_selectable : t -> boolReturns whether the label is selectable.
val get_natural_wrap_mode : t -> Gtk_enums.naturalwrapmodeReturns 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 optionRetrieves the target of the mnemonic (keyboard shortcut) of this label.
See method@Gtk.Label.set_mnemonic_widget.
val get_mnemonic_keyval : t -> intReturn 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 -> intRetrieves the desired maximum width of @label, in characters.
See method@Gtk.Label.set_width_chars.
val get_lines : t -> intGets 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 * intObtains 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.
val get_layout : t -> Ocgtk_pango.Pango.Wrappers.Layout.tGets 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 -> stringFetches 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.justificationReturns the justification of the label.
See method@Gtk.Label.set_justify.
Gets the extra menu model of @label.
See method@Gtk.Label.set_extra_menu.
val get_ellipsize : t -> Ocgtk_pango.Pango.ellipsizemodeReturns the ellipsizing position of the label.
See method@Gtk.Label.set_ellipsize.
val get_current_uri : t -> string optionReturns 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 optionGets 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_activate_current_link :
?after:bool ->
t ->
callback:(unit -> unit) ->
Gobject.Signal.handler_idval on_activate_link :
?after:bool ->
t ->
callback:(uri:string -> bool) ->
Gobject.Signal.handler_idval on_copy_clipboard :
?after:bool ->
t ->
callback:(unit -> unit) ->
Gobject.Signal.handler_idval on_move_cursor :
?after:bool ->
t ->
callback:
(step:Gtk_enums.movementstep -> count:int -> extend_selection:bool -> unit) ->
Gobject.Signal.handler_id