ide-buffer-manager: Builder SDK Reference

## ide-buffer-manager ide-buffer-manager |

## Functions

IdeBuffer * | ide_buffer_manager_create_temporary_buffer ()
void | ide_buffer_manager_load_file_async ()
IdeBuffer * | ide_buffer_manager_load_file_finish ()
void | ide_buffer_manager_save_file_async ()
gboolean | ide_buffer_manager_save_file_finish ()
void | ide_buffer_manager_save_all_async ()
gboolean | ide_buffer_manager_save_all_finish ()
IdeBuffer * | ide_buffer_manager_get_focus_buffer ()
void | ide_buffer_manager_set_focus_buffer ()
GPtrArray * | ide_buffer_manager_get_buffers ()
guint | ide_buffer_manager_get_n_buffers ()
gboolean | ide_buffer_manager_has_file ()
IdeBuffer * | ide_buffer_manager_find_buffer ()
gsize | ide_buffer_manager_get_max_file_size ()
void | ide_buffer_manager_set_max_file_size ()
void | ide_buffer_manager_apply_edits_async ()
gboolean | ide_buffer_manager_apply_edits_finish ()
guint | ide_buffer_manager_get_auto_save_timeout ()
void | ide_buffer_manager_set_auto_save_timeout ()
gboolean | ide_buffer_manager_get_auto_save ()
void | ide_buffer_manager_set_auto_save ()

## Properties

gboolean | auto-save | Read / Write
guint | auto-save-timeout | Read / Write
IdeBuffer * | focus-buffer | Read / Write

## Signals

void | buffer-focus-enter | Run Last
void | buffer-focus-leave | Run Last
void | buffer-loaded | Run Last
void | buffer-saved | Run Last
void | buffer-unloaded | Run Last
IdeBuffer* | create-buffer | Run Last
void | load-buffer | Run Last
void | save-buffer | Run Last

## Types and Values

#define | IDE_TYPE_BUFFER_MANAGER
| IdeBufferManager

## Object Hierarchy

        GObject
        ╰── IdeObject
            ╰── IdeBufferManager

## Implemented Interfaces

IdeBufferManager implements GListModel.

## Description

## Functions

### ide_buffer_manager_create_temporary_buffer ()

    IdeBuffer *
    ide_buffer_manager_create_temporary_buffer
                                   (IdeBufferManager *self);

Creates a new IdeBuffer that does not yet have a backing file attached to it. Interfaces should perform a save-as operation to save the file to a real file.

ide_file_get_file() will return `NULL` to denote this type of buffer.

#### Returns

A newly created IdeBuffer.

[transfer full]

### ide_buffer_manager_load_file_async ()

    void
    ide_buffer_manager_load_file_async (IdeBufferManager *self,
                                        IdeFile *file,
                                        gboolean force_reload,
                                        IdeWorkbenchOpenFlags flags,
                                        IdeProgress **progress,
                                        GCancellable *cancellable,
                                        GAsyncReadyCallback callback,
                                        gpointer user_data);

Asynchronously requests that the file represented by `file` is loaded. If the file is already loaded, the previously loaded version of the file will be returned, asynchronously.

Before loading the file, IdeBufferManager will check the file size to help protect itself from the user accidentally loading very large files. You can change the maximum size of file that will be loaded with the “max-file-size” property.

See `ide_buffer_manager_load_file_finish()` for how to complete this asynchronous request.

#### Parameters

progress | A location for an IdeProgress or `NULL`. | [out][nullable]

### ide_buffer_manager_load_file_finish ()

    IdeBuffer *
    ide_buffer_manager_load_file_finish (IdeBufferManager *self,
                                         GAsyncResult *result,
                                         GError **error);

Completes an asynchronous request to load a file via `ide_buffer_manager_load_file_async()`. If the buffer was already loaded, this function will return a reference to the previous buffer with its reference count incremented by one.

#### Returns

An IdeBuffer if successful; otherwise `NULL` and `error` is set.

