## GflsUnsavedDocumentTitles

GflsUnsavedDocumentTitles — To give titles to unsaved documents

## Functions

gchar * | (*GflsUnsavedDocumentTitleCallback) ()
GflsUnsavedDocumentTitles * | gfls_unsaved_document_titles_new ()
GflsUnsavedDocumentTitles * | gfls_unsaved_document_titles_get_default ()
gint | gfls_unsaved_document_titles_allocate_number ()
void | gfls_unsaved_document_titles_release_number ()
gchar * | gfls_unsaved_document_titles_get_title ()
void | gfls_unsaved_document_titles_set_title_callback ()

## Types and Values

struct | GflsUnsavedDocumentTitles

## Object Hierarchy

        GObject
        ╰── GflsUnsavedDocumentTitles

## Includes

    #include <gfls/gfls.h>

## Description

GflsUnsavedDocumentTitles is used to give titles to unsaved documents, such as "Unsaved Document N" with 'N' replaced by a number.

This is for new documents that have never been saved before and reside in memory only. These documents have not yet an associated GFile.

Do not confuse it with documents with unsaved changes.

## Functions

### GflsUnsavedDocumentTitleCallback ()

    gchar *
    (*GflsUnsavedDocumentTitleCallback) (gint num);

Type definition for a function that will be called to create a string containing `num` , to give a name to a document not yet present on disk.

#### Parameters

num | the number. |

#### Returns

the created title.

[transfer full]

Since: 0.1

### gfls_unsaved_document_titles_new ()

    GflsUnsavedDocumentTitles *
    gfls_unsaved_document_titles_new (void);

#### Returns

a new GflsUnsavedDocumentTitles object.

[transfer full]

Since: 0.1

### gfls_unsaved_document_titles_get_default ()

    GflsUnsavedDocumentTitles *
    gfls_unsaved_document_titles_get_default
                                   (void);

#### Returns

the default instance of GflsUnsavedDocumentTitles.

[transfer none]

Since: 0.1

### gfls_unsaved_document_titles_allocate_number ()

    gint
    gfls_unsaved_document_titles_allocate_number
                                   (GflsUnsavedDocumentTitles *titles);

Allocates a number for an unsaved document. When the document is saved on disk, you need to give back the number with `gfls_unsaved_document_titles_release_number()`.

The returned number is the lowest available value, starting at 1.

#### Parameters

titles | a GflsUnsavedDocumentTitles. |

#### Returns

the allocated number.

Since: 0.1

### gfls_unsaved_document_titles_release_number ()

    void
    gfls_unsaved_document_titles_release_number
                                   (GflsUnsavedDocumentTitles *titles,
                                    gint number);

Call this function to give back `number` to `titles` , so that it becomes available for a next unsaved document. This is usually done when the document is saved on disk.

#### Parameters

titles | a GflsUnsavedDocumentTitles. |
number | the number to release. |

Since: 0.1

### gfls_unsaved_document_titles_get_title ()

    gchar *
    gfls_unsaved_document_titles_get_title
                                   (GflsUnsavedDocumentTitles *titles,
                                    gint number);

Generates the title of an unsaved document. To customize the returned string, you can use `gfls_unsaved_document_titles_set_title_callback()`.

#### Parameters

titles | a GflsUnsavedDocumentTitles. |
number | a number. |

#### Returns

a suitable title for the unsaved document with the given `number` .

[transfer full]

Since: 0.1

### gfls_unsaved_document_titles_set_title_callback ()

    void
    gfls_unsaved_document_titles_set_title_callback
                                   (GflsUnsavedDocumentTitles *titles,
                                    GflsUnsavedDocumentTitleCallback title_callback);

Sets a GflsUnsavedDocumentTitleCallback function. To reset to the default setting, pass `NULL` to `title_callback` .

The callback will be used by `gfls_unsaved_document_titles_get_title()`.

Examples:

- "Unsaved Document N"

- "Unsaved File N"

- "Untitled Document N"

- "New Document N"

- Etc.

[skip]

#### Parameters

titles | a GflsUnsavedDocumentTitles. |
title_callback | a GflsUnsavedDocumentTitleCallback. | [nullable]

Since: 0.1

## Types and Values

### struct GflsUnsavedDocumentTitles

    struct GflsUnsavedDocumentTitles;