Top |
TeplFileLoaderTeplFileLoader — Load a file into a TeplBuffer |
A TeplFileLoader object permits to load the content of a GFile into a TeplBuffer.
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 tepl_file_loader_load_async()
.
Running a TeplFileLoader is an undoable action for the TeplBuffer. That is,
gtk_source_buffer_begin_not_undoable_action()
and
gtk_source_buffer_end_not_undoable_action()
are called, which delete the
undo/redo history.
After a file loading, the buffer is reset to the content provided by the
GFile, so the buffer is set as “unmodified”, that is,
gtk_text_buffer_set_modified()
is called with FALSE
.
TeplFileLoader * tepl_file_loader_new (TeplBuffer *buffer
,TeplFile *file
);
Creates a new TeplFileLoader object. The content is read from the TeplFile location.
If not already done, call tepl_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. Setting the TeplFile
location directly permits to update the UI, to display the good location when
the file is loading.
Since: 1.0
TeplBuffer *
tepl_file_loader_get_buffer (TeplFileLoader *loader
);
Since: 1.0
TeplFile *
tepl_file_loader_get_file (TeplFileLoader *loader
);
Since: 1.0
GFile *
tepl_file_loader_get_location (TeplFileLoader *loader
);
Since: 1.0
void tepl_file_loader_load_async (TeplFileLoader *loader
,gint io_priority
,GCancellable *cancellable
,GAsyncReadyCallback callback
,gpointer user_data
);
Loads asynchronously the file content into the TeplBuffer.
See the GAsyncResult documentation to know how to use this function.
loader |
||
io_priority |
the I/O priority of the request. E.g. |
|
cancellable |
optional GCancellable object, |
[nullable] |
callback |
a GAsyncReadyCallback to call when the request is satisfied. |
[scope async] |
user_data |
user data to pass to |
Since: 5.0
gboolean tepl_file_loader_load_finish (TeplFileLoader *loader
,GAsyncResult *result
,GError **error
);
Finishes a file loading started with tepl_file_loader_load_async()
.
Since: 1.0
“buffer”
property“buffer” TeplBuffer *
The TeplBuffer to load the content into. The TeplFileLoader object has a weak reference to the buffer.
Owner: TeplFileLoader
Flags: Read / Write / Construct Only
Since: 1.0
“file”
property“file” TeplFile *
The TeplFile. The TeplFileLoader object has a weak reference to the file.
Owner: TeplFileLoader
Flags: Read / Write / Construct Only
Since: 1.0