:right-sidebar: True FileLoader =================================================================== .. currentmodule:: gi.repository.GtkSource .. class:: FileLoader(**properties: ~typing.Any) :no-contents-entry: Superclasses: :class:`~gi.repository.GObject.Object` :Constructors: :: FileLoader(**properties) new(buffer:GtkSource.Buffer, file:GtkSource.File) -> GtkSource.FileLoader new_from_stream(buffer:GtkSource.Buffer, file:GtkSource.File, stream:Gio.InputStream) -> GtkSource.FileLoader Constructors ------------ .. rst-class:: interim-class .. class:: FileLoader :no-index: .. classmethod:: new(buffer: ~gi.repository.GtkSource.Buffer, file: ~gi.repository.GtkSource.File) -> ~gi.repository.GtkSource.FileLoader Creates a new ``GtkSourceFileLoader`` object. The contents is read from the :obj:`~gi.repository.GtkSource.File`'s location. If not already done, call :obj:`~gi.repository.File.set_location` before calling this constructor. The previous location is anyway not needed, because as soon as the file loading begins, the ``buffer`` is emptied. :param buffer: the :obj:`~gi.repository.GtkSource.Buffer` to load the contents into. :param file: the :obj:`~gi.repository.GtkSource.File`. .. classmethod:: new_from_stream(buffer: ~gi.repository.GtkSource.Buffer, file: ~gi.repository.GtkSource.File, stream: ~gi.repository.Gio.InputStream) -> ~gi.repository.GtkSource.FileLoader Creates a new :obj:`~gi.repository.GtkSource.FileLoader` object. The contents is read from ``stream``. :param buffer: the :obj:`~gi.repository.GtkSource.Buffer` to load the contents into. :param file: the :obj:`~gi.repository.GtkSource.File`. :param stream: the :obj:`~gi.repository.Gio.InputStream` to load, e.g. stdin. Methods ------- .. rst-class:: interim-class .. class:: FileLoader :no-index: .. method:: get_buffer() -> ~gi.repository.GtkSource.Buffer .. method:: get_compression_type() -> ~gi.repository.GtkSource.CompressionType .. method:: get_encoding() -> ~gi.repository.GtkSource.Encoding .. method:: get_file() -> ~gi.repository.GtkSource.File .. method:: get_input_stream() -> ~gi.repository.Gio.InputStream | None .. method:: get_location() -> ~gi.repository.Gio.File | None .. method:: get_newline_type() -> ~gi.repository.GtkSource.NewlineType .. method:: load_async(io_priority: int, cancellable: ~gi.repository.Gio.Cancellable | None = None, progress_callback: ~typing.Callable[[...], None] | None = None, callback: ~typing.Callable[[...], None] | None = None, *user_data: ~typing.Any) -> None Loads asynchronously the file or input stream contents into the :obj:`~gi.repository.GtkSource.Buffer`. See the :obj:`~gi.repository.Gio.AsyncResult` documentation to know how to use this function. :param io_priority: the I/O priority of the request. E.g. ``%G_PRIORITY_LOW``, ``%G_PRIORITY_DEFAULT`` or ``%G_PRIORITY_HIGH``. :param cancellable: optional :obj:`~gi.repository.Gio.Cancellable` object, :const:`None` to ignore. :param progress_callback: function to call back with progress information, or :const:`None` if progress information is not needed. :param callback: a :obj:`~gi.repository.Gio.AsyncReadyCallback` to call when the request is satisfied. :param user_data: user data to pass to ``callback``. .. method:: load_finish(result: ~gi.repository.Gio.AsyncResult) -> bool Finishes a file loading started with :obj:`~gi.repository.FileLoader.load_async`. If the contents has been loaded, the following :obj:`~gi.repository.GtkSource.File` properties will be updated: the location, the encoding, the newline type and the compression type. :param result: a :obj:`~gi.repository.Gio.AsyncResult`. .. method:: set_candidate_encodings(candidate_encodings: list[~gi.repository.GtkSource.Encoding]) -> None Sets the candidate encodings for the file loading. The encodings are tried in the same order as the list. For convenience, ``candidate_encodings`` can contain duplicates. Only the first occurrence of a duplicated encoding is kept in the list. By default the candidate encodings are (in that order in the list): 1. If set, the :obj:`~gi.repository.GtkSource.File`'s encoding as returned by :obj:`~gi.repository.File.get_encoding`. 2. The default candidates as returned by :obj:`~gi.repository.Encoding.get_default_candidates`. :param candidate_encodings: a list of :obj:`~gi.repository.GtkSource.Encoding`s. Properties ---------- .. rst-class:: interim-class .. class:: FileLoader :no-index: .. attribute:: props.buffer :type: ~gi.repository.GtkSource.Buffer The :obj:`~gi.repository.GtkSource.Buffer` to load the contents into. The :obj:`~gi.repository.GtkSource.FileLoader` object has a weak reference to the buffer. .. attribute:: props.file :type: ~gi.repository.GtkSource.File The :obj:`~gi.repository.GtkSource.File`. The :obj:`~gi.repository.GtkSource.FileLoader` object has a weak reference to the file. .. attribute:: props.input_stream :type: ~gi.repository.Gio.InputStream The :obj:`~gi.repository.Gio.InputStream` to load. Useful for reading stdin. If this property is set, the :obj:`~gi.repository.GtkSource.FileLoader`:location property is ignored. .. attribute:: props.location :type: ~gi.repository.Gio.File The :obj:`~gi.repository.Gio.File` to load. If the :obj:`~gi.repository.GtkSource.FileLoader`:input-stream is :const:`None`, by default the location is taken from the :obj:`~gi.repository.GtkSource.File` at construction time.