GtefFileLoader

GtefFileLoader — Load a file into a GtefBuffer

Functions

Properties

GtefBuffer * buffer Read / Write / Construct Only
gint64 chunk-size Read / Write / Construct
GtefFile * file Read / Write / Construct Only
GFile * location Read / Write / Construct Only
gint64 max-size Read / Write / Construct

Types and Values

Object Hierarchy

    GEnum
    ╰── GtefFileLoaderError
    GObject
    ╰── GtefFileLoader

Includes

#include <gtef/gtef.h>

Description

GtefFileLoader is not a fork of GtkSourceFileLoader, it is a new implementation based on uchardet.

But the implementation is not yet finished.

Functions

gtef_file_loader_new ()

GtefFileLoader *
gtef_file_loader_new (GtefBuffer *buffer,
                      GtefFile *file);

Creates a new GtefFileLoader object. The contents is read from the GtefFile location.

If not already done, call gtef_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 GtefFile location directly permits to update the UI, to display the good location when the file is loading.

Parameters

buffer

the GtefBuffer to load the contents into.

 

file

the GtefFile.

 

Returns

a new GtefFileLoader object.

Since: 1.0


gtef_file_loader_get_buffer ()

GtefBuffer *
gtef_file_loader_get_buffer (GtefFileLoader *loader);

Parameters

loader

a GtefFileLoader.

 

Returns

the GtefBuffer to load the contents into.

[transfer none][nullable]

Since: 1.0


gtef_file_loader_get_file ()

GtefFile *
gtef_file_loader_get_file (GtefFileLoader *loader);

Parameters

loader

a GtefFileLoader.

 

Returns

the GtefFile.

[transfer none][nullable]

Since: 1.0


gtef_file_loader_get_location ()

GFile *
gtef_file_loader_get_location (GtefFileLoader *loader);

Parameters

loader

a GtefFileLoader.

 

Returns

the GFile to load.

[transfer none][nullable]

Since: 1.0


gtef_file_loader_get_max_size ()

gint64
gtef_file_loader_get_max_size (GtefFileLoader *loader);

Parameters

loader

a GtefFileLoader.

 

Returns

the maximum contents size, or -1 for unlimited.

Since: 1.0


gtef_file_loader_set_max_size ()

void
gtef_file_loader_set_max_size (GtefFileLoader *loader,
                               gint64 max_size);

Parameters

loader

a GtefFileLoader.

 

max_size

the new maximum size, or -1 for unlimited.

 

Since: 1.0


gtef_file_loader_get_chunk_size ()

gint64
gtef_file_loader_get_chunk_size (GtefFileLoader *loader);

Parameters

loader

a GtefFileLoader.

 

Returns

the chunk size.

Since: 1.0


gtef_file_loader_set_chunk_size ()

void
gtef_file_loader_set_chunk_size (GtefFileLoader *loader,
                                 gint64 chunk_size);

Parameters

loader

a GtefFileLoader.

 

chunk_size

the new chunk size.

 

Since: 1.0


gtef_file_loader_load_async ()

void
gtef_file_loader_load_async (GtefFileLoader *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 contents into the GtefBuffer.

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

Parameters

loader

a GtefFileLoader.

 

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.

[scope notified][nullable]

progress_callback_data

user data to pass to progress_callback .

[closure]

progress_callback_notify

function to call on progress_callback_data when the progress_callback is no longer needed, or NULL.

[nullable]

callback

a GAsyncReadyCallback to call when the request is satisfied.

[scope async]

user_data

user data to pass to callback .

 

Since: 1.0


gtef_file_loader_load_finish ()

gboolean
gtef_file_loader_load_finish (GtefFileLoader *loader,
                              GAsyncResult *result,
                              GError **error);

Finishes a file loading started with gtef_file_loader_load_async().

Parameters

loader

a GtefFileLoader.

 

result

a GAsyncResult.

 

error

a GError, or NULL.

 

Returns

whether the contents has been loaded successfully.

Since: 1.0

Types and Values

GtefFileLoader

typedef struct _GtefFileLoader GtefFileLoader;

GTEF_FILE_LOADER_ERROR

#define GTEF_FILE_LOADER_ERROR gtef_file_loader_error_quark ()

enum GtefFileLoaderError

An error code used with the GTEF_FILE_LOADER_ERROR domain.

Members

GTEF_FILE_LOADER_ERROR_TOO_BIG

The file is too big.

 

GTEF_FILE_LOADER_ERROR_ENCODING_AUTO_DETECTION_FAILED

It is not possible to detect the encoding automatically.

 

Since: 1.0

Property Details

The “buffer” property

  “buffer”                   GtefBuffer *

The GtefBuffer to load the contents into. The GtefFileLoader object has a weak reference to the buffer.

Flags: Read / Write / Construct Only

Since: 1.0


The “chunk-size” property

  “chunk-size”               gint64

The chunk size, in bytes. The contents is loaded chunk by chunk. It permits to avoid allocating a too big contiguous memory area, as well as reporting progress information after each chunk read.

A small chunk size is better when loading a remote file with a slow connection. For local files, the chunk size can be larger.

Flags: Read / Write / Construct

Allowed values: >= 1

Default value: 32768

Since: 1.0


The “file” property

  “file”                     GtefFile *

The GtefFile. The GtefFileLoader object has a weak reference to the file.

Flags: Read / Write / Construct Only

Since: 1.0


The “location” property

  “location”                 GFile *

The GFile to load. By default the location is taken from the GtefFile at construction time.

Flags: Read / Write / Construct Only

Since: 1.0


The “max-size” property

  “max-size”                 gint64

The maximum contents size, in bytes. Keep in mind that all the contents is loaded in memory, and when loaded into a GtkTextBuffer it takes more memory than just the contents size.

Set to -1 for unlimited size.

Flags: Read / Write / Construct

Allowed values: >= -1

Default value: 50000000

Since: 1.0