Class (GI Class)

Gtk-3.0GtkTextBuffer

You may wish to begin by reading the text widget conceptual overview which gives an overview of all the objects and data types related to the text widget and how they work together.

Hierarchy (View Summary)

Index

Constructors

Properties

Accessors

Methods

_init add_mark add_selection_clipboard apply_tag apply_tag_by_name backspace begin_user_action connect connect_after copy_clipboard create_child_anchor create_mark cut_clipboard delete delete_interactive delete_mark delete_mark_by_name delete_selection deserialize deserialize_get_can_create_tags deserialize_set_can_create_tags emit end_user_action get_bounds get_char_count get_copy_target_list get_deserialize_formats get_end_iter get_has_selection get_insert get_iter_at_child_anchor get_iter_at_line get_iter_at_line_index get_iter_at_line_offset get_iter_at_mark get_iter_at_offset get_line_count get_mark get_modified get_paste_target_list get_selection_bound get_selection_bounds get_serialize_formats get_slice get_start_iter get_tag_table get_text insert insert_at_cursor insert_child_anchor insert_interactive insert_interactive_at_cursor insert_markup insert_pixbuf insert_range insert_range_interactive move_mark move_mark_by_name paste_clipboard place_cursor register_deserialize_format register_deserialize_tagset register_serialize_format register_serialize_tagset remove_all_tags remove_selection_clipboard remove_tag remove_tag_by_name select_range serialize set_modified set_text unregister_deserialize_format unregister_serialize_format vfunc_apply_tag vfunc_begin_user_action vfunc_changed vfunc_delete_range vfunc_end_user_action vfunc_insert_child_anchor vfunc_insert_pixbuf vfunc_insert_text vfunc_mark_deleted vfunc_mark_set vfunc_modified_changed vfunc_paste_done vfunc_remove_tag new

Methods - Inherited from GObject

Constructors

Properties

Compile-time signal type information.

This instance property is generated only for TypeScript type checking. It is not defined at runtime and should not be accessed in JS code.

Accessors

  • get cursor_position(): number

    The position of the insert mark (as offset from the beginning of the buffer). It is useful for getting notified when the cursor moves.

    Returns number

    2.10

  • get cursorPosition(): number

    The position of the insert mark (as offset from the beginning of the buffer). It is useful for getting notified when the cursor moves.

    Returns number

    2.10

  • get has_selection(): boolean

    Whether the buffer has some text currently selected.

    Returns boolean

    2.10

  • get hasSelection(): boolean

    Whether the buffer has some text currently selected.

    Returns boolean

    2.10

  • get text(): string

    The text content of the buffer. Without child widgets and images, see gtk_text_buffer_get_text() for more information.

    Returns string

    2.8

  • set text(val: string): void

    Parameters

    • val: string

    Returns void

