| Top |
| GtkSourceBuffer * | buffer | Read / Write / Construct Only |
| GtkSourceFile * | file | Read / Write / Construct Only |
| GInputStream * | input-stream | Read / Write / Construct Only |
| GFile * | location | Read / Write / Construct Only |
A GtkSourceFileLoader object permits to load the contents of a GFile or a GInputStream into a GtkSourceBuffer.
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 gtk_source_file_loader_load_async().
Running a GtkSourceFileLoader is an undoable action for the
GtkSourceBuffer. 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 contents provided by the
GFile or GInputStream, so the buffer is set as “unmodified”, that is,
gtk_text_buffer_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 gtk_text_buffer_set_modified() with TRUE after calling
gtk_source_file_loader_load_finish().
GtkSourceFileLoader * gtk_source_file_loader_new (GtkSourceBuffer *buffer,GtkSourceFile *file);
Creates a new GtkSourceFileLoader object. The contents is read from the
GtkSourceFile's location. If not already done, call
gtk_source_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.
Since: 3.14
GtkSourceFileLoader * gtk_source_file_loader_new_from_stream (GtkSourceBuffer *buffer,GtkSourceFile *file,GInputStream *stream);
Creates a new GtkSourceFileLoader object. The contents is read from stream
.
buffer |
the GtkSourceBuffer to load the contents into. |
|
file |
the GtkSourceFile. |
|
stream |
the GInputStream to load, e.g. stdin. |
Since: 3.14
void gtk_source_file_loader_set_candidate_encodings (GtkSourceFileLoader *loader,GSList *candidate_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 GtkSourceFile's encoding as returned by
gtk_source_file_get_encoding().
The default candidates as returned by
gtk_source_encoding_get_default_candidates().
loader |
||
candidate_encodings |
a list of GtkSourceEncodings. |
[element-type GtkSourceEncoding] |
Since: 3.14
GtkSourceBuffer *
gtk_source_file_loader_get_buffer (GtkSourceFileLoader *loader);
Since: 3.14
GtkSourceFile *
gtk_source_file_loader_get_file (GtkSourceFileLoader *loader);
Since: 3.14
GFile *
gtk_source_file_loader_get_location (GtkSourceFileLoader *loader);
Since: 3.14
GInputStream *
gtk_source_file_loader_get_input_stream
(GtkSourceFileLoader *loader);
Since: 3.14
void gtk_source_file_loader_load_async (GtkSourceFileLoader *loader,gint io_priority,GCancellable *cancellable,GFileProgressCallback progress_callback,gpointer progress_callback_data,GDestroyNotify progress_callback_notify,GAsyncReadyCallback callback,gpointer user_data);
Loads asynchronously the file or input stream contents into the GtkSourceBuffer. 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] |
progress_callback |
function to call back with
progress information, or |
[scope notified][nullable] |
progress_callback_data |
user data to pass to |
[closure] |
progress_callback_notify |
function to call on
|
[nullable] |
callback |
a GAsyncReadyCallback to call when the request is satisfied. |
[scope async] |
user_data |
user data to pass to |
Since: 3.14
gboolean gtk_source_file_loader_load_finish (GtkSourceFileLoader *loader,GAsyncResult *result,GError **error);
Finishes a file loading started with gtk_source_file_loader_load_async().
If the contents has been loaded, the following GtkSourceFile properties will be updated: the location, the encoding, the newline type and the compression type.
Since: 3.14
const GtkSourceEncoding *
gtk_source_file_loader_get_encoding (GtkSourceFileLoader *loader);
Since: 3.14
GtkSourceNewlineType
gtk_source_file_loader_get_newline_type
(GtkSourceFileLoader *loader);
Since: 3.14
GtkSourceCompressionType
gtk_source_file_loader_get_compression_type
(GtkSourceFileLoader *loader);
Since: 3.14
#define GTK_SOURCE_FILE_LOADER_ERROR gtk_source_file_loader_error_quark ()
An error code used with the GTK_SOURCE_FILE_LOADER_ERROR domain.
“buffer” property“buffer” GtkSourceBuffer *
The GtkSourceBuffer to load the contents into. The GtkSourceFileLoader object has a weak reference to the buffer.
Flags: Read / Write / Construct Only
Since: 3.14
“file” property“file” GtkSourceFile *
The GtkSourceFile. The GtkSourceFileLoader object has a weak reference to the file.
Flags: Read / Write / Construct Only
Since: 3.14
“input-stream” property “input-stream” GInputStream *
The GInputStream to load. Useful for reading stdin. If this property is set, the “location” property is ignored.
Flags: Read / Write / Construct Only
Since: 3.14
“location” property “location” GFile *
The GFile to load. If the “input-stream” is
NULL, by default the location is taken from the GtkSourceFile at
construction time.
Flags: Read / Write / Construct Only
Since: 3.14