[transfer full]

### ide_buffer_manager_save_file_async ()

    void
    ide_buffer_manager_save_file_async (IdeBufferManager *self,
                                        IdeBuffer *buffer,
                                        IdeFile *file,
                                        IdeProgress **progress,
                                        GCancellable *cancellable,
                                        GAsyncReadyCallback callback,
                                        gpointer user_data);

This function asynchronously requests that a buffer be saved to the storage represented by `file` . `buffer` should be a previously loaded buffer owned by `self` , such as one loaded with `ide_buffer_manager_load_file_async()`.

Call `ide_buffer_manager_save_file_finish()` to complete this asynchronous request.

#### Parameters

self | an IdeBufferManager |
buffer | an IdeBuffer |
file | an IdeFile |
progress | a location for an IdeProgress. | [out][transfer full]
cancellable | a GCancellable. | [nullable]
callback | a GAsyncReadyCallback or `NULL`. | [nullable]
user_data | closure data for `callback` |

### ide_buffer_manager_save_file_finish ()

    gboolean
    ide_buffer_manager_save_file_finish (IdeBufferManager *self,
                                         GAsyncResult *result,
                                         GError **error);

This function completes an asynchronous request to save a buffer to storage using `ide_buffer_manager_save_file_async()`. Upon failure, `FALSE` is returned and `error` is set.

#### Returns

`TRUE` if successful `FALSE` upon failure and `error` is set.

### ide_buffer_manager_save_all_async ()

    void
    ide_buffer_manager_save_all_async (IdeBufferManager *self,
                                       GCancellable *cancellable,
                                       GAsyncReadyCallback callback,
                                       gpointer user_data);

### ide_buffer_manager_save_all_finish ()

    gboolean
    ide_buffer_manager_save_all_finish (IdeBufferManager *self,
                                        GAsyncResult *result,
                                        GError **error);

### ide_buffer_manager_get_focus_buffer ()

    IdeBuffer *
    ide_buffer_manager_get_focus_buffer (IdeBufferManager *self);

Gets the “focus-buffer” property. This is the buffer behind the current selected view.

#### Returns

An IdeBuffer or `NULL`.

[transfer none]

### ide_buffer_manager_set_focus_buffer ()

    void
    ide_buffer_manager_set_focus_buffer (IdeBufferManager *self,
                                         IdeBuffer *buffer);

### ide_buffer_manager_get_buffers ()

    GPtrArray *
    ide_buffer_manager_get_buffers (IdeBufferManager *self);

Returns a newly allocated GPtrArray of all the buffers managed by the IdeBufferManager instance.

Buffers are generally not added to the buffer list until they have been loaded.

#### Returns

a GPtrArray of buffers.

[transfer full][element-type Ide.Buffer]

### ide_buffer_manager_get_n_buffers ()

    guint
    ide_buffer_manager_get_n_buffers (IdeBufferManager *self);

### ide_buffer_manager_has_file ()

    gboolean
    ide_buffer_manager_has_file (IdeBufferManager *self,
                                 GFile *file);

Checks to see if the buffer manager has the file loaded.

#### Parameters

self | An IdeBufferManager. | [in]
file | An IdeFile. | [in]

#### Returns

`TRUE` if `file` is loaded.

### ide_buffer_manager_find_buffer ()

    IdeBuffer *
    ide_buffer_manager_find_buffer (IdeBufferManager *self,
                                    GFile *file);

Gets the buffer for a given file. If it has not yet been loaded, `NULL` is returned.

#### Parameters

self | An IdeBufferManager. | [in]
file | a GFile. | [in]

#### Returns

An IdeBuffer or `NULL`.

[transfer none][nullable]

### ide_buffer_manager_get_max_file_size ()

    gsize
    ide_buffer_manager_get_max_file_size (IdeBufferManager *self);

Gets the “max-file-size” property. This contains the maximum file size in bytes that a file may be to be loaded by the IdeBufferManager.

