## 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 ()
GtkSourceCompletionWords * | ide_buffer_manager_get_word_completion ()
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 ()

## 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
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,
                                        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 it's reference count incremented by one.

#### Returns

An IdeBuffer if successf; 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.

### 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 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 container][element-type IdeBuffer*]

### ide_buffer_manager_get_word_completion ()

    GtkSourceCompletionWords *
    ide_buffer_manager_get_word_completion
                                   (IdeBufferManager *self);

Gets the GtkSourceCompletionWords completion provider that will complete words using the loaded documents.

#### Parameters

self | A IdeBufferManager. |

#### Returns

A GtkSourceCompletionWords.

[transfer none]

### 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. |

## 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.

#### 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          reloading,
                   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 `reloading` is `TRUE`, then the buffer is being force-reloaded due to changes from the host file-system.

#### Parameters

self | An IdeBufferManager. |
buffer | an IdeBuffer. |
reloading | if the buffer is being reloaded |
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.

#### Parameters

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

Flags: Run Last