TeplFile: libgedit-tepl 6 Reference Manual

## TeplFile TeplFile — On-disk representation of a TeplBuffer |

## Functions

GMountOperation * | (*TeplMountOperationFactory) ()
TeplFile * | tepl_file_new ()
GFile * | tepl_file_get_location ()
void | tepl_file_set_location ()
gchar * | tepl_file_get_short_name ()
gchar * | tepl_file_get_full_name ()
TeplNewlineType | tepl_file_get_newline_type ()
void | tepl_file_set_mount_operation_factory ()
void | tepl_file_add_uri_to_recent_manager ()

## Properties

char * | full-name | Read
GFile * | location | Read / Write / Construct
TeplNewlineType | newline-type | Read
char * | short-name | Read

## Types and Values

struct | TeplFile
enum | TeplNewlineType
#define | TEPL_NEWLINE_TYPE_DEFAULT

## Object Hierarchy

        GEnum
        ╰── TeplNewlineType
        GObject
        ╰── TeplFile

## Includes

    #include <tepl/tepl.h>

## Description

A TeplFile object is the on-disk representation of a TeplBuffer.

With a TeplFile, you can create and configure a TeplFileLoader and TeplFileSaver which take by default the values of the TeplFile properties (except for the file loader which auto-detects some properties). On a successful load or save operation, the TeplFile properties are updated. If an operation fails, the TeplFile properties have still the previous valid values.

It is possible to use TeplFile without using TeplFileLoader and TeplFileSaver. TeplFile alone offers several features useful for a text editor.

When using TeplFile alone, TeplFile does the I/O operations (if any) asynchronously.

## Functions

### TeplMountOperationFactory ()

    GMountOperation *
    (*TeplMountOperationFactory) (TeplFile *file,
                                  gpointer user_data);

Type definition for a function that will be called to create a GMountOperation. This is useful for creating a GtkMountOperation.

#### Parameters

file | a TeplFile. |
user_data | user data. |

Since: 1.0

### tepl_file_new ()

    TeplFile *
    tepl_file_new (void);

#### Returns

a new TeplFile object.

Since: 1.0

### tepl_file_get_location ()

    GFile *
    tepl_file_get_location (TeplFile *file);

#### Parameters

file | a TeplFile. |

#### Returns

the value of the “location” property.

[transfer none]

Since: 1.0

### tepl_file_set_location ()

    void
    tepl_file_set_location (TeplFile *file,
                            GFile *location);

Sets the “location” property.

#### Parameters

file | a TeplFile. |
location | the new GFile, or `NULL`. | [nullable]

Since: 1.0

### tepl_file_get_short_name ()

    gchar *
    tepl_file_get_short_name (TeplFile *file);

#### Parameters

file | a TeplFile. |

#### Returns

the value of the “short-name” property. Free with `g_free()`.

Since: 5.0

### tepl_file_get_full_name ()

    gchar *
    tepl_file_get_full_name (TeplFile *file);

#### Parameters

file | a TeplFile. |

#### Returns

the value of the “full-name” property. Free with `g_free()`.

Since: 6.4

### tepl_file_get_newline_type ()

    TeplNewlineType
    tepl_file_get_newline_type (TeplFile *file);

#### Parameters

file | a TeplFile. |

#### Returns

the value of the “newline-type” property.

Since: 1.0

### tepl_file_set_mount_operation_factory ()

    void
    tepl_file_set_mount_operation_factory (TeplFile *file,
                                           TeplMountOperationFactory callback,
                                           gpointer user_data,
                                           GDestroyNotify notify);

Sets a TeplMountOperationFactory function that will be called when a GMountOperation must be created. This is useful for creating a GtkMountOperation with the parent GtkWindow.

If a mount operation factory isn't set, `g_mount_operation_new()` will be called.

#### Parameters

file | a TeplFile. |
callback | a TeplMountOperationFactory to call when a GMountOperation is needed. | [scope notified]
user_data | the data to pass to the `callback` function. |
notify | function to call on `user_data` when the `callback` is no longer needed, or `NULL`. | [nullable]

Since: 1.0

### tepl_file_add_uri_to_recent_manager ()

    void
    tepl_file_add_uri_to_recent_manager (TeplFile *file);

If the “location” isn't `NULL`, adds its URI to the default GtkRecentManager with `gtk_recent_manager_add_item()`.

#### Parameters

file | a TeplFile. |

Since: 4.0

## Types and Values

### struct TeplFile

    struct TeplFile;

### enum TeplNewlineType

#### Members

TEPL_NEWLINE_TYPE_LF | line feed, used on UNIX. |
TEPL_NEWLINE_TYPE_CR | carriage return, used on Mac. |
TEPL_NEWLINE_TYPE_CR_LF | carriage return followed by a line feed, used on Windows. |

Since: 1.0

### TEPL_NEWLINE_TYPE_DEFAULT

    #define TEPL_NEWLINE_TYPE_DEFAULT TEPL_NEWLINE_TYPE_CR_LF

The default newline type on the current OS.

Since: 1.0

## Property Details

### The `“full-name”` property

      “full-name”                char *

Convenience property for the full name of a TeplFile.

When the “location” is `NULL`, this property has the same value as the “short-name”.

When the “location” is not `NULL`, this property contains the full path to the location. It uses:

- g_file_get_parse_name()

- tepl_utils_replace_home_dir_with_tilde()

Owner: TeplFile

Flags: Read

Default value: NULL

### The `“location”` property

      “location”                 GFile *

The location.

Owner: TeplFile

Flags: Read / Write / Construct

Since: 1.0

### The `“newline-type”` property

      “newline-type”             TeplNewlineType

The line ending type.

Owner: TeplFile

Flags: Read

Default value: TEPL_NEWLINE_TYPE_LF

Since: 1.0

### The `“short-name”` property

      “short-name”               char *

The file short name.

When the “location” is `NULL`, the default instance of GflsUnsavedDocumentTitles is used to get a title.

When the “location” is not `NULL`, this property contains the display-name (see G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME). However, requesting the display-name can take some time (for example for a remote file with a slow network connection). When the “location” property is set, the display-name is fetched asynchronously. When the display-name is available, this property is notified. In the meantime – after the “location” is set but before receiving the display-name – a fallback implementation is used that does no blocking I/O (but it may return a different result compared to the real display-name).

Owner: TeplFile

Flags: Read

Default value: NULL

Since: 1.0

## See Also

TeplFileLoader, TeplFileSaver