## GtkSourceFile

GtkSourceFile — On-disk representation of a GtkSourceBuffer

## Functions

GMountOperation * | ( *GtkSourceMountOperationFactory ) ()
GtkSourceFile * | gtk_source_file_new ()
GFile * | gtk_source_file_get_location ()
void | gtk_source_file_set_location ()
const GtkSourceEncoding * | gtk_source_file_get_encoding ()
GtkSourceNewlineType | gtk_source_file_get_newline_type ()
GtkSourceCompressionType | gtk_source_file_get_compression_type ()
void | gtk_source_file_check_file_on_disk ()
gboolean | gtk_source_file_is_local ()
gboolean | gtk_source_file_is_externally_modified ()
gboolean | gtk_source_file_is_deleted ()
gboolean | gtk_source_file_is_readonly ()
void | gtk_source_file_set_mount_operation_factory ()

## Properties

GtkSourceCompressionType | compression-type | Read
GtkSourceEncoding * | encoding | Read
GFile * | location | Read / Write / Construct
GtkSourceNewlineType | newline-type | Read
gboolean | read-only | Read

## Types and Values

| GtkSourceFile
enum | GtkSourceNewlineType
#define | GTK_SOURCE_NEWLINE_TYPE_DEFAULT
enum | GtkSourceCompressionType

## Object Hierarchy

        GEnum
        ├── GtkSourceCompressionType
        ╰── GtkSourceNewlineType
        GObject
        ╰── GtkSourceFile

## Includes

    #include <gtksourceview/gtksource.h>

## Description

A GtkSourceFile object is the on-disk representation of a GtkSourceBuffer. With a GtkSourceFile, you can create and configure a GtkSourceFileLoader and GtkSourceFileSaver which take by default the values of the GtkSourceFile properties (except for the file loader which auto-detect some properties). On a successful load or save operation, the GtkSourceFile properties are updated. If an operation fails, the GtkSourceFile properties have still the previous valid values.

## Functions

### GtkSourceMountOperationFactory ()

    GMountOperation *
    (*GtkSourceMountOperationFactory) (GtkSourceFile *file,
                                       gpointer userdata);

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

#### Parameters

file | a GtkSourceFile. |
userdata | user data |

Since: 3.14

### gtk_source_file_new ()

    GtkSourceFile *
    gtk_source_file_new (void);

#### Returns

a new GtkSourceFile object.

Since: 3.14

### gtk_source_file_get_location ()

    GFile *
    gtk_source_file_get_location (GtkSourceFile *file);

#### Parameters

file | a GtkSourceFile. |

#### Returns

the GFile.

[transfer none]

Since: 3.14

### gtk_source_file_set_location ()

    void
    gtk_source_file_set_location (GtkSourceFile *file,
                                  GFile *location);

Sets the location.

#### Parameters

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

Since: 3.14

### gtk_source_file_get_encoding ()

    const GtkSourceEncoding *
    gtk_source_file_get_encoding (GtkSourceFile *file);

The encoding is initially `NULL`. After a successful file loading or saving operation, the encoding is non-`NULL`.

#### Parameters

file | a GtkSourceFile. |

#### Returns

the character encoding.

Since: 3.14

### gtk_source_file_get_newline_type ()

    GtkSourceNewlineType
    gtk_source_file_get_newline_type (GtkSourceFile *file);

#### Parameters

file | a GtkSourceFile. |

#### Returns

the newline type.

Since: 3.14

### gtk_source_file_get_compression_type ()

    GtkSourceCompressionType
    gtk_source_file_get_compression_type (GtkSourceFile *file);

#### Parameters

file | a GtkSourceFile. |

#### Returns

the compression type.

Since: 3.14

### gtk_source_file_check_file_on_disk ()

    void
    gtk_source_file_check_file_on_disk (GtkSourceFile *file);

Checks synchronously the file on disk, to know whether the file is externally modified, or has been deleted, and whether the file is read-only.

GtkSourceFile doesn't create a GFileMonitor to track those properties, so this function needs to be called instead. Creating lots of GFileMonitor's would take lots of resources.

Since this function is synchronous, it is advised to call it only on local files. See `gtk_source_file_is_local()`.

#### Parameters

file | a GtkSourceFile. |

Since: 3.18

### gtk_source_file_is_local ()

    gboolean
    gtk_source_file_is_local (GtkSourceFile *file);

Returns whether the file is local. If the “location” is `NULL`, returns `FALSE`.

#### Parameters

file | a GtkSourceFile. |

#### Returns

whether the file is local.

Since: 3.18

### gtk_source_file_is_externally_modified ()

    gboolean
    gtk_source_file_is_externally_modified
                                   (GtkSourceFile *file);

Returns whether the file is externally modified. If the “location” is `NULL`, returns `FALSE`.

To have an up-to-date value, you must first call `gtk_source_file_check_file_on_disk()`.

#### Parameters

file | a GtkSourceFile. |

#### Returns

whether the file is externally modified.

Since: 3.18

### gtk_source_file_is_deleted ()

    gboolean
    gtk_source_file_is_deleted (GtkSourceFile *file);

Returns whether the file has been deleted. If the “location” is `NULL`, returns `FALSE`.

To have an up-to-date value, you must first call `gtk_source_file_check_file_on_disk()`.

#### Parameters

file | a GtkSourceFile. |

#### Returns

whether the file has been deleted.

Since: 3.18

### gtk_source_file_is_readonly ()

    gboolean
    gtk_source_file_is_readonly (GtkSourceFile *file);

Returns whether the file is read-only. If the “location” is `NULL`, returns `FALSE`.

To have an up-to-date value, you must first call `gtk_source_file_check_file_on_disk()`.

#### Parameters

file | a GtkSourceFile. |

#### Returns

whether the file is read-only.

Since: 3.18

### gtk_source_file_set_mount_operation_factory ()

    void
    gtk_source_file_set_mount_operation_factory
                                   (GtkSourceFile *file,
                                    GtkSourceMountOperationFactory callback,
                                    gpointer user_data,
                                    GDestroyNotify notify);

Sets a GtkSourceMountOperationFactory 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 GtkSourceFile. |
callback | a GtkSourceMountOperationFactory to call when a GMountOperation is needed. | [scope notified]
user_data | the data to pass to the `callback` function. | [closure]
notify | function to call on `user_data` when the `callback` is no longer needed, or `NULL`. | [nullable]

Since: 3.14

## Types and Values

### GtkSourceFile

    typedef struct _GtkSourceFile GtkSourceFile;

### enum GtkSourceNewlineType

#### Members

GTK_SOURCE_NEWLINE_TYPE_LF | line feed, used on UNIX. |
GTK_SOURCE_NEWLINE_TYPE_CR | carriage return, used on Mac. |
GTK_SOURCE_NEWLINE_TYPE_CR_LF | carriage return followed by a line feed, used on Windows. |

Since: 3.14

### GTK_SOURCE_NEWLINE_TYPE_DEFAULT

    #define GTK_SOURCE_NEWLINE_TYPE_DEFAULT GTK_SOURCE_NEWLINE_TYPE_CR_LF

The default newline type on the current OS.

Since: 3.14

### enum GtkSourceCompressionType

#### Members

GTK_SOURCE_COMPRESSION_TYPE_NONE | plain text. |
GTK_SOURCE_COMPRESSION_TYPE_GZIP | gzip compression. |

Since: 3.14

## Property Details

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

      “compression-type”         GtkSourceCompressionType

The compression type.

Owner: GtkSourceFile

Flags: Read

Default value: GTK_SOURCE_COMPRESSION_TYPE_NONE

Since: 3.14

### The `“encoding”` property

      “encoding”                 GtkSourceEncoding *

The character encoding, initially `NULL`. After a successful file loading or saving operation, the encoding is non-`NULL`.

Owner: GtkSourceFile

Flags: Read

Since: 3.14

### The `“location”` property

      “location”                 GFile *

The location.

Owner: GtkSourceFile

Flags: Read / Write / Construct

Since: 3.14

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

      “newline-type”             GtkSourceNewlineType

The line ending type.

Owner: GtkSourceFile

Flags: Read

Default value: GTK_SOURCE_NEWLINE_TYPE_LF

Since: 3.14

### The `“read-only”` property

      “read-only”                gboolean

Whether the file is read-only or not. The value of this property is not updated automatically (there is no file monitors).

Owner: GtkSourceFile

Flags: Read

Default value: FALSE

Since: 3.18

## See Also

GtkSourceFileLoader, GtkSourceFileSaver