Next: , Previous: ClutterTableLayout, Up: Top


67 ClutterText

An actor for displaying and editing text

67.1 Overview

<clutter-text> is an actor that displays custom text using Pango as the text rendering engine.

<clutter-text> also allows inline editing of the text if the actor is set editable using clutter-text-set-editable.

Selection using keyboard or pointers can be enabled using clutter-text-set-selectable.

<clutter-text> is available since Clutter 1.0

67.2 Usage

— Function: clutter-text-new ⇒  (ret <clutter-actor>)

Creates a new <clutter-text> actor. This actor can be used to display and edit text.

ret
the newly created <clutter-text> actor

Since 1.0

— Function: clutter-text-new-full (font_name mchars) (text mchars) (color <clutter-color>) ⇒  (ret <clutter-actor>)

Creates a new <clutter-text> actor, using font-name as the font description; text will be used to set the contents of the actor; and color will be used as the color to render text.

This function is equivalent to calling clutter-text-new, clutter-text-set-font-name, clutter-text-set-text and clutter-text-set-color.

font-name
a string with a font description
text
the contents of the actor
color
the color to be used to render text
ret
the newly created <clutter-text> actor

Since 1.0

— Function: clutter-text-new-with-text (font_name mchars) (text mchars) ⇒  (ret <clutter-actor>)

Creates a new <clutter-text> actor, using font-name as the font description; text will be used to set the contents of the actor.

This function is equivalent to calling clutter-text-new, clutter-text-set-font-name, and clutter-text-set-text.

font-name
a string with a font description.
text
the contents of the actor
ret
the newly created <clutter-text> actor

Since 1.0

— Function: clutter-text-new-with-buffer (buffer <clutter-text-buffer>) ⇒  (ret <clutter-actor>)

Creates a new entry with the specified text buffer.

buffer
The buffer to use for the new <clutter-text>.
ret
a new <clutter-text>

Since 1.10

— Function: clutter-text-set-buffer (self <clutter-text>) (buffer <clutter-text-buffer>)
— Method: set-buffer

Set the <clutter-text-buffer> object which holds the text for this widget.

self
a <clutter-text>
buffer
a <clutter-text-buffer>

Since 1.10

— Function: clutter-text-get-buffer (self <clutter-text>) ⇒  (ret <clutter-text-buffer>)
— Method: get-buffer

Get the <clutter-text-buffer> object which holds the text for this widget.

self
a <clutter-text>
ret
A <gtk-entry-buffer> object.

Since 1.10

— Function: clutter-text-set-text (self <clutter-text>) (text mchars)
— Method: set-text

Sets the contents of a <clutter-text> actor.

If the <"use-markup"> property was set to ‘#t’ it will be reset to ‘#f’ as a side effect. If you want to maintain the <"use-markup"> you should use the clutter-text-set-markup function instead

self
a <clutter-text>
text
the text to set. Passing ‘#f’ is the same as passing "" (the empty string).

Since 1.0

— Function: clutter-text-set-markup (self <clutter-text>) (markup mchars)
— Method: set-markup

Sets markup as the contents of a <clutter-text>.

This is a convenience function for setting a string containing Pango markup, and it is logically equivalent to:

          
            /&#x002A; the order is important &#x002A;/
            clutter_text_set_text (CLUTTER_TEXT (actor), markup);
            clutter_text_set_use_markup (CLUTTER_TEXT (actor), TRUE);
self
a <clutter-text>
markup
a string containing Pango markup. Passing ‘#f’ is the same as passing "" (the empty string).

Since 1.0

— Function: clutter-text-get-text (self <clutter-text>) ⇒  (ret mchars)
— Method: get-text

Retrieves a pointer to the current contents of a <clutter-text> actor.

If you need a copy of the contents for manipulating, either use g-strdup on the returned string, or use:

          
             copy = clutter_text_get_chars (text, 0, -1);

Which will return a newly allocated string.

If the <clutter-text> actor is empty, this function will return an empty string, and not ‘#f’.

self
a <clutter-text>
ret
the contents of the actor. The returned string is owned by the <clutter-text> actor and should never be modified or freed.

Since 1.0

