GtkSourceInputStream

GtkSourceInputStream — Additional functions for GInputStream

Functions

Includes

#include <gtksourceview/gtksource.h>

Description

Additional functions for GInputStream.

Functions

GtkSourceSimpleProgressCallback ()

void
(*GtkSourceSimpleProgressCallback) (gsize number,
                                    gpointer user_data);

Like GFileProgressCallback but without the total.

Parameters

number

the number.

 

user_data

user data.

 

Since: 299.6


gtk_source_input_stream_read_async ()

void
gtk_source_input_stream_read_async (GInputStream *input_stream,
                                    gsize expected_size,
                                    gsize max_size,
                                    gint io_priority,
                                    GCancellable *cancellable,
                                    GtkSourceSimpleProgressCallback progress_callback,
                                    gpointer progress_callback_data,
                                    GAsyncReadyCallback callback,
                                    gpointer user_data);

This function starts a read operation on input_stream . It is meant to be used as the only read operation on input_stream , to get a GBytes as a result, with max_size as the provided maximum number of bytes to read.

expected_size is typically a GFile size as returned by g_file_info_get_size(). But note that in that case, the returned GBytes may contain a different number of bytes than what was expected (the TOC/TOU problem: time of check to time of use). expected_size is used as an indication to how much memory to allocate initially.

This function also closes input_stream after reading the content.

See the GAsyncResult documentation to know how to use this function.

[skip]

Parameters

input_stream

a GInputStream.

 

expected_size

the expected number of bytes contained in input_stream .

 

max_size

the maximum number of bytes to read.

 

io_priority

the I/O priority of the request. E.g. G_PRIORITY_LOW, G_PRIORITY_DEFAULT or G_PRIORITY_HIGH.

 

cancellable

optional GCancellable object, NULL to ignore.

[nullable]

progress_callback

function to call back with progress information, or NULL if progress information is not needed.

[nullable]

progress_callback_data

user data to pass to progress_callback .

 

callback

a GAsyncReadyCallback to call when the operation is finished.

[scope async]

user_data

user data to pass to callback .

 

Since: 299.6


gtk_source_input_stream_read_finish ()

GBytes *
gtk_source_input_stream_read_finish (GInputStream *input_stream,
                                     GAsyncResult *result,
                                     gboolean *is_truncated,
                                     GError **error);

Finishes an operation started with gtk_source_input_stream_read_async().

If is_truncated is set to TRUE, it is not an error (error is not set), and a GBytes is returned. However, since gtk_source_input_stream_read_async() is meant to be used as the only read operation on input_stream , it is an undefined behavior if you try to read more content from input_stream .

The data contained in the resulting GBytes is always zero-terminated, but this is not included in the GBytes length.

[skip]

Parameters

input_stream

a GInputStream.

 

result

a GAsyncResult.

 

is_truncated

will be set to TRUE if the input_stream contains more data to be read, but the maximum number of bytes to read has been reached.

 

error

a GError, or NULL.

 

Returns

a GBytes, or NULL on error. Free with g_bytes_unref().

[transfer full][nullable]

Since: 299.6