## gimpconfig-iface

gimpconfig-iface — High-level API for libgimpconfig.

## Synopsis

                        GimpConfig;
                        GimpConfigInterface;
    gboolean            gimp_config_serialize_to_file       (GimpConfig *config,
                                                             const gchar *filename,
                                                             const gchar *header,
                                                             const gchar *footer,
                                                             gpointer data,
                                                             GError **error);
    gboolean            gimp_config_serialize_to_fd         (GimpConfig *config,
                                                             gint fd,
                                                             gpointer data);
    gchar *             gimp_config_serialize_to_string     (GimpConfig *config,
                                                             gpointer data);
    gboolean            gimp_config_deserialize_file        (GimpConfig *config,
                                                             const gchar *filename,
                                                             gpointer data,
                                                             GError **error);
    gboolean            gimp_config_deserialize_string      (GimpConfig *config,
                                                             const gchar *text,
                                                             gint text_len,
                                                             gpointer data,
                                                             GError **error);
    gboolean            gimp_config_deserialize_return      (GScanner *scanner,
                                                             GTokenType expected_token,
                                                             gint nest_level);
    gpointer            gimp_config_duplicate               (GimpConfig *config);
    gboolean            gimp_config_is_equal_to             (GimpConfig *a,
                                                             GimpConfig *b);
    void                gimp_config_reset                   (GimpConfig *config);
    gboolean            gimp_config_copy                    (GimpConfig *src,
                                                             GimpConfig *dest,
                                                             GParamFlags flags);

## Object Hierarchy

      GInterface
       +----GimpConfigInterface

## Prerequisites

GimpConfigInterface requires GObject.

## Known Implementations

GimpConfigInterface is implemented by GimpColorConfig.

## Description

High-level API functions for libgimpconfig.

## Details

### GimpConfig

    typedef struct _GimpConfig GimpConfig;

### GimpConfigInterface

    typedef struct _GimpConfigInterface GimpConfigInterface;

### gimp_config_serialize_to_file ()

    gboolean            gimp_config_serialize_to_file       (GimpConfig *config,
                                                             const gchar *filename,
                                                             const gchar *header,
                                                             const gchar *footer,
                                                             gpointer data,
                                                             GError **error);

Serializes the object properties of `config` to the file specified by `filename`. If a file with that name already exists, it is overwritten. Basically this function opens `filename` for you and calls the serialize function of the `config`'s GimpConfigInterface.

`config` : | a GObject that implements the GimpConfigInterface.
`filename` : | the name of the file to write the configuration to.
`header` : | optional file header (must be ASCII only)
`footer` : | optional file footer (must be ASCII only)
`data` : | user data passed to the serialize implementation.
Returns : | `TRUE` if serialization succeeded, `FALSE` otherwise.

Since GIMP 2.4

### gimp_config_serialize_to_fd ()

    gboolean            gimp_config_serialize_to_fd         (GimpConfig *config,
                                                             gint fd,
                                                             gpointer data);

Serializes the object properties of `config` to the given file descriptor.

`config` : | a GObject that implements the GimpConfigInterface.
`fd` : | a file descriptor, opened for writing
`data` : | user data passed to the serialize implementation.
Returns : | `TRUE` if serialization succeeded, `FALSE` otherwise.

Since GIMP 2.4

### gimp_config_serialize_to_string ()

    gchar *             gimp_config_serialize_to_string     (GimpConfig *config,
                                                             gpointer data);

Serializes the object properties of `config` to a string.

`config` : | a GObject that implements the GimpConfigInterface.
`data` : | user data passed to the serialize implementation.
Returns : | a newly allocated `NUL`-terminated string.

Since GIMP 2.4

### gimp_config_deserialize_file ()

    gboolean            gimp_config_deserialize_file        (GimpConfig *config,
                                                             const gchar *filename,
                                                             gpointer data,
                                                             GError **error);

Opens the file specified by `filename`, reads configuration data from it and configures `config` accordingly. Basically this function creates a properly configured GScanner for you and calls the deserialize function of the `config`'s GimpConfigInterface.

`config` : | a GObject that implements the GimpConfigInterface.
`filename` : | the name of the file to read configuration from.
`data` : | user data passed to the deserialize implementation.
Returns : | `TRUE` if deserialization succeeded, `FALSE` otherwise.

Since GIMP 2.4

### gimp_config_deserialize_string ()

    gboolean            gimp_config_deserialize_string      (GimpConfig *config,
                                                             const gchar *text,
                                                             gint text_len,
                                                             gpointer data,
                                                             GError **error);

Configures `config` from `text`. Basically this function creates a properly configured GScanner for you and calls the deserialize function of the `config`'s GimpConfigInterface.

`config` : | a GObject that implements the GimpConfigInterface.
`text` : | string to deserialize (in UTF-8 encoding)
`text_len` : | length of `text` in bytes or -1
Returns : | `TRUE` if deserialization succeeded, `FALSE` otherwise.

Since GIMP 2.4

### gimp_config_deserialize_return ()

    gboolean            gimp_config_deserialize_return      (GScanner *scanner,
                                                             GTokenType expected_token,
                                                             gint nest_level);

Returns : |

Since GIMP 2.4

### gimp_config_duplicate ()

    gpointer            gimp_config_duplicate               (GimpConfig *config);

Creates a copy of the passed object by copying all object properties. The default implementation of the GimpConfigInterface only works for objects that are completely defined by their properties.

`config` : | a GObject that implements the GimpConfigInterface.
Returns : | the duplicated GimpConfig object

Since GIMP 2.4

### gimp_config_is_equal_to ()

    gboolean            gimp_config_is_equal_to             (GimpConfig *a,
                                                             GimpConfig *b);

Compares the two objects. The default implementation of the GimpConfigInterface compares the object properties and thus only works for objects that are completely defined by their properties.

`a` : | a GObject that implements the GimpConfigInterface.
`b` : | another GObject of the same type as `a`.
Returns : | `TRUE` if the two objects are equal.

Since GIMP 2.4

### gimp_config_reset ()

    void                gimp_config_reset                   (GimpConfig *config);

Resets the object to its default state. The default implementation of the GimpConfigInterface only works for objects that are completely defined by their properties.

`config` : | a GObject that implements the GimpConfigInterface.

Since GIMP 2.4

### gimp_config_copy ()

    gboolean            gimp_config_copy                    (GimpConfig *src,
                                                             GimpConfig *dest,
                                                             GParamFlags flags);

Compares all read- and write-able properties from `src` and `dest` that have all `flags` set. Differing values are then copied from `src` to `dest`. If `flags` is 0, all differing read/write properties.

Properties marked as "construct-only" are not touched.

`src` : | a GObject that implements the GimpConfigInterface.
`dest` : | another GObject of the same type as `a`.
`flags` : | a mask of GParamFlags
Returns : | `TRUE` if `dest` was modified, `FALSE` otherwise

Since GIMP 2.6