— Function: clutter-text-set-activatable (self <clutter-text>) (activatable bool)
— Method: set-activatable

Sets whether a <clutter-text> actor should be activatable.

An activatable <clutter-text> actor will emit the <"activate"> signal whenever the 'Enter' (or 'Return') key is pressed; if it is not activatable, a new line will be appended to the current content.

An activatable <clutter-text> must also be set as editable using clutter-text-set-editable.

self
a <clutter-text>
activatable
whether the <clutter-text> actor should be activatable

Since 1.0

— Function: clutter-text-get-activatable (self <clutter-text>) ⇒  (ret bool)
— Method: get-activatable

Retrieves whether a <clutter-text> is activatable or not.

self
a <clutter-text>
ret
#t’ if the actor is activatable

Since 1.0

— Function: clutter-text-set-attributes (self <clutter-text>) (attrs <pango-attr-list>)
— Method: set-attributes

Sets the attributes list that are going to be applied to the <clutter-text> contents.

The <clutter-text> actor will take a reference on the <pango-attr-list> passed to this function.

self
a <clutter-text>
attrs
a <pango-attr-list> or ‘#f’ to unset the attributes

Since 1.0

— Function: clutter-text-get-attributes (self <clutter-text>) ⇒  (ret <pango-attr-list>)
— Method: get-attributes

Gets the attribute list that was set on the <clutter-text> actor clutter-text-set-attributes, if any.

self
a <clutter-text>
ret
the attribute list, or ‘#f’ if none was set. The returned value is owned by the <clutter-text> and should not be unreferenced.

Since 1.0

— Function: clutter-text-set-color (self <clutter-text>) (color <clutter-color>)
— Method: set-color

Sets the color of the contents of a <clutter-text> actor.

The overall opacity of the <clutter-text> actor will be the result of the alpha value of color and the composited opacity of the actor itself on the scenegraph, as returned by clutter-actor-get-paint-opacity.

self
a <clutter-text>
color
a <clutter-color>

Since 1.0

— Function: clutter-text-get-color (self <clutter-text>) (color <clutter-color>)
— Method: get-color

Retrieves the text color as set by clutter-text-set-color.

self
a <clutter-text>
color
return location for a <clutter-color>.

Since 1.0

— Function: clutter-text-set-ellipsize (self <clutter-text>) (mode <pango-ellipsize-mode>)
— Method: set-ellipsize

Sets the mode used to ellipsize (add an ellipsis: "...") to the text if there is not enough space to render the entire contents of a <clutter-text> actor

self
a <clutter-text>
mode
a <pango-ellipsize-mode>

Since 1.0

— Function: clutter-text-get-ellipsize (self <clutter-text>) ⇒  (ret <pango-ellipsize-mode>)
— Method: get-ellipsize

Returns the ellipsizing position of a <clutter-text> actor, as set by clutter-text-set-ellipsize.

self
a <clutter-text>
ret
<pango-ellipsize-mode>

Since 1.0

— Function: clutter-text-set-font-name (self <clutter-text>) (font_name mchars)
— Method: set-font-name

Sets the font used by a <clutter-text>. The font-name string must either be ‘#f’, which means that the font name from the default <clutter-backend> will be used; or be something that can be parsed by the pango-font-description-from-string function, like:

          
            clutter_text_set_font_name (text, "Sans 10pt");
            clutter_text_set_font_name (text, "Serif 16px");
            clutter_text_set_font_name (text, "Helvetica 10");
self
a <clutter-text>
font-name
a font name, or ‘#f’ to set the default font name.

Since 1.0

— Function: clutter-text-get-font-name (self <clutter-text>) ⇒  (ret mchars)
— Method: get-font-name

Retrieves the font name as set by clutter-text-set-font-name.

self
a <clutter-text>
ret
a string containing the font name. The returned string is owned by the <clutter-text> actor and should not be modified or freed

Since 1.0

— Function: clutter-text-set-font-description (self <clutter-text>) (font_desc <pango-font-description>)
— Method: set-font-description

Sets font-desc as the font description for a <clutter-text>

The <pango-font-description> is copied by the <clutter-text> actor so you can safely call pango-font-description-free on it after calling this function.