If zero, no size limits will be enforced.

#### Parameters

self | An IdeBufferManager. |

#### Returns

a gsize in bytes or zero.

### ide_buffer_manager_set_max_file_size ()

    void
    ide_buffer_manager_set_max_file_size (IdeBufferManager *self,
                                          gsize max_file_size);

Sets the maximum file size in bytes, that will be loaded by the IdeBufferManager.

#### Parameters

self | An IdeBufferManager. |
max_file_size | The maximum file size in bytes, or zero for no limit. |

### ide_buffer_manager_apply_edits_async ()

    void
    ide_buffer_manager_apply_edits_async (IdeBufferManager *self,
                                          GPtrArray *edits,
                                          GCancellable *cancellable,
                                          GAsyncReadyCallback callback,
                                          gpointer user_data);

Asynchronously requests that all of `edits` are applied to the buffers in the project. If the buffer has not been loaded for a particular edit, it will be loaded.

#### Parameters

self | An IdeBufferManager |
edits | An GPtrArray of IdeProjectEdit. | [transfer full][element-type Ide.ProjectEdit]
cancellable | a GCancellable or `NULL`. | [allow-none]
callback | the callback to complete the request |
user_data | user data for `callback` |

### ide_buffer_manager_apply_edits_finish ()

    gboolean
    ide_buffer_manager_apply_edits_finish (IdeBufferManager *self,
                                           GAsyncResult *result,
                                           GError **error);

### ide_buffer_manager_get_auto_save_timeout ()

    guint
    ide_buffer_manager_get_auto_save_timeout
                                   (IdeBufferManager *self);

Gets the value of the “auto-save-timeout” property.

#### Returns

The timeout in seconds if enabled, otherwise 0.

### ide_buffer_manager_set_auto_save_timeout ()

    void
    ide_buffer_manager_set_auto_save_timeout
                                   (IdeBufferManager *self,
                                    guint auto_save_timeout);

Sets the “auto-save-timeout” property.

You can set this property to 0 to use the default timeout.

This is the number of seconds to wait after a buffer has been changed before automatically saving the buffer.

#### Parameters

auto_save_timeout | The auto save timeout in seconds. |

### ide_buffer_manager_get_auto_save ()

    gboolean
    ide_buffer_manager_get_auto_save (IdeBufferManager *self);

Gets the “auto-save” property.

If auto-save is enabled, then buffers managed by `self` will be automatically persisted “auto-save-timeout” seconds after their last change.

#### Returns

`TRUE` if auto save is enabled. otherwise `FALSE`.

### ide_buffer_manager_set_auto_save ()

    void
    ide_buffer_manager_set_auto_save (IdeBufferManager *self,
                                      gboolean auto_save);

Sets the “auto-save” property. If this is `TRUE`, then a buffer will automatically be saved after “auto-save-timeout” seconds have elapsed since the buffer's last modification.

#### Parameters

self | an IdeBufferManager |
auto_save | `TRUE` if auto-save should be enabled. |

## Types and Values

### IDE_TYPE_BUFFER_MANAGER

    #define IDE_TYPE_BUFFER_MANAGER (ide_buffer_manager_get_type())

### IdeBufferManager

    typedef struct _IdeBufferManager IdeBufferManager;

## Property Details

### The `“auto-save”` property

      “auto-save”                gboolean

If the documents should auto save after a configured timeout.

Flags: Read / Write

Default value: TRUE

### The `“auto-save-timeout”` property

      “auto-save-timeout”        guint

The number of seconds after modification before auto saving.

Flags: Read / Write

Default value: 60

### The `“focus-buffer”` property

      “focus-buffer”             IdeBuffer *

The currently focused buffer.

Flags: Read / Write

## Signal Details

### The `“buffer-focus-enter”` signal

    void
    user_function (IdeBufferManager *self,
                   IdeBuffer        *buffer,
                   gpointer          user_data)

