## GeditDocument GeditDocument |

## Functions

GeditDocument * | gedit_document_new ()
GtkSourceFile * | gedit_document_get_file ()
GFile * | gedit_document_get_location ()
void | gedit_document_set_location ()
gchar * | gedit_document_get_uri_for_display ()
gchar * | gedit_document_get_short_name_for_display ()
void | gedit_document_set_short_name_for_display ()
gchar * | gedit_document_get_mime_type ()
gboolean | gedit_document_get_readonly ()
gboolean | gedit_document_is_local ()
gboolean | gedit_document_is_untouched ()
gboolean | gedit_document_is_untitled ()
gboolean | gedit_document_get_deleted ()
gboolean | gedit_document_goto_line ()
gboolean | gedit_document_goto_line_offset ()
void | gedit_document_set_language ()
GtkSourceNewlineType | gedit_document_get_newline_type ()
GtkSourceCompressionType | gedit_document_get_compression_type ()
gchar * | gedit_document_get_content_type ()
void | gedit_document_set_content_type ()
gchar * | gedit_document_get_metadata ()
void | gedit_document_set_metadata ()
void | gedit_document_set_search_context ()
GtkSourceSearchContext * | gedit_document_get_search_context ()

## Properties

gchar * | content-type | Read / Write
gboolean | empty-search | Read
gchar * | mime-type | Read
gboolean | read-only | Read
gchar * | shortname | Read / Write
gboolean | use-gvfs-metadata | Read / Write / Construct Only

## Signals

void | cursor-moved | Run Last
void | load | Run Last
void | loaded | Run First
void | save | Run Last
void | saved | Run First

## Types and Values

| GeditDocument

## Object Hierarchy

        GObject
        ╰── GtkTextBuffer
            ╰── GtkSourceBuffer
                ╰── GeditDocument

## Description

## Functions

### gedit_document_new ()

    GeditDocument *
    gedit_document_new (void);

### gedit_document_get_file ()

    GtkSourceFile *
    gedit_document_get_file (GeditDocument *doc);

Gets the associated GtkSourceFile. You should use it only for reading purposes, not for creating a GtkSourceFileLoader or GtkSourceFileSaver, because gedit does some extra work when loading or saving a file and maintains an internal state. If you use in a plugin a file loader or saver on the returned GtkSourceFile, the internal state of gedit won't be updated.

If you want to save the GeditDocument to a secondary file, you can create a new GtkSourceFile and use a GtkSourceFileSaver.

#### Parameters

doc | a GeditDocument. |

#### Returns

the associated GtkSourceFile.

[transfer none]

Since: 3.14

### gedit_document_get_location ()

    GFile *
    gedit_document_get_location (GeditDocument *doc);

`gedit_document_get_location` has been deprecated since version 3.14 and should not be used in newly-written code.

use `gtk_source_file_get_location()` instead. Attention, `gedit_document_get_location()` has a transfer full for the return value, while `gtk_source_file_get_location()` has a transfer none.

#### Parameters

doc | a GeditDocument |

#### Returns

a copy of the internal GFile.

[allow-none][transfer full]

### gedit_document_set_location ()

    void
    gedit_document_set_location (GeditDocument *doc,
                                 GFile *location);

`gedit_document_set_location` has been deprecated since version 3.14 and should not be used in newly-written code.

use `gtk_source_file_set_location()` instead.

#### Parameters

doc | a GeditDocument. |
location | the new location. |

### gedit_document_get_uri_for_display ()

    gchar *
    gedit_document_get_uri_for_display (GeditDocument *doc);

Note: this never returns `NULL`.

#### Parameters

doc | a GeditDocument. |

### gedit_document_get_short_name_for_display ()

    gchar *
    gedit_document_get_short_name_for_display
                                   (GeditDocument *doc);

Note: this never returns `NULL`.

#### Parameters

doc | a GeditDocument. |

### gedit_document_set_short_name_for_display ()

    void
    gedit_document_set_short_name_for_display
                                   (GeditDocument *doc,
                                    const gchar *short_name);

`gedit_document_set_short_name_for_display` has been deprecated since version 3.18 and should not be used in newly-written code.

