## 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_set_mount_operation_factory ()

## Properties

GtkSourceCompressionType | compression-type | Read
GtkSourceEncoding * | encoding | Read
GFile * | location | Read / Write
GtkSourceNewlineType | newline-type | Read

## Types and Values

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

## Object Hierarchy

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

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

Flags: Read

Since 3.14

### The `“location”` property

      “location”                 GFile *

The location.

Flags: Read / Write

Since 3.14

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

      “newline-type”             GtkSourceNewlineType

The line ending type.

Flags: Read

Default value: GTK_SOURCE_NEWLINE_TYPE_LF

Since 3.14

## See Also

GtkSourceFileLoader, GtkSourceFileSaver