Methods

  • Adds the mark at position where. The mark must not be added to another buffer, and if its name is not null then there must not be another mark in the buffer with the same name.

    Emits the Gtk.TextBuffer.SignalSignatures.mark_set | Gtk.TextBuffer::mark-set signal as notification of the mark's initial placement.

    Parameters

    Returns void

  • Performs the appropriate action as if the user hit the delete key with the cursor at the position specified by iter. In the normal case a single character will be deleted, but when combining accents are involved, more than one character can be deleted, and when precomposed character and accent combinations are involved, less than one character will be deleted.

    Because the buffer is modified, all outstanding iterators become invalid after calling this function; however, the iter will be re-initialized to point to the location where text was deleted.

    Parameters

    • iter: Gtk.TextIter

      a position in buffer

    • interactive: boolean

      whether the deletion is caused by user interaction

    • default_editable: boolean

      whether the buffer is editable by default

    Returns boolean

    true if the buffer was modified

  • Called to indicate that the buffer operations between here and a call to gtk_text_buffer_end_user_action() are part of a single user-visible operation. The operations between gtk_text_buffer_begin_user_action() and gtk_text_buffer_end_user_action() can then be grouped when creating an undo stack. Gtk.TextBuffer maintains a count of calls to gtk_text_buffer_begin_user_action() that have not been closed with a call to gtk_text_buffer_end_user_action(), and emits the “begin-user-action” and “end-user-action” signals only for the outermost pair of calls. This allows you to build user actions from other user actions.

    The “interactive” buffer mutation functions, such as gtk_text_buffer_insert_interactive(), automatically call begin/end user action around the buffer operations they perform, so there's no need to add extra calls if you user action consists solely of a single call to one of those functions.

    Returns void

  • This is a convenience function which simply creates a child anchor with gtk_text_child_anchor_new() and inserts it into the buffer with gtk_text_buffer_insert_child_anchor(). The new anchor is owned by the buffer; no reference count is returned to the caller of gtk_text_buffer_create_child_anchor().

    Parameters

    Returns Gtk.TextChildAnchor

    the created child anchor

  • Creates a mark at position where. If mark_name is null, the mark is anonymous; otherwise, the mark can be retrieved by name using gtk_text_buffer_get_mark(). If a mark has left gravity, and text is inserted at the mark’s current location, the mark will be moved to the left of the newly-inserted text. If the mark has right gravity (left_gravity = false), the mark will end up on the right of newly-inserted text. The standard left-to-right cursor is a mark with right gravity (when you type, the cursor stays on the right side of the text you’re typing).

    The caller of this function does not own a reference to the returned Gtk.TextMark, so you can ignore the return value if you like. Marks are owned by the buffer and go away when the buffer does.

    Emits the Gtk.TextBuffer.SignalSignatures.mark_set | Gtk.TextBuffer::mark-set signal as notification of the mark's initial placement.

    Parameters

    • mark_name: string

      name for mark, or null

    • where: Gtk.TextIter

      location to place mark

    • left_gravity: boolean

      whether the mark has left gravity

    Returns Gtk.TextMark

    the new Gtk.TextMark object

  • Copies the currently-selected text to a clipboard, then deletes said text if it’s editable.

    Parameters

    Returns void

  • Deletes text between start and end. The order of start and end is not actually relevant; gtk_text_buffer_delete() will reorder them. This function actually emits the “delete-range” signal, and the default handler of that signal deletes the text. Because the buffer is modified, all outstanding iterators become invalid after calling this function; however, the start and end will be re-initialized to point to the location where text was deleted.

    Parameters

    Returns void

  • Deletes all editable text in the given range. Calls gtk_text_buffer_delete() for each editable sub-range of [start,end). start and end are revalidated to point to the location of the last deleted range, or left untouched if no text was deleted.

    Parameters

    • start_iter: Gtk.TextIter

      start of range to delete

    • end_iter: Gtk.TextIter

      end of range

    • default_editable: boolean

      whether the buffer is editable by default

    Returns boolean

    whether some text was actually deleted

  • Deletes mark, so that it’s no longer located anywhere in the buffer. Removes the reference the buffer holds to the mark, so if you haven’t called g_object_ref() on the mark, it will be freed. Even if the mark isn’t freed, most operations on mark become invalid, until it gets added to a buffer again with gtk_text_buffer_add_mark(). Use gtk_text_mark_get_deleted() to find out if a mark has been removed from its buffer. The Gtk.TextBuffer.SignalSignatures.mark_deleted | Gtk.TextBuffer::mark-deleted signal will be emitted as notification after the mark is deleted.

    Parameters

    Returns void

  • Deletes the mark named name; the mark must exist. See gtk_text_buffer_delete_mark() for details.

    Parameters

    • name: string

      name of a mark in buffer

    Returns void

  • Deletes the range between the “insert” and “selection_bound” marks, that is, the currently-selected text. If interactive is true, the editability of the selection will be considered (users can’t delete uneditable text).

    Parameters

    • interactive: boolean

      whether the deletion is caused by user interaction

    • default_editable: boolean

      whether the buffer is editable by default

    Returns boolean

    whether there was a non-empty selection to delete

  • This function deserializes rich text in format format and inserts it at iter.

    formats to be used must be registered using gtk_text_buffer_register_deserialize_format() or gtk_text_buffer_register_deserialize_tagset() beforehand.

    Parameters

    • content_buffer: Gtk.TextBuffer

      the Gtk.TextBuffer to deserialize into

    • format: Gdk.Atom

      the rich text format to use for deserializing

    • iter: Gtk.TextIter

      insertion point for the deserialized text

    • data: string | Uint8Array<ArrayBufferLike>

      data to deserialize

    Returns boolean

    true on success, false otherwise.

  • This functions returns the value set with gtk_text_buffer_deserialize_set_can_create_tags()

    Parameters

    Returns boolean

    whether deserializing this format may create tags

  • Use this function to allow a rich text deserialization function to create new tags in the receiving buffer. Note that using this function is almost always a bad idea, because the rich text functions you register should know how to map the rich text format they handler to your text buffers set of tags.

    The ability of creating new (arbitrary!) tags in the receiving buffer is meant for special rich text formats like the internal one that is registered using gtk_text_buffer_register_deserialize_tagset(), because that format is essentially a dump of the internal structure of the source buffer, including its tag names.

    You should allow creation of tags only if you know what you are doing, e.g. if you defined a tagset name for your application suite’s text buffers and you know that it’s fine to receive new tags from these buffers, because you know that your application can handle the newly created tags.

    Parameters

    • format: Gdk.Atom

      a Gdk.Atom representing a registered rich text format

    • can_create_tags: boolean

      whether deserializing this format may create tags

    Returns void

  • Should be paired with a call to gtk_text_buffer_begin_user_action(). See that function for a full explanation.

    Returns void

  • Gets the number of characters in the buffer; note that characters and bytes are not the same, you can’t e.g. expect the contents of the buffer in string form to be this many bytes long. The character count is cached, so this function is very fast.

    Returns number

    number of characters in the buffer

  • This function returns the rich text deserialize formats registered with buffer using gtk_text_buffer_register_deserialize_format() or gtk_text_buffer_register_deserialize_tagset()

    Returns Gdk.Atom[]

    an array of GdkAtoms representing the registered formats.

  • Initializes iter with the “end iterator,” one past the last valid character in the text buffer. If dereferenced with gtk_text_iter_get_char(), the end iterator has a character value of 0. The entire buffer lies in the range from the first position in the buffer (call gtk_text_buffer_get_start_iter() to get character position 0) to the end iterator.

    Returns Gtk.TextIter

  • Indicates whether the buffer has some text currently selected.

    Returns boolean

    true if the there is text selected

  • Returns the mark that represents the cursor (insertion point). Equivalent to calling gtk_text_buffer_get_mark() to get the mark named “insert”, but very slightly more efficient, and involves less typing.

    Returns Gtk.TextMark

    insertion point mark

  • Initializes iter to the start of the given line. If line_number is greater than the number of lines in the buffer, the end iterator is returned.

    Parameters

    • line_number: number

      line number counting from 0

    Returns Gtk.TextIter

  • Obtains an iterator pointing to byte_index within the given line. byte_index must be the start of a UTF-8 character. Note bytes, not characters; UTF-8 may encode one character as multiple bytes.

    Before the 3.20 version, it was not allowed to pass an invalid location.

    Since the 3.20 version, if line_number is greater than the number of lines in the buffer, the end iterator is returned. And if byte_index is off the end of the line, the iterator at the end of the line is returned.

    Parameters

    • line_number: number

      line number counting from 0

    • byte_index: number

      byte index from start of line

    Returns Gtk.TextIter

  • Obtains an iterator pointing to char_offset within the given line. Note characters, not bytes; UTF-8 may encode one character as multiple bytes.

    Before the 3.20 version, it was not allowed to pass an invalid location.

    Since the 3.20 version, if line_number is greater than the number of lines in the buffer, the end iterator is returned. And if char_offset is off the end of the line, the iterator at the end of the line is returned.

    Parameters

    • line_number: number

      line number counting from 0

    • char_offset: number

      char offset from start of line

    Returns Gtk.TextIter

  • Initializes iter to a position char_offset chars from the start of the entire buffer. If char_offset is -1 or greater than the number of characters in the buffer, iter is initialized to the end iterator, the iterator one past the last valid character in the buffer.

    Parameters

    • char_offset: number

      char offset from start of buffer, counting from 0, or -1

    Returns Gtk.TextIter

  • Obtains the number of lines in the buffer. This value is cached, so the function is very fast.

    Returns number

    number of lines in the buffer

  • Indicates whether the buffer has been modified since the last call to gtk_text_buffer_set_modified() set the modification flag to false. Used for example to enable a “save” function in a text editor.

    Returns boolean

    true if the buffer has been modified

  • Returns the mark that represents the selection bound. Equivalent to calling gtk_text_buffer_get_mark() to get the mark named “selection_bound”, but very slightly more efficient, and involves less typing.

    The currently-selected text in buffer is the region between the “selection_bound” and “insert” marks. If “selection_bound” and “insert” are in the same place, then there is no current selection. gtk_text_buffer_get_selection_bounds() is another convenient function for handling the selection, if you just want to know whether there’s a selection and what its bounds are.

    Returns Gtk.TextMark

    selection bound mark

  • Returns true if some text is selected; places the bounds of the selection in start and end (if the selection has length 0, then start and end are filled in with the same value). start and end will be in ascending order. If start and end are NULL, then they are not filled in, but the return value still indicates whether text is selected.

    Returns [boolean, Gtk.TextIter, Gtk.TextIter]

    whether the selection has nonzero length

  • This function returns the rich text serialize formats registered with buffer using gtk_text_buffer_register_serialize_format() or gtk_text_buffer_register_serialize_tagset()

    Returns Gdk.Atom[]

    an array of GdkAtoms representing the registered formats.

  • Returns the text in the range [start,end). Excludes undisplayed text (text marked with tags that set the invisibility attribute) if include_hidden_chars is false. The returned string includes a 0xFFFC character whenever the buffer contains embedded images, so byte and character indexes into the returned string do correspond to byte and character indexes into the buffer. Contrast with gtk_text_buffer_get_text(). Note that 0xFFFC can occur in normal text as well, so it is not a reliable indicator that a pixbuf or widget is in the buffer.

    Parameters

    • start: Gtk.TextIter

      start of a range

    • end: Gtk.TextIter

      end of a range

    • include_hidden_chars: boolean

      whether to include invisible text

    Returns string

    an allocated UTF-8 string

  • Initialized iter with the first position in the text buffer. This is the same as using gtk_text_buffer_get_iter_at_offset() to get the iter at character offset 0.

    Returns Gtk.TextIter

  • Returns the text in the range [start,end). Excludes undisplayed text (text marked with tags that set the invisibility attribute) if include_hidden_chars is false. Does not include characters representing embedded images, so byte and character indexes into the returned string do not correspond to byte and character indexes into the buffer. Contrast with gtk_text_buffer_get_slice().

    Parameters

    • start: Gtk.TextIter

      start of a range

    • end: Gtk.TextIter

      end of a range

    • include_hidden_chars: boolean

      whether to include invisible text

    Returns string

    an allocated UTF-8 string

  • Inserts len bytes of text at position iter. If len is -1, text must be nul-terminated and will be inserted in its entirety. Emits the “insert-text” signal; insertion actually occurs in the default handler for the signal. iter is invalidated when insertion occurs (because the buffer contents change), but the default signal handler revalidates it to point to the end of the inserted text.

    Parameters

    • iter: Gtk.TextIter

      a position in the buffer

    • text: string

      text in UTF-8 format

    • len: number

      length of text in bytes, or -1

    Returns void

  • Simply calls gtk_text_buffer_insert(), using the current cursor position as the insertion point.

    Parameters

    • text: string

      text in UTF-8 format

    • len: number

      length of text, in bytes

    Returns void

  • Inserts a child widget anchor into the text buffer at iter. The anchor will be counted as one character in character counts, and when obtaining the buffer contents as a string, will be represented by the Unicode “object replacement character” 0xFFFC. Note that the “slice” variants for obtaining portions of the buffer as a string include this character for child anchors, but the “text” variants do not. E.g. see gtk_text_buffer_get_slice() and gtk_text_buffer_get_text(). Consider gtk_text_buffer_create_child_anchor() as a more convenient alternative to this function. The buffer will add a reference to the anchor, so you can unref it after insertion.

    Parameters

    Returns void

  • Like gtk_text_buffer_insert(), but the insertion will not occur if iter is at a non-editable location in the buffer. Usually you want to prevent insertions at ineditable locations if the insertion results from a user action (is interactive).

    default_editable indicates the editability of text that doesn't have a tag affecting editability applied to it. Typically the result of gtk_text_view_get_editable() is appropriate here.

    Parameters

    • iter: Gtk.TextIter

      a position in buffer

    • text: string

      some UTF-8 text

    • len: number

      length of text in bytes, or -1

    • default_editable: boolean

      default editability of buffer

    Returns boolean

    whether text was actually inserted

  • Calls gtk_text_buffer_insert_interactive() at the cursor position.

    default_editable indicates the editability of text that doesn't have a tag affecting editability applied to it. Typically the result of gtk_text_view_get_editable() is appropriate here.

    Parameters

    • text: string

      text in UTF-8 format

    • len: number

      length of text in bytes, or -1

    • default_editable: boolean

      default editability of buffer

    Returns boolean

    whether text was actually inserted

  • Inserts the text in markup at position iter. markup will be inserted in its entirety and must be nul-terminated and valid UTF-8. Emits the Gtk.TextBuffer.SignalSignatures.insert_text | Gtk.TextBuffer::insert-text signal, possibly multiple times; insertion actually occurs in the default handler for the signal. iter will point to the end of the inserted text on return.

    Parameters

    • iter: Gtk.TextIter

      location to insert the markup

    • markup: string

      a nul-terminated UTF-8 string containing [Pango markup][PangoMarkupFormat]

    • len: number

      length of markup in bytes, or -1

    Returns void

  • Inserts an image into the text buffer at iter. The image will be counted as one character in character counts, and when obtaining the buffer contents as a string, will be represented by the Unicode “object replacement character” 0xFFFC. Note that the “slice” variants for obtaining portions of the buffer as a string include this character for pixbufs, but the “text” variants do not. e.g. see gtk_text_buffer_get_slice() and gtk_text_buffer_get_text().

    Parameters

    Returns void

  • Copies text, tags, and pixbufs between start and end (the order of start and end doesn’t matter) and inserts the copy at iter. Used instead of simply getting/inserting text because it preserves images and tags. If start and end are in a different buffer from buffer, the two buffers must share the same tag table.

    Implemented via emissions of the insert_text and apply_tag signals, so expect those.

    Parameters

    Returns void

  • Same as gtk_text_buffer_insert_range(), but does nothing if the insertion point isn’t editable. The default_editable parameter indicates whether the text is editable at iter if no tags enclosing iter affect editability. Typically the result of gtk_text_view_get_editable() is appropriate here.

    Parameters

    Returns boolean

    whether an insertion was possible at iter

  • Moves the mark named name (which must exist) to location where. See gtk_text_buffer_move_mark() for details.

    Parameters

    • name: string

      name of a mark

    • where: Gtk.TextIter

      new location for mark

    Returns void

  • Pastes the contents of a clipboard. If override_location is null, the pasted text will be inserted at the cursor position, or the buffer selection will be replaced if the selection is non-empty.

    Note: pasting is asynchronous, that is, we’ll ask for the paste data and return, and at some point later after the main loop runs, the paste data will be inserted.

    Parameters

    • clipboard: Gtk.Clipboard

      the Gtk.Clipboard to paste from

    • override_location: Gtk.TextIter

      location to insert pasted text, or null

    • default_editable: boolean

      whether the buffer is editable by default

    Returns void

  • This function moves the “insert” and “selection_bound” marks simultaneously. If you move them to the same place in two steps with gtk_text_buffer_move_mark(), you will temporarily select a region in between their old and new locations, which can be pretty inefficient since the temporarily-selected region will force stuff to be recalculated. This function moves them as a unit, which can be optimized.

    Parameters

    Returns void

  • This function registers GTK+’s internal rich text serialization format with the passed buffer. See gtk_text_buffer_register_serialize_tagset() for details.

    Parameters

    • Optionaltagset_name: string

      an optional tagset name, on null

    Returns Gdk.Atom

    the Gdk.Atom that corresponds to the newly registered format’s mime-type.

  • This function registers GTK+’s internal rich text serialization format with the passed buffer. The internal format does not comply to any standard rich text format and only works between Gtk.TextBuffer instances. It is capable of serializing all of a text buffer’s tags and embedded pixbufs.

    This function is just a wrapper around gtk_text_buffer_register_serialize_format(). The mime type used for registering is “application/x-gtk-text-buffer-rich-text”, or “application/x-gtk-text-buffer-rich-text;format=tagset_name” if a tagset_name was passed.

    The tagset_name can be used to restrict the transfer of rich text to buffers with compatible sets of tags, in order to avoid unknown tags from being pasted. It is probably the common case to pass an identifier != null here, since the null tagset requires the receiving buffer to deal with with pasting of arbitrary tags.

    Parameters

    • Optionaltagset_name: string

      an optional tagset name, on null

    Returns Gdk.Atom

    the Gdk.Atom that corresponds to the newly registered format’s mime-type.

  • Removes all tags in the range between start and end. Be careful with this function; it could remove tags added in code unrelated to the code you’re currently writing. That is, using this function is probably a bad idea if you have two or more unrelated code sections that add tags.

    Parameters

    Returns void

  • This function moves the “insert” and “selection_bound” marks simultaneously. If you move them in two steps with gtk_text_buffer_move_mark(), you will temporarily select a region in between their old and new locations, which can be pretty inefficient since the temporarily-selected region will force stuff to be recalculated. This function moves them as a unit, which can be optimized.

    Parameters

    • ins: Gtk.TextIter

      where to put the “insert” mark

    • bound: Gtk.TextIter

      where to put the “selection_bound” mark

    Returns void

  • This function serializes the portion of text between start and end in the rich text format represented by format.

    formats to be used must be registered using gtk_text_buffer_register_serialize_format() or gtk_text_buffer_register_serialize_tagset() beforehand.

    Parameters

    Returns Uint8Array

    the serialized data, encoded as format

  • Used to keep track of whether the buffer has been modified since the last time it was saved. Whenever the buffer is saved to disk, call gtk_text_buffer_set_modified (buffer, FALSE). When the buffer is modified, it will automatically toggled on the modified bit again. When the modified bit flips, the buffer emits the Gtk.TextBuffer.SignalSignatures.modified_changed | Gtk.TextBuffer::modified-changed signal.

    Parameters

    • setting: boolean

      modification flag setting

    Returns void

  • Deletes current contents of buffer, and inserts text instead. If len is -1, text must be nul-terminated. text must be valid UTF-8.

    Parameters

    • text: string

      UTF-8 text to insert

    • len: number

      length of text in bytes

    Returns void

  • This function unregisters a rich text format that was previously registered using gtk_text_buffer_register_deserialize_format() or gtk_text_buffer_register_deserialize_tagset().

    Parameters

    Returns void

  • This function unregisters a rich text format that was previously registered using gtk_text_buffer_register_serialize_format() or gtk_text_buffer_register_serialize_tagset()

    Parameters

    Returns void

  • Called to indicate that the buffer operations between here and a call to gtk_text_buffer_end_user_action() are part of a single user-visible operation. The operations between gtk_text_buffer_begin_user_action() and gtk_text_buffer_end_user_action() can then be grouped when creating an undo stack. Gtk.TextBuffer maintains a count of calls to gtk_text_buffer_begin_user_action() that have not been closed with a call to gtk_text_buffer_end_user_action(), and emits the “begin-user-action” and “end-user-action” signals only for the outermost pair of calls. This allows you to build user actions from other user actions.

    The “interactive” buffer mutation functions, such as gtk_text_buffer_insert_interactive(), automatically call begin/end user action around the buffer operations they perform, so there's no need to add extra calls if you user action consists solely of a single call to one of those functions.

    Returns void

  • Should be paired with a call to gtk_text_buffer_begin_user_action(). See that function for a full explanation.

    Returns void

  • Inserts a child widget anchor into the text buffer at iter. The anchor will be counted as one character in character counts, and when obtaining the buffer contents as a string, will be represented by the Unicode “object replacement character” 0xFFFC. Note that the “slice” variants for obtaining portions of the buffer as a string include this character for child anchors, but the “text” variants do not. E.g. see gtk_text_buffer_get_slice() and gtk_text_buffer_get_text(). Consider gtk_text_buffer_create_child_anchor() as a more convenient alternative to this function. The buffer will add a reference to the anchor, so you can unref it after insertion.

    Parameters

    Returns void

  • Inserts an image into the text buffer at iter. The image will be counted as one character in character counts, and when obtaining the buffer contents as a string, will be represented by the Unicode “object replacement character” 0xFFFC. Note that the “slice” variants for obtaining portions of the buffer as a string include this character for pixbufs, but the “text” variants do not. e.g. see gtk_text_buffer_get_slice() and gtk_text_buffer_get_text().

    Parameters

    Returns void

  • The class handler for the Gtk.TextBuffer.SignalSignatures.insert_text | Gtk.TextBuffer::insert-text signal.

    Parameters

    • pos: Gtk.TextIter
    • new_text: string
    • new_text_length: number

    Returns void

  • The class handler for the Gtk.TextBuffer.SignalSignatures.modified_changed | Gtk.TextBuffer::modified-changed signal.

    Returns void

