ide-file: Builder SDK Reference

## ide-file ide-file |

## Functions

IdeFile * | ide_file_new ()
IdeFile * | ide_file_new_for_path ()
gboolean | ide_file_get_is_temporary ()
guint | ide_file_get_temporary_id ()
GtkSourceLanguage * | ide_file_get_language ()
const gchar * | ide_file_get_language_id ()
GFile * | ide_file_get_file ()
guint | ide_file_hash ()
gboolean | ide_file_equal ()
const gchar * | ide_file_get_path ()
void | ide_file_load_settings_async ()
IdeFileSettings * | ide_file_load_settings_finish ()
IdeFileSettings * | ide_file_peek_settings ()
void | ide_file_find_other_async ()
IdeFile * | ide_file_find_other_finish ()
gint | ide_file_compare ()

## Properties

GFile * | file | Read / Write / Construct Only
gboolean | is-temporary | Read
GtkSourceLanguage * | language | Read
gchar * | path | Read / Write / Construct Only
guint | temporary-id | Read / Write / Construct Only

## Types and Values

#define | IDE_TYPE_FILE
#define | IDE_FILE_ATTRIBUTE_POSITION
| IdeFile

## Object Hierarchy

        GObject
        ╰── IdeObject
            ╰── IdeFile

## Description

## Functions

### ide_file_new ()

    IdeFile *
    ide_file_new (IdeContext *context,
                  GFile *file);

Creates a new file.

#### Parameters

context | An IdeContext or `NULL`. | [allow-none]
file | a GFile. |

#### Returns

An IdeFile.

[transfer full]

### ide_file_new_for_path ()

    IdeFile *
    ide_file_new_for_path (IdeContext *context,
                           const gchar *path);

### ide_file_get_is_temporary ()

    gboolean
    ide_file_get_is_temporary (IdeFile *self);

### ide_file_get_temporary_id ()

    guint
    ide_file_get_temporary_id (IdeFile *self);

Gets the “temporary-id” property for the file.

Temporary files have unique identifiers associated with them so that we can display names such as "unsaved file 1" and know that it will not collide with another temporary file.

Files that are not temporary, will return zero.

#### Parameters

self | an IdeFile. | [in]

#### Returns

A positive integer greater than zero if the file is a temporary file.

### ide_file_get_language ()

    GtkSourceLanguage *
    ide_file_get_language (IdeFile *self);

Retrieves the GtkSourceLanguage that was discovered for the file.

#### Returns

a GtkSourceLanguage or `NULL`.

[nullable][transfer none]

### ide_file_get_language_id ()

    const gchar *
    ide_file_get_language_id (IdeFile *self);

### ide_file_get_file ()

    GFile *
    ide_file_get_file (IdeFile *self);

Retrieves the underlying GFile represented by `self` .

#### Returns

a GFile.

[transfer none]

### ide_file_hash ()

    guint
    ide_file_hash (IdeFile *self);

### ide_file_equal ()

    gboolean
    ide_file_equal (IdeFile *self,
                    IdeFile *other);

### ide_file_get_path ()

    const gchar *
    ide_file_get_path (IdeFile *self);

### ide_file_load_settings_async ()

    void
    ide_file_load_settings_async (IdeFile *self,
                                  GCancellable *cancellable,
                                  GAsyncReadyCallback callback,
                                  gpointer user_data);

### ide_file_load_settings_finish ()

    IdeFileSettings *
    ide_file_load_settings_finish (IdeFile *self,
                                   GAsyncResult *result,
                                   GError **error);

#### Returns

An IdeFileSettings or `NULL` upon failure and `error` is set.

[transfer full]

### ide_file_peek_settings ()

    IdeFileSettings *
    ide_file_peek_settings (IdeFile *self);

Returns the IdeFileSettings if they've been loaded.

#### Parameters

self | a IdeFile |

#### Returns

an IdeFileSettings or `NULL`.

[nullable][transfer none]

Since: 3.28

### ide_file_find_other_async ()

    void
    ide_file_find_other_async (IdeFile *self,
                               GCancellable *cancellable,
                               GAsyncReadyCallback callback,
                               gpointer user_data);

### ide_file_find_other_finish ()

    IdeFile *
    ide_file_find_other_finish (IdeFile *self,
                                GAsyncResult *result,
                                GError **error);

Completes an asynchronous call to `ide_file_find_other_async()`. This function will try to find a matching file for languages where this exists. Such cases include C and C++ where a .c or .cpp file may have a .h or .hh header. Additional suffixes are implemented including (.c, .cc, .cpp, .cxx, .h, .hh, .hpp, and .hxx).

Returns an IdeFile if successful, otherwise `NULL` and `error` is set.

#### Returns

An IdeFIle or `NULL`.

[transfer full][nullable]

### ide_file_compare ()

    gint
    ide_file_compare (const IdeFile *a,
                      const IdeFile *b);

## Types and Values

### IDE_TYPE_FILE

    #define IDE_TYPE_FILE (ide_file_get_type())

### IDE_FILE_ATTRIBUTE_POSITION

    #define IDE_FILE_ATTRIBUTE_POSITION "metadata::libide-position"

### IdeFile

    typedef struct _IdeFile IdeFile;

## Property Details

### The `“file”` property

      “file”                     GFile *

The path to the underlying file.

Flags: Read / Write / Construct Only

### The `“is-temporary”` property

      “is-temporary”             gboolean

If the file represents a temporary file.

Flags: Read

Default value: FALSE

### The `“language”` property

      “language”                 GtkSourceLanguage *

The file language.

Flags: Read

### The `“path”` property

      “path”                     gchar *

The path within the project.

Flags: Read / Write / Construct Only

Default value: NULL

### The `“temporary-id”` property

      “temporary-id”             guint

A unique identifier for temporary files.

Flags: Read / Write / Construct Only

Default value: 0