self
a <clutter-text>
font-desc
a <pango-font-description>

Since 1.2

— Function: clutter-text-set-password-char (self <clutter-text>) (wc unsigned-int32)
— Method: set-password-char

Sets the character to use in place of the actual text in a password text actor.

If wc is 0 the text will be displayed as it is entered in the <clutter-text> actor.

self
a <clutter-text>
wc
a Unicode character, or 0 to unset the password character

Since 1.0

— Function: clutter-text-get-password-char (self <clutter-text>) ⇒  (ret unsigned-int32)
— Method: get-password-char

Retrieves the character to use in place of the actual text as set by clutter-text-set-password-char.

self
a <clutter-text>
ret
a Unicode character or 0 if the password character is not set

Since 1.0

— Function: clutter-text-set-justify (self <clutter-text>) (justify bool)
— Method: set-justify

Sets whether the text of the <clutter-text> actor should be justified on both margins. This setting is ignored if Clutter is compiled against Pango < 1.18.

self
a <clutter-text>
justify
whether the text should be justified

Since 1.0

— Function: clutter-text-get-justify (self <clutter-text>) ⇒  (ret bool)
— Method: get-justify

Retrieves whether the <clutter-text> actor should justify its contents on both margins.

self
a <clutter-text>
ret
#t’ if the text should be justified

Since 0.6

— Function: clutter-text-get-layout (self <clutter-text>) ⇒  (ret <pango-layout>)
— Method: get-layout

Retrieves the current <pango-layout> used by a <clutter-text> actor.

self
a <clutter-text>
ret
a <pango-layout>. The returned object is owned by the <clutter-text> actor and should not be modified or freed.

Since 1.0

— Function: clutter-text-set-line-alignment (self <clutter-text>) (alignment <pango-alignment>)
— Method: set-line-alignment

Sets the way that the lines of a wrapped label are aligned with respect to each other. This does not affect the overall alignment of the label within its allocated or specified width.

To align a <clutter-text> actor you should add it to a container that supports alignment, or use the anchor point.

self
a <clutter-text>
alignment
A <pango-alignment>

Since 1.0

— Function: clutter-text-get-line-alignment (self <clutter-text>) ⇒  (ret <pango-alignment>)
— Method: get-line-alignment

Retrieves the alignment of a <clutter-text>, as set by clutter-text-set-line-alignment.

self
a <clutter-text>
ret
a <pango-alignment>

Since 1.0

— Function: clutter-text-set-line-wrap (self <clutter-text>) (line_wrap bool)
— Method: set-line-wrap

Sets whether the contents of a <clutter-text> actor should wrap, if they don't fit the size assigned to the actor.

self
a <clutter-text>
line-wrap
whether the contents should wrap

Since 1.0

— Function: clutter-text-get-line-wrap (self <clutter-text>) ⇒  (ret bool)
— Method: get-line-wrap

Retrieves the value set using clutter-text-set-line-wrap.

self
a <clutter-text>
ret
#t’ if the <clutter-text> actor should wrap its contents

Since 1.0

— Function: clutter-text-set-line-wrap-mode (self <clutter-text>) (wrap_mode <pango-wrap-mode>)
— Method: set-line-wrap-mode

If line wrapping is enabled (see clutter-text-set-line-wrap) this function controls how the line wrapping is performed. The default is ‘PANGO_WRAP_WORD’ which means wrap on word boundaries.

self
a <clutter-text>
wrap-mode
the line wrapping mode

Since 1.0

— Function: clutter-text-get-line-wrap-mode (self <clutter-text>) ⇒  (ret <pango-wrap-mode>)
— Method: get-line-wrap-mode

Retrieves the line wrap mode used by the <clutter-text> actor.

See clutter-text-set-line-wrap-mode.

self
a <clutter-text>
ret
the wrap mode used by the <clutter-text>

Since 1.0

— Function: clutter-text-set-max-length (self <clutter-text>) (max int)
— Method: set-max-length

Sets the maximum allowed length of the contents of the actor. If the current contents are longer than the given length, then they will be truncated to fit.