Methods - Inherited from GObject

  • Creates a binding between source_property on source and target_property on target.

    Whenever the source_property is changed the target_property is updated using the same value. For instance:

      g_object_bind_property (action, "active", widget, "sensitive", 0);
    

    Will result in the "sensitive" property of the widget GObject.Object instance to be updated with the same value of the "active" property of the action GObject.Object instance.

    If flags contains GObject.BindingFlags.BIDIRECTIONAL then the binding will be mutual: if target_property on target changes then the source_property on source will be updated as well.

    The binding will automatically be removed when either the source or the target instances are finalized. To remove the binding without affecting the source and the target you can just call g_object_unref() on the returned GObject.Binding instance.

    Removing the binding by calling g_object_unref() on it must only be done if the binding, source and target are only used from a single thread and it is clear that both source and target outlive the binding. Especially it is not safe to rely on this if the binding, source or target can be finalized from different threads. Keep another reference to the binding and use g_binding_unbind() instead to be on the safe side.

    A GObject.Object can have multiple bindings.

    Parameters

    Returns GObject.Binding

    the GObject.Binding instance representing the binding between the two GObject.Object instances. The binding is released whenever the GObject.Binding reference count reaches zero.

  • Complete version of g_object_bind_property().

    Creates a binding between source_property on source and target_property on target, allowing you to set the transformation functions to be used by the binding.

    If flags contains GObject.BindingFlags.BIDIRECTIONAL then the binding will be mutual: if target_property on target changes then the source_property on source will be updated as well. The transform_from function is only used in case of bidirectional bindings, otherwise it will be ignored

    The binding will automatically be removed when either the source or the target instances are finalized. This will release the reference that is being held on the GObject.Binding instance; if you want to hold on to the GObject.Binding instance, you will need to hold a reference to it.

    To remove the binding, call g_binding_unbind().

    A GObject.Object can have multiple bindings.

    The same user_data parameter will be used for both transform_to and transform_from transformation functions; the notify function will be called once, when the binding is removed. If you need different data for each transformation function, please use g_object_bind_property_with_closures() instead.

    Parameters

    • source_property: string

      the property on source to bind

    • target: GObject.Object

      the target GObject.Object

    • target_property: string

      the property on target to bind

    • flags: GObject.BindingFlags

      flags to pass to GObject.Binding

    • Optionaltransform_to: BindingTransformFunc

      the transformation function from the source to the target, or null to use the default

    • Optionaltransform_from: BindingTransformFunc

      the transformation function from the target to the source, or null to use the default

    • Optionalnotify: DestroyNotify

      a function to call when disposing the binding, to free resources used by the transformation functions, or null if not required

    Returns GObject.Binding

    the GObject.Binding instance representing the binding between the two GObject.Object instances. The binding is released whenever the GObject.Binding reference count reaches zero.

  • Creates a binding between source_property on source and target_property on target, allowing you to set the transformation functions to be used by the binding.

    This function is the language bindings friendly version of g_object_bind_property_full(), using GClosures instead of function pointers.

    Parameters

    Returns GObject.Binding

    the GObject.Binding instance representing the binding between the two GObject.Object instances. The binding is released whenever the GObject.Binding reference count reaches zero.

  • Disconnects a handler from an instance so it will not be called during any future or currently ongoing emissions of the signal it has been connected to.

    Parameters

    • id: number

      Handler ID of the handler to be disconnected

    Returns void

  • This function is intended for GObject.Object implementations to re-enforce a [floating][floating-ref] object reference. Doing this is seldom required: all GInitiallyUnowneds are created with a floating reference which usually just needs to be sunken by calling g_object_ref_sink().

    Returns void

  • Increases the freeze count on object. If the freeze count is non-zero, the emission of "notify" signals on object is stopped. The signals are queued until the freeze count is decreased to zero. Duplicate notifications are squashed so that at most one GObject.Object::notify signal is emitted for each property modified while the object is frozen.

    This is necessary for accessors that modify multiple properties to prevent premature notification while the object is still being modified.

    Returns void

  • Gets a named field from the objects table of associations (see g_object_set_data()).

    Parameters

    • key: string

      name of the key for that association

    Returns any

    the data if found, or null if no such data exists.

  • Gets a property of an object.

    The value can be:

    • an empty GObject.Value initialized by G_VALUE_INIT, which will be automatically initialized with the expected type of the property (since GLib 2.60)
    • a GObject.Value initialized with the expected type of the property
    • a GObject.Value initialized with a type to which the expected type of the property can be transformed

    In general, a copy is made of the property contents and the caller is responsible for freeing the memory by calling GObject.Value.unset.

    Note that GObject.Object.get_property is really intended for language bindings, GObject.Object.get is much more convenient for C programming.

    Parameters

    • property_name: string

      The name of the property to get

    • value: any

      Return location for the property value. Can be an empty GObject.Value initialized by G_VALUE_INIT (auto-initialized with expected type since GLib 2.60), a GObject.Value initialized with the expected property type, or a GObject.Value initialized with a transformable type

    Returns any

  • This function gets back user data pointers stored via g_object_set_qdata().

    Parameters

    • quark: number

      A GLib.Quark, naming the user data pointer

    Returns any

    The user data pointer set, or null

  • Gets n_properties properties for an object. Obtained properties will be set to values. All properties must be valid. Warnings will be emitted and undefined behaviour may result if invalid properties are passed in.

    Parameters

    • names: string[]

      the names of each property to get

    • values: any[]

      the values of each property to get

    Returns void

  • Emits a "notify" signal for the property property_name on object.

    When possible, eg. when signaling a property change from within the class that registered the property, you should use g_object_notify_by_pspec() instead.

    Note that emission of the notify signal may be blocked with g_object_freeze_notify(). In this case, the signal emissions are queued and will be emitted (in reverse order) when g_object_thaw_notify() is called.

    Parameters

    • property_name: string

      the name of a property installed on the class of object.

    Returns void

  • Emits a "notify" signal for the property specified by pspec on object.

    This function omits the property name lookup, hence it is faster than g_object_notify().

    One way to avoid using g_object_notify() from within the class that registered the properties, and using g_object_notify_by_pspec() instead, is to store the GParamSpec used with g_object_class_install_property() inside a static array, e.g.:

      typedef enum
    {
    PROP_FOO = 1,
    PROP_LAST
    } MyObjectProperty;

    static GParamSpec *properties[PROP_LAST];

    static void
    my_object_class_init (MyObjectClass *klass)
    {
    properties[PROP_FOO] = g_param_spec_int ("foo", NULL, NULL,
    0, 100,
    50,
    G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
    g_object_class_install_property (gobject_class,
    PROP_FOO,
    properties[PROP_FOO]);
    }

    and then notify a change on the "foo" property with:

      g_object_notify_by_pspec (self, properties[PROP_FOO]);
    

    Parameters

    Returns void

  • Increases the reference count of object.

    Since GLib 2.56, if GLIB_VERSION_MAX_ALLOWED is 2.56 or greater, the type of object will be propagated to the return type (using the GCC typeof() extension), so any casting the caller needs to do on the return type must be explicit.

    Returns GObject.Object

    the same object

  • Increase the reference count of object, and possibly remove the [floating][floating-ref] reference, if object has a floating reference.

    In other words, if the object is floating, then this call "assumes ownership" of the floating reference, converting it to a normal reference by clearing the floating flag while leaving the reference count unchanged. If the object is not floating, then this call adds a new normal reference increasing the reference count by one.

    Since GLib 2.56, the type of object will be propagated to the return type under the same conditions as for g_object_ref().

    Returns GObject.Object

    object

  • Releases all references to other objects. This can be used to break reference cycles.

    This function should only be called from object system implementations.

    Returns void

  • Sets multiple properties of an object at once. The properties argument should be a dictionary mapping property names to values.

    Parameters

    • properties: { [key: string]: any }

      Object containing the properties to set

    Returns void

  • Each object carries around a table of associations from strings to pointers. This function lets you set an association.

    If the object already had an association with that name, the old association will be destroyed.

    Internally, the key is converted to a GLib.Quark using g_quark_from_string(). This means a copy of key is kept permanently (even after object has been finalized) — so it is recommended to only use a small, bounded set of values for key in your program, to avoid the GLib.Quark storage growing unbounded.

    Parameters

    • key: string

      name of the key

    • Optionaldata: any

      data to associate with that key

    Returns void

  • Sets a property on an object.

    Parameters

    • property_name: string

      The name of the property to set

    • value: any

      The value to set the property to

    Returns void

  • Remove a specified datum from the object's data associations, without invoking the association's destroy handler.

    Parameters

    • key: string

      name of the key

    Returns any

    the data if found, or null if no such data exists.

  • This function gets back user data pointers stored via g_object_set_qdata() and removes the data from object without invoking its destroy() function (if any was set). Usually, calling this function is only required to update user data pointers with a destroy notifier, for example:

    void
    object_add_to_user_list (GObject *object,
    const gchar *new_string)
    {
    // the quark, naming the object data
    GQuark quark_string_list = g_quark_from_static_string ("my-string-list");
    // retrieve the old string list
    GList *list = g_object_steal_qdata (object, quark_string_list);

    // prepend new string
    list = g_list_prepend (list, g_strdup (new_string));
    // this changed 'list', so we need to set it again
    g_object_set_qdata_full (object, quark_string_list, list, free_string_list);
    }
    static void
    free_string_list (gpointer data)
    {
    GList *node, *list = data;

    for (node = list; node; node = node->next)
    g_free (node->data);
    g_list_free (list);
    }

    Using g_object_get_qdata() in the above example, instead of g_object_steal_qdata() would have left the destroy function set, and thus the partial string list would have been freed upon g_object_set_qdata_full().

    Parameters

    • quark: number

      A GLib.Quark, naming the user data pointer

    Returns any

    The user data pointer set, or null

  • Stops a signal's emission by the given signal name. This will prevent the default handler and any subsequent signal handlers from being invoked.

    Parameters

    • detailedName: string

      Name of the signal to stop emission of

    Returns void

  • Reverts the effect of a previous call to g_object_freeze_notify(). The freeze count is decreased on object and when it reaches zero, queued "notify" signals are emitted.

    Duplicate notifications for each property are squashed so that at most one GObject.Object::notify signal is emitted for each property, in the reverse order in which they have been queued.

    It is an error to call this function when the freeze count is zero.

    Returns void

  • Decreases the reference count of object. When its reference count drops to 0, the object is finalized (i.e. its memory is freed).

    If the pointer to the GObject.Object may be reused in future (for example, if it is an instance variable of another object), it is recommended to clear the pointer to null rather than retain a dangling pointer to a potentially invalid GObject.Object instance. Use g_clear_object() for this.

    Returns void

  • the constructed function is called by g_object_new() as the final step of the object creation process. At the point of the call, all construction properties have been set on the object. The purpose of this call is to allow for object initialisation steps that can only be performed after construction properties have been set. constructed implementors should chain up to the constructed call of their parent class to allow it to complete its initialisation.

    Returns void

  • the dispose function is supposed to drop all references to other objects, but keep the instance otherwise intact, so that client method invocations still work. It may be run multiple times (due to reference loops). Before returning, dispose should chain up to the dispose method of the parent class.

    Returns void

  • instance finalization function, should finish the finalization of the instance begun in dispose and chain up to the finalize method of the parent class.

    Returns void

  • Emits a "notify" signal for the property property_name on object.

    When possible, eg. when signaling a property change from within the class that registered the property, you should use g_object_notify_by_pspec() instead.

    Note that emission of the notify signal may be blocked with g_object_freeze_notify(). In this case, the signal emissions are queued and will be emitted (in reverse order) when g_object_thaw_notify() is called.

    Parameters

    Returns void

  • the generic setter for all properties of this type. Should be overridden for every type with properties. If implementations of set_property don't emit property change notification explicitly, this will be done implicitly by the type system. However, if the notify signal is emitted explicitly, the type system will not emit it a second time.

    Parameters

    Returns void

  • This function essentially limits the life time of the closure to the life time of the object. That is, when the object is finalized, the closure is invalidated by calling g_closure_invalidate() on it, in order to prevent invocations of the closure with a finalized (nonexisting) object. Also, g_object_ref() and g_object_unref() are added as marshal guards to the closure, to ensure that an extra reference count is held on object during invocation of the closure. Usually, this function will be called on closures that use this object as closure data.

    Parameters

    Returns void

  • Add a property to an interface; this is only useful for interfaces that are added to GObject-derived types. Adding a property to an interface forces all objects classes with that interface to have a compatible property. The compatible property could be a newly created GObject.ParamSpec, but normally g_object_class_override_property() will be used so that the object class only needs to provide an implementation and inherits the property description, default value, bounds, and so forth from the interface property.

    This function is meant to be called from the interface's default vtable initialization function (the class_init member of GObject.TypeInfo.) It must not be called after after class_init has been called for any object types implementing this interface.

    If pspec is a floating reference, it will be consumed.

    Parameters

    Returns void

  • Parameters

    • property_id: number

      the new property ID

    • name: string

      the name of a property registered in a parent class or in an interface of this class.

    Returns void

Interfaces

ConstructorProps
SignalSignatures