GtkSource.FileLoader¶
- Subclasses:
None
Methods¶
- Inherited:
- Structs:
class |
|
class |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Virtual Methods¶
- Inherited:
Properties¶
Name |
Type |
Flags |
Short Description |
|---|---|---|---|
r/w/co |
|||
r/w/co |
|||
r/w/co |
|||
r/w/co |
Signals¶
- Inherited:
Fields¶
- Inherited:
Class Details¶
- class GtkSource.FileLoader(**kwargs)¶
- Bases:
- Abstract:
No
- Structure:
Load a file into a
GtkSource.Buffer.A
GtkSourceFileLoaderobject permits to load the contents of a [iface`Gio`.File] or a [class`Gio`.InputStream] into a [class`Buffer`].A file loader should be used only for one load operation, including errors handling. If an error occurs, you can reconfigure the loader and relaunch the operation with [method`FileLoader`.load_async].
Running a
GtkSourceFileLoaderis an undoable action for the [class`Buffer`].After a file loading, the buffer is reset to the contents provided by the [iface`Gio`.File] or [class`Gio`.InputStream], so the buffer is set as “unmodified”, that is, [method`Gtk`.TextBuffer.set_modified] is called with
False. If the contents isn’t saved somewhere (for example if you load from stdin), then you should probably call [method`Gtk`.TextBuffer.set_modified] withTrueafter calling [method`FileLoader`.load_finish].- classmethod new(buffer, file)¶
- Parameters:
buffer (
GtkSource.Buffer) – theGtkSource.Bufferto load the contents into.file (
GtkSource.File) – theGtkSource.File.
- Returns:
a new
GtkSource.FileLoaderobject.- Return type:
Creates a new
GtkSourceFileLoaderobject. The contents is read from the [class`File`]’s location.If not already done, call [method`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.
- classmethod new_from_stream(buffer, file, stream)¶
- Parameters:
buffer (
GtkSource.Buffer) – theGtkSource.Bufferto load the contents into.file (
GtkSource.File) – theGtkSource.File.stream (
Gio.InputStream) – theGio.InputStreamto load, e.g. stdin.
- Returns:
a new
GtkSource.FileLoaderobject.- Return type:
Creates a new
GtkSource.FileLoaderobject. The contents is read from stream.
- get_buffer()¶
- Returns:
the
GtkSource.Bufferto load the contents into.- Return type:
- get_compression_type()¶
- Returns:
the detected compression type.
- Return type:
- get_encoding()¶
- Returns:
the detected file encoding.
- Return type:
- get_file()¶
- Returns:
the
GtkSource.File.- Return type:
- get_input_stream()¶
- Returns:
the
Gio.InputStreamto load, orNoneif aGio.Fileis used.- Return type:
- get_location()¶
- get_newline_type()¶
- Returns:
the detected newline type.
- Return type:
- load_async(io_priority, cancellable, progress_callback, progress_callback_data, callback, *user_data)¶
- Parameters:
io_priority (
int) – the I/O priority of the request. E.g.GLib.PRIORITY_LOW,GLib.PRIORITY_DEFAULTorGLib.PRIORITY_HIGH.cancellable (
Gio.CancellableorNone) – optionalGio.Cancellableobject,Noneto ignore.progress_callback (
Gio.FileProgressCallbackorNone) – function to call back with progress information, orNoneif progress information is not needed.progress_callback_data (
objectorNone) – user data to pass to progress_callback.callback (
Gio.AsyncReadyCallbackorNone) – aGio.AsyncReadyCallbackto call when the request is satisfied.
Loads asynchronously the file or input stream contents into the [class`Buffer`].
See the [iface`Gio`.AsyncResult] documentation to know how to use this function.
- load_finish(result)¶
- Parameters:
result (
Gio.AsyncResult) – aGio.AsyncResult.- Raises:
- Returns:
whether the contents has been loaded successfully.
- Return type:
Finishes a file loading started with [method`FileLoader`.load_async].
If the contents has been loaded, the following [class`File`] properties will be updated: the location, the encoding, the newline type and the compression type.
- set_candidate_encodings(candidate_encodings)¶
- Parameters:
candidate_encodings ([
GtkSource.Encoding]) – a list ofGtkSource.Encodings.
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):
If set, the [class`File`]’s encoding as returned by [method`File`.get_encoding].
The default candidates as returned by [func`Encoding`.get_default_candidates].
Property Details¶
- GtkSource.FileLoader.props.buffer¶
- Name:
buffer- Type:
- Default Value:
- Flags:
The
GtkSource.Bufferto load the contents into. TheGtkSource.FileLoaderobject has a weak reference to the buffer.
- GtkSource.FileLoader.props.file¶
- Name:
file- Type:
- Default Value:
- Flags:
The
GtkSource.File. TheGtkSource.FileLoaderobject has a weak reference to the file.
- GtkSource.FileLoader.props.input_stream¶
- Name:
input-stream- Type:
- Default Value:
- Flags:
The
Gio.InputStreamto load. Useful for reading stdin. If this property is set, theGtkSource.FileLoader:locationproperty is ignored.
- GtkSource.FileLoader.props.location¶
- Name:
location- Type:
- Default Value:
- Flags:
The
Gio.Fileto load. If theGtkSource.FileLoader:input-streamisNone, by default the location is taken from theGtkSource.Fileat construction time.