This signal is emitted when a view for `buffer` has received focus. You might connect to this signal when you want to perform an operation while a buffer is in focus.

#### Parameters

self | An IdeBufferManager. |
buffer | an IdeBuffer. |
user_data | user data set when the signal handler was connected. |

Flags: Run Last

### The `“buffer-focus-leave”` signal

    void
    user_function (IdeBufferManager *self,
                   IdeBuffer        *buffer,
                   gpointer          user_data)

This signal is emitted when the focus has left the view containing `buffer` . You might connect to this signal to stop any work you were performing while the buffer was focused.

#### Parameters

self | An IdeBufferManager. |
buffer | an IdeBuffer. |
user_data | user data set when the signal handler was connected. |

Flags: Run Last

### The `“buffer-loaded”` signal

    void
    user_function (IdeBufferManager *self,
                   IdeBuffer        *buffer,
                   gpointer          user_data)

This signal is emitted when a buffer has been successfully loaded. You might connect to this signal to be notified when a buffer has completed loading.

#### Parameters

self | An IdeBufferManager. |
buffer | an IdeBuffer. |
user_data | user data set when the signal handler was connected. |

Flags: Run Last

### The `“buffer-saved”` signal

    void
    user_function (IdeBufferManager *self,
                   IdeBuffer        *buffer,
                   gpointer          user_data)

This signal is emitted when a buffer has finished saving to storage. You might connect to this signal if you want to know when the modifications have successfully been written to storage. The buffer:file property point to the saved file.

#### Parameters

self | An IdeBufferManager. |
buffer | an IdeBuffer. |
user_data | user data set when the signal handler was connected. |

Flags: Run Last

### The `“buffer-unloaded”` signal

    void
    user_function (IdeBufferManager *self,
                   IdeBuffer        *buffer,
                   gpointer          user_data)

This signal is emitted when the buffer is unloaded. This allows consumers to access the buffer before the items-changed signal is emitted; at which point it will be too late to get a pointer to the buffer.

#### Parameters

self | An IdeBufferManager |
buffer | An IdeBuffer |
user_data | user data set when the signal handler was connected. |

Flags: Run Last

### The `“create-buffer”` signal

    IdeBuffer*
    user_function (IdeBufferManager *self,
                   IdeFile          *file,
                   gpointer          user_data)

This signal is emitted when there is a request to create a new buffer object. This allows subclasses of IdeBuffer to be instantiated by the buffer manager.

The first handler of this signal is responsible for returning an IdeBuffer or `NULL`, for which one will be created.

#### Parameters

self | An IdeBufferManager |
file | An IdeFile |
user_data | user data set when the signal handler was connected. |

#### Returns

An IdeBuffer or `NULL`.

[transfer full][nullable]

Flags: Run Last

### The `“load-buffer”` signal

    void
    user_function (IdeBufferManager *self,
                   IdeBuffer        *buffer,
                   gboolean          create_new_view,
                   gpointer          user_data)

This signal is emitted when a request has been made to load a buffer from storage. You might connect to this signal to be notified when loading of a buffer has begun.

If `create_new_view` is `FALSE`, then the buffer is probably being force-reloaded due to changes from the host file-system.

#### Parameters

self | An IdeBufferManager. |
buffer | An IdeBuffer. |
create_new_view | Whether to create a new IdeEditorView for the buffer. |
user_data | user data set when the signal handler was connected. |

Flags: Run Last

### The `“save-buffer”` signal

    void
    user_function (IdeBufferManager *self,
                   IdeBuffer        *buffer,
                   gpointer          user_data)

This signal is emitted when a request has been made to save a buffer. Connect to this signal if you'd like to perform mutation of the buffer before it is persisted to storage. Till the "buffer-saved" signal is emmited, the buffer:file property point to the current file.

#### Parameters

self | An IdeBufferManager. |
buffer | an IdeBuffer. |
user_data | user data set when the signal handler was connected. |

Flags: Run Last