gimpenv

## gimpenv gimpenv — Functions to access the GIMP environment. |

## Synopsis

    void                gimp_env_init                       (gboolean plug_in);
    const gchar*        gimp_directory                      (void);
    const gchar*        gimp_data_directory                 (void);
    const gchar*        gimp_locale_directory               (void);
    const gchar*        gimp_plug_in_directory              (void);
    const gchar*        gimp_sysconf_directory              (void);
    const gchar*        gimp_user_directory                 (GimpUserDirectory type);
    gchar*              gimp_personal_rc_file               (const gchar *basename);
    const gchar*        gimp_gtkrc                          (void);
    GList*              gimp_path_parse                     (const gchar *path,
                                                             gint max_paths,
                                                             gboolean check,
                                                             GList **check_failed);
    gchar*              gimp_path_to_str                    (GList *path);
    void                gimp_path_free                      (GList *path);
    gchar*              gimp_path_get_user_writable_dir     (GList *path);

## Description

A set of functions to find the locations of GIMP's data directories and configuration files.

## Details

### gimp_env_init ()

    void                gimp_env_init                       (gboolean plug_in);

You don't need to care about this function. It is being called for you automatically (by means of the `MAIN()` macro that every plug-in runs). Calling it again will cause a fatal error.

`plug_in` : | must be `TRUE` if this function is called from a plug-in

Since GIMP 2.4

### gimp_directory ()

    const gchar*        gimp_directory                      (void);

Returns the user-specific GIMP settings directory. If the environment variable GIMP2_DIRECTORY exists, it is used. If it is an absolute path, it is used as is. If it is a relative path, it is taken to be a subdirectory of the home directory. If it is a relative path, and no home directory can be determined, it is taken to be a subdirectory of `gimp_data_directory()`.

The usual case is that no GIMP2_DIRECTORY environment variable exists, and then we use the GIMPDIR subdirectory of the home directory. If no home directory exists, we use a per-user subdirectory of `gimp_data_directory()`. In any case, we always return some non-empty string, whether it corresponds to an existing directory or not.

The returned string is owned by GIMP and must not be modified or freed. The returned string is in the encoding used for filenames by GLib, which isn't necessarily UTF-8. (On Windows it always is UTF-8.)

Returns : | The user-specific GIMP settings directory.

### gimp_data_directory ()

    const gchar*        gimp_data_directory                 (void);

Returns the top directory for GIMP data. If the environment variable GIMP2_DATADIR exists, that is used. It should be an absolute pathname. Otherwise, on Unix the compile-time defined directory is used. On Windows, the installation directory as deduced from the executable's full filename is used.

The returned string is owned by GIMP and must not be modified or freed. The returned string is in the encoding used for filenames by GLib, which isn't necessarily UTF-8. (On Windows it always is UTF-8.)

Returns : | The top directory for GIMP data.

### gimp_locale_directory ()

    const gchar*        gimp_locale_directory               (void);

Returns the top directory for GIMP locale files. If the environment variable GIMP2_LOCALEDIR exists, that is used. It should be an absolute pathname. Otherwise, on Unix the compile-time defined directory is used. On Windows, the installation directory as deduced from the executable's full filename is used.

The returned string is owned by GIMP and must not be modified or freed. The returned string is in the encoding used for filenames by the C library, which isn't necessarily UTF-8. (On Windows, unlike the other similar functions here, the return value from this function is in the system codepage, never in UTF-8. It can thus be passed directly to the `bindtextdomain()` function from libintl which does not handle UTF-8.)

Returns : | The top directory for GIMP locale files.

### gimp_plug_in_directory ()

    const gchar*        gimp_plug_in_directory              (void);

Returns the top directory for GIMP plug_ins and modules. If the environment variable GIMP2_PLUGINDIR exists, that is used. It should be an absolute pathname. Otherwise, on Unix the compile-time defined directory is used. On Windows, the installation directory as deduced from the executable's full filename is used.

The returned string is owned by GIMP and must not be modified or freed. The returned string is in the encoding used for filenames by GLib, which isn't necessarily UTF-8. (On Windows it always is UTF-8.)

Returns : | The top directory for GIMP plug_ins and modules.

### gimp_sysconf_directory ()

    const gchar*        gimp_sysconf_directory              (void);

Returns the top directory for GIMP config files. If the environment variable GIMP2_SYSCONFDIR exists, that is used. It should be an absolute pathname. Otherwise, on Unix the compile-time defined directory is used. On Windows, the installation directory as deduced from the executable's full filename is used.

The returned string is owned by GIMP and must not be modified or freed. The returned string is in the encoding used for filenames by GLib, which isn't necessarily UTF-8. (On Windows it always is UTF-8.).

Returns : | The top directory for GIMP config files.

### gimp_user_directory ()

    const gchar*        gimp_user_directory                 (GimpUserDirectory type);

Identifies special folders used frequently by applications, but which may not have the same name or location on any given system.

Plug-ins may want to use this function to add shortcuts to such folders to a file-chooser.

`type` : | the type of user directory to retrieve
Returns : | The path to the specified user directory, or `NULL` if the logical ID was not found.

Since GIMP 2.4

### gimp_personal_rc_file ()

    gchar*              gimp_personal_rc_file               (const gchar *basename);

Returns the name of a file in the user-specific GIMP settings directory.

The returned string is allocated dynamically and *SHOULD* be freed with `g_free()` after use. The returned string is in the encoding used for filenames by GLib, which isn't necessarily UTF-8. (On Windows it always is UTF-8.)

`basename` : | The basename of a rc_file.
Returns : | The name of a file in the user-specific GIMP settings directory.

### gimp_gtkrc ()

    const gchar*        gimp_gtkrc                          (void);

Returns the name of GIMP's application-specific gtkrc file.

The returned string is owned by GIMP and must not be modified or freed. The returned string is in the encoding used for filenames by GLib, which isn't necessarily UTF-8. (On Windows it always is UTF-8.)

Returns : | The name of GIMP's application-specific gtkrc file.

### gimp_path_parse ()

    GList*              gimp_path_parse                     (const gchar *path,
                                                             gint max_paths,
                                                             gboolean check,
                                                             GList **check_failed);

`path` : | A list of directories separated by G_SEARCHPATH_SEPARATOR.
`max_paths` : | The maximum number of directories to return.
`check` : | `TRUE` if you want the directories to be checked.
`check_failed` : | Returns a GList of path elements for which the check failed.
Returns : | A GList of all directories in `path`.

### gimp_path_to_str ()

    gchar*              gimp_path_to_str                    (GList *path);

`path` : | A list of directories as returned by `gimp_path_parse()`.
Returns : | A searchpath string separated by G_SEARCHPATH_SEPARATOR.

### gimp_path_free ()

    void                gimp_path_free                      (GList *path);

This function frees the memory allocated for the list and the strings it contains.

`path` : | A list of directories as returned by `gimp_path_parse()`.

### gimp_path_get_user_writable_dir ()

    gchar*              gimp_path_get_user_writable_dir     (GList *path);

Note that you have to `g_free()` the returned string.

`path` : | A list of directories as returned by `gimp_path_parse()`.
Returns : | The first directory in `path` where the user has write permission.