Unused function. The intent is to change the “shortname” property to be read-only.

#### Parameters

short_name | . | [allow-none]

### gedit_document_get_mime_type ()

    gchar *
    gedit_document_get_mime_type (GeditDocument *doc);

Note: this never returns `NULL`.

#### Parameters

doc | a GeditDocument. |

### gedit_document_get_readonly ()

    gboolean
    gedit_document_get_readonly (GeditDocument *doc);

`gedit_document_get_readonly` has been deprecated since version 3.18 and should not be used in newly-written code.

Use `gtk_source_file_is_readonly()` instead.

#### Parameters

doc | a GeditDocument. |

#### Returns

whether the document is read-only.

### gedit_document_is_local ()

    gboolean
    gedit_document_is_local (GeditDocument *doc);

`gedit_document_is_local` has been deprecated since version 3.18 and should not be used in newly-written code.

Use `gtk_source_file_is_local()` instead.

#### Parameters

doc | a GeditDocument. |

#### Returns

whether the document is local.

### gedit_document_is_untouched ()

    gboolean
    gedit_document_is_untouched (GeditDocument *doc);

### gedit_document_is_untitled ()

    gboolean
    gedit_document_is_untitled (GeditDocument *doc);

### gedit_document_get_deleted ()

    gboolean
    gedit_document_get_deleted (GeditDocument *doc);

`gedit_document_get_deleted` has been deprecated since version 3.18 and should not be used in newly-written code.

Unused function.

#### Parameters

doc | a GeditDocument. |

#### Returns

whether the file has been deleted.

### gedit_document_goto_line ()

    gboolean
    gedit_document_goto_line (GeditDocument *doc,
                              gint line);

### gedit_document_goto_line_offset ()

    gboolean
    gedit_document_goto_line_offset (GeditDocument *doc,
                                     gint line,
                                     gint line_offset);

### gedit_document_set_language ()

    void
    gedit_document_set_language (GeditDocument *doc,
                                 GtkSourceLanguage *lang);

#### Parameters

lang | . | [allow-none]

### gedit_document_get_newline_type ()

    GtkSourceNewlineType
    gedit_document_get_newline_type (GeditDocument *doc);

`gedit_document_get_newline_type` has been deprecated since version 3.14 and should not be used in newly-written code.

use `gtk_source_file_get_newline_type()` instead.

#### Parameters

doc | a GeditDocument. |

#### Returns

the newline type.

### gedit_document_get_compression_type ()

    GtkSourceCompressionType
    gedit_document_get_compression_type (GeditDocument *doc);

`gedit_document_get_compression_type` has been deprecated since version 3.14 and should not be used in newly-written code.

use `gtk_source_file_get_compression_type()` instead.

#### Parameters

doc | a GeditDocument. |

#### Returns

the compression type.

### gedit_document_get_content_type ()

    gchar *
    gedit_document_get_content_type (GeditDocument *doc);

### gedit_document_set_content_type ()

    void
    gedit_document_set_content_type (GeditDocument *doc,
                                     const gchar *content_type);

`gedit_document_set_content_type` has been deprecated since version 3.18 and should not be used in newly-written code.

Unused function. The intent is to change the “content-type” property to be read-only.

#### Parameters

content_type | . | [allow-none]

### gedit_document_get_metadata ()

    gchar *
    gedit_document_get_metadata (GeditDocument *doc,
                                 const gchar *key);

Gets the metadata assigned to `key` .

#### Parameters

doc | a GeditDocument |
key | name of the key |

#### Returns

the value assigned to `key` . Free with `g_free()`.

### gedit_document_set_metadata ()

    void
    gedit_document_set_metadata (GeditDocument *doc,
                                 const gchar *first_key,
                                 ...);

Sets metadata on a document.

#### Parameters

doc | a GeditDocument |
first_key | name of the first key to set |
... | value for the first key, followed optionally by more key/value pairs, followed by `NULL`. | [allow-none]

### gedit_document_set_search_context ()

    void
    gedit_document_set_search_context (GeditDocument *doc,
                                       GtkSourceSearchContext *search_context);