self
a <clutter-text>
max
the maximum number of characters allowed in the text actor; 0 to disable or -1 to set the length of the current string

Since 1.0

— Function: clutter-text-get-max-length (self <clutter-text>) ⇒  (ret int)
— Method: get-max-length

Gets the maximum length of text that can be set into a text actor.

See clutter-text-set-max-length.

self
a <clutter-text>
ret
the maximum number of characters.

Since 1.0

— Function: clutter-text-set-selectable (self <clutter-text>) (selectable bool)
— Method: set-selectable

Sets whether a <clutter-text> actor should be selectable.

A selectable <clutter-text> will allow selecting its contents using the pointer or the keyboard.

self
a <clutter-text>
selectable
whether the <clutter-text> actor should be selectable

Since 1.0

— Function: clutter-text-get-selectable (self <clutter-text>) ⇒  (ret bool)
— Method: get-selectable

Retrieves whether a <clutter-text> is selectable or not.

self
a <clutter-text>
ret
#t’ if the actor is selectable

Since 1.0

— Function: clutter-text-set-selection (self <clutter-text>) (start_pos ssize_t) (end_pos ssize_t)
— Method: set-selection

Selects the region of text between start-pos and end-pos.

This function changes the position of the cursor to match start-pos and the selection bound to match end-pos.

self
a <clutter-text>
start-pos
start of the selection, in characters
end-pos
end of the selection, in characters

Since 1.0

— Function: clutter-text-get-selection (self <clutter-text>) ⇒  (ret mchars)
— Method: get-selection

Retrieves the currently selected text.

self
a <clutter-text>
ret
a newly allocated string containing the currently selected text, or ‘#f’. Use g-free to free the returned string.

Since 1.0

— Function: clutter-text-set-selection-bound (self <clutter-text>) (selection_bound int)
— Method: set-selection-bound

Sets the other end of the selection, starting from the current cursor position.

If selection-bound is -1, the selection unset.

self
a <clutter-text>
selection-bound
the position of the end of the selection, in characters

Since 1.0

— Function: clutter-text-get-selection-bound (self <clutter-text>) ⇒  (ret int)
— Method: get-selection-bound

Retrieves the other end of the selection of a <clutter-text> actor, in characters from the current cursor position.

self
a <clutter-text>
ret
the position of the other end of the selection

Since 1.0

— Function: clutter-text-set-single-line-mode (self <clutter-text>) (single_line bool)
— Method: set-single-line-mode

Sets whether a <clutter-text> actor should be in single line mode or not. Only editable <clutter-text>s can be in single line mode.

A text actor in single line mode will not wrap text and will clip the visible area to the predefined size. The contents of the text actor will scroll to display the end of the text if its length is bigger than the allocated width.

When setting the single line mode the <"activatable"> property is also set as a side effect. Instead of entering a new line character, the text actor will emit the <"activate"> signal.

self
a <clutter-text>
single-line
whether to enable single line mode

Since 1.0

— Function: clutter-text-get-single-line-mode (self <clutter-text>) ⇒  (ret bool)
— Method: get-single-line-mode

Retrieves whether the <clutter-text> actor is in single line mode.

self
a <clutter-text>
ret
#t’ if the <clutter-text> actor is in single line mode

Since 1.0

— Function: clutter-text-set-use-markup (self <clutter-text>) (setting bool)
— Method: set-use-markup

Sets whether the contents of the <clutter-text> actor contains markup in Pango's text markup language.

Setting <"use-markup"> on an editable <clutter-text> will not have any effect except hiding the markup.

See also <"use-markup">.

self
a <clutter-text>
setting
#t’ if the text should be parsed for markup.

Since 1.0

— Function: clutter-text-get-use-markup (self <clutter-text>) ⇒  (ret bool)
— Method: get-use-markup

Retrieves whether the contents of the <clutter-text> actor should be parsed for the Pango text markup.

self
a <clutter-text>
ret
#t’ if the contents will be parsed for markup

Since 1.0

— Function: clutter-text-set-editable (self <clutter-text>) (editable bool)
— Method: set-editable

Sets whether the <clutter-text> actor should be editable.

An editable <clutter-text> with key focus set using clutter-actor-grab-key-focus or clutter-stage-set-key-focus will receive key events and will update its contents accordingly.

self
a <clutter-text>
editable
whether the <clutter-text> should be editable

Since 1.0

— Function: clutter-text-get-editable (self <clutter-text>) ⇒  (ret bool)
— Method: get-editable

Retrieves whether a <clutter-text> is editable or not.

self
a <clutter-text>
ret
#t’ if the actor is editable

Since 1.0

— Function: clutter-text-insert-text (self <clutter-text>) (text mchars) (position ssize_t)
— Method: insert-text

Inserts text into a <clutter-actor> at the given position.

If position is a negative number, the text will be appended at the end of the current contents of the <clutter-text>.

The position is expressed in characters, not in bytes.

self
a <clutter-text>
text
the text to be inserted
position
the position of the insertion, or -1

Since 1.0

— Function: clutter-text-insert-unichar (self <clutter-text>) (wc unsigned-int32)
— Method: insert-unichar

Inserts wc at the current cursor position of a <clutter-text> actor.

self
a <clutter-text>
wc
a Unicode character

Since 1.0

— Function: clutter-text-delete-chars (self <clutter-text>) (n_chars unsigned-int)
— Method: delete-chars

Deletes n-chars inside a <clutter-text> actor, starting from the current cursor position.

Somewhat awkwardly, the cursor position is decremented by the same number of characters you've deleted.

self
a <clutter-text>
n-chars
the number of characters to delete

Since 1.0

— Function: clutter-text-delete-text (self <clutter-text>) (start_pos ssize_t) (end_pos ssize_t)
— Method: delete-text

Deletes the text inside a <clutter-text> actor between start-pos and end-pos.

The starting and ending positions are expressed in characters, not in bytes.

self
a <clutter-text>
start-pos
starting position
end-pos
ending position

Since 1.0

— Function: clutter-text-delete-selection (self <clutter-text>) ⇒  (ret bool)
— Method: delete-selection

Deletes the currently selected text

This function is only useful in subclasses of <clutter-text>

self
a <clutter-text>
ret
#t’ if text was deleted or if the text actor is empty, and ‘#f’ otherwise

Since 1.0

— Function: clutter-text-get-chars (self <clutter-text>) (start_pos ssize_t) (end_pos ssize_t) ⇒  (ret mchars)
— Method: get-chars

Retrieves the contents of the <clutter-text> actor between start-pos and end-pos, but not including end-pos.

The positions are specified in characters, not in bytes.

self
a <clutter-text>
start-pos
start of text, in characters
end-pos
end of text, in characters
ret
a newly allocated string with the contents of the text actor between the specified positions. Use g-free to free the resources when done

Since 1.0

— Function: clutter-text-set-cursor-color (self <clutter-text>) (color <clutter-color>)
— Method: set-cursor-color

Sets the color of the cursor of a <clutter-text> actor.

If color is ‘#f’, the cursor color will be the same as the text color.

self
a <clutter-text>
color
the color of the cursor, or ‘#f’ to unset it

Since 1.0

— Function: clutter-text-get-cursor-color (self <clutter-text>) (color <clutter-color>)
— Method: get-cursor-color

Retrieves the color of the cursor of a <clutter-text> actor.

self
a <clutter-text>
color
return location for a <clutter-color>.

Since 1.0

— Function: clutter-text-set-selection-color (self <clutter-text>) (color <clutter-color>)
— Method: set-selection-color

Sets the color of the selection of a <clutter-text> actor.

If color is ‘#f’, the selection color will be the same as the cursor color, or if no cursor color is set either then it will be the same as the text color.

self
a <clutter-text>
color
the color of the selection, or ‘#f’ to unset it

Since 1.0

— Function: clutter-text-get-selection-color (self <clutter-text>) (color <clutter-color>)
— Method: get-selection-color

Retrieves the color of the selection of a <clutter-text> actor.

self
a <clutter-text>
color
return location for a <clutter-color>.

Since 1.0

— Function: clutter-text-set-cursor-position (self <clutter-text>) (position int)
— Method: set-cursor-position

Sets the cursor of a <clutter-text> actor at position.

The position is expressed in characters, not in bytes.

self
a <clutter-text>
position
the new cursor position, in characters

Since 1.0

— Function: clutter-text-get-cursor-position (self <clutter-text>) ⇒  (ret int)
— Method: get-cursor-position

Retrieves the cursor position.

self
a <clutter-text>
ret
the cursor position, in characters

Since 1.0

— Function: clutter-text-set-cursor-visible (self <clutter-text>) (cursor_visible bool)
— Method: set-cursor-visible

Sets whether the cursor of a <clutter-text> actor should be visible or not.

The color of the cursor will be the same as the text color unless clutter-text-set-cursor-color has been called.

The size of the cursor can be set using clutter-text-set-cursor-size.

The position of the cursor can be changed programmatically using clutter-text-set-cursor-position.

self
a <clutter-text>
cursor-visible
whether the cursor should be visible

Since 1.0

— Function: clutter-text-get-cursor-visible (self <clutter-text>) ⇒  (ret bool)
— Method: get-cursor-visible

Retrieves whether the cursor of a <clutter-text> actor is visible.

self
a <clutter-text>
ret
#t’ if the cursor is visible

Since 1.0

— Function: clutter-text-set-cursor-size (self <clutter-text>) (size int)
— Method: set-cursor-size

Sets the size of the cursor of a <clutter-text>. The cursor will only be visible if the <"cursor-visible"> property is set to ‘#t’.

self
a <clutter-text>
size
the size of the cursor, in pixels, or -1 to use the default value

Since 1.0

— Function: clutter-text-get-cursor-size (self <clutter-text>) ⇒  (ret unsigned-int)
— Method: get-cursor-size

Retrieves the size of the cursor of a <clutter-text> actor.

self
a <clutter-text>
ret
the size of the cursor, in pixels

Since 1.0

— Function: clutter-text-activate (self <clutter-text>) ⇒  (ret bool)
— Method: activate

Emits the <"activate"> signal, if self has been set as activatable using clutter-text-set-activatable.

This function can be used to emit the ::activate signal inside a <"captured-event"> or <"key-press-event"> signal handlers before the default signal handler for the <clutter-text> is invoked.

self
a <clutter-text>
ret
#t’ if the ::activate signal has been emitted, and ‘#f’ otherwise

Since 1.0

— Function: clutter-text-coords-to-position (self <clutter-text>) (float) (float) ⇒  (ret int)
— Method: coords-to-position

Retrieves the position of the character at the given coordinates.

Return: the position of the character

self
a <clutter-text>
x
the X coordinate, relative to the actor
y
the Y coordinate, relative to the actor

Since 1.10

— Function: clutter-text-position-to-coords (self <clutter-text>) (position int) ⇒  (ret bool) (float) (float) (line_height float)
— Method: position-to-coords

Retrieves the coordinates of the given position.

self
a <clutter-text>
position
position in characters
x
return location for the X coordinate, or ‘#f’.
y
return location for the Y coordinate, or ‘#f’.
line-height
return location for the line height, or ‘#f’.
ret
#t’ if the conversion was successful

Since 1.0

— Function: clutter-text-set-preedit-string (self <clutter-text>) (preedit_str mchars) (preedit_attrs <pango-attr-list>) (cursor_pos unsigned-int)
— Method: set-preedit-string

Sets, or unsets, the pre-edit string. This function is useful for input methods to display a string (with eventual specific Pango attributes) before it is entered inside the <clutter-text> buffer.

The preedit string and attributes are ignored if the <clutter-text> actor is not editable.

This function should not be used by applications

self
a <clutter-text>
preedit-str
the pre-edit string, or ‘#f’ to unset it.
preedit-attrs
the pre-edit string attributes.
cursor-pos
the cursor position for the pre-edit string

Since 1.2

— Function: clutter-text-get-layout-offsets (self <clutter-text>) ⇒  (int) (int)
— Method: get-layout-offsets

Obtains the coordinates where the <clutter-text> will draw the <pango-layout> representing the text.

self
a <clutter-text>
x
location to store X offset of layout, or ‘#f’.
y
location to store Y offset of layout, or ‘#f’.

Since 1.8