Sets the new search context for the document. Use this function only when the search occurrences are highlighted. So this function should not be used for background searches. The purpose is to have only one highlighted search context at a time in the document.

After using this function, you should unref the `search_context` . The `doc` should be the only owner of the `search_context` , so that the Clear Highlight action works. If you need the `search_context` after calling this function, use `gedit_document_get_search_context()`.

#### Parameters

doc | a GeditDocument |
search_context | the new GtkSourceSearchContext. | [allow-none]

### gedit_document_get_search_context ()

    GtkSourceSearchContext *
    gedit_document_get_search_context (GeditDocument *doc);

Gets the search context. Use this function only if you have used `gedit_document_set_search_context()` before. You should not alter other search contexts, so you have to verify that the returned search context is yours. One way to verify that is to compare the search settings object, or to mark the search context with `g_object_set_data()`.

#### Parameters

doc | a GeditDocument |

#### Returns

the current search context of the document, or NULL if there is no current search context.

[transfer none]

## Types and Values

### GeditDocument

    typedef struct _GeditDocument GeditDocument;

## Property Details

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

      “content-type”             gchar *

The document's content type.

Flags: Read / Write

Default value: NULL

### The `“empty-search”` property

      “empty-search”             gboolean

The property is used internally by gedit. It must not be used in a gedit plugin. The property can be modified or removed at any time.

Flags: Read

Default value: TRUE

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

      “mime-type”                gchar *

The document's MIME type.

Flags: Read

Default value: "text/plain"

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

      “read-only”                gboolean

Whether the document is read-only or not.

`GeditDocument:read-only` has been deprecated since version 3.18 and should not be used in newly-written code.

Use the GtkSourceFile API.

Flags: Read

Default value: FALSE

### The `“shortname”` property

      “shortname”                gchar *

The document's short name.

Flags: Read / Write

Default value: NULL

### The `“use-gvfs-metadata”` property

      “use-gvfs-metadata”        gboolean

Whether to use GVFS metadata. If `FALSE`, use the gedit metadata manager that stores the metadata in an XML file in the user cache directory.

The property is used internally by gedit. It must not be used in a gedit plugin. The property can be modified or removed at any time.

Flags: Read / Write / Construct Only

Default value: TRUE

## Signal Details

### The `“cursor-moved”` signal

    void
    user_function (GeditDocument *geditdocument,
                   gpointer       user_data)

Flags: Run Last

### The `“load”` signal

    void
    user_function (GeditDocument *document,
                   gpointer       user_data)

The "load" signal is emitted at the beginning of a file loading.

Before gedit 3.14 this signal contained parameters to configure the file loading (the location, encoding, etc). Plugins should not need those parameters.

#### Parameters

document | the GeditDocument. |
user_data | user data set when the signal handler was connected. |

Flags: Run Last

Since: 2.22

### The `“loaded”` signal

    void
    user_function (GeditDocument *document,
                   gpointer       user_data)

The "loaded" signal is emitted at the end of a successful file loading.

Before gedit 3.14 this signal contained a GError parameter, and the signal was also emitted if an error occurred. Plugins should not need the error parameter.

#### Parameters

document | the GeditDocument. |
user_data | user data set when the signal handler was connected. |

Flags: Run First

### The `“save”` signal

    void
    user_function (GeditDocument *document,
                   gpointer       user_data)

The "save" signal is emitted at the beginning of a file saving.

Before gedit 3.14 this signal contained parameters to configure the file saving (the location, encoding, etc). Plugins should not need those parameters.

#### Parameters

document | the GeditDocument. |
user_data | user data set when the signal handler was connected. |

Flags: Run Last

Since: 2.20

### The `“saved”` signal

    void
    user_function (GeditDocument *document,
                   gpointer       user_data)

The "saved" signal is emitted at the end of a successful file saving.

Before gedit 3.14 this signal contained a GError parameter, and the signal was also emitted if an error occurred. To save a document, a plugin can use the `gedit_commands_save_document_async()` function and get the result of the operation with `gedit_commands_save_document_finish()`.

#### Parameters

document | the GeditDocument. |
user_data | user data set when the signal handler was connected. |

Flags: Run First