## gimpcontext gimpcontext — Functions to manipulate a plug-in's context. |

## Synopsis

    gboolean            gimp_context_push                   (void);
    gboolean            gimp_context_pop                    (void);
    gboolean            gimp_context_get_foreground         (GimpRGB *foreground);
    gboolean            gimp_context_set_foreground         (const GimpRGB *foreground);
    gboolean            gimp_context_get_background         (GimpRGB *background);
    gboolean            gimp_context_set_background         (const GimpRGB *background);
    gboolean            gimp_context_set_default_colors     (void);
    gboolean            gimp_context_swap_colors            (void);
    gdouble             gimp_context_get_opacity            (void);
    gboolean            gimp_context_set_opacity            (gdouble opacity);
    GimpLayerModeEffects gimp_context_get_paint_mode        (void);
    gboolean            gimp_context_set_paint_mode         (GimpLayerModeEffects paint_mode);
    gchar*              gimp_context_get_brush              (void);
    gboolean            gimp_context_set_brush              (const gchar *name);
    gchar*              gimp_context_get_pattern            (void);
    gboolean            gimp_context_set_pattern            (const gchar *name);
    gchar*              gimp_context_get_gradient           (void);
    gboolean            gimp_context_set_gradient           (const gchar *name);
    gchar*              gimp_context_get_palette            (void);
    gboolean            gimp_context_set_palette            (const gchar *name);
    gchar*              gimp_context_get_font               (void);
    gboolean            gimp_context_set_font               (const gchar *name);
    gchar*              gimp_context_get_paint_method       (void);
    gboolean            gimp_context_set_paint_method       (const gchar *name);
    gboolean            gimp_context_list_paint_methods     (gint *num_paint_methods,
                                                             gchar ***paint_methods);

## Description

Functions to manipulate a plug-in's context.

## Details

### gimp_context_push ()

    gboolean            gimp_context_push                   (void);

Pushes a context to the top of the plug-in's context stack.

This procedure creates a new context by copying the current context. This copy becomes the new current context for the calling plug-in until it is popped again using `gimp_context_pop()`.

Returns : | TRUE on success.

Since GIMP 2.2

### gimp_context_pop ()

    gboolean            gimp_context_pop                    (void);

Pops the topmost context from the plug-in's context stack.

This procedure removes the topmost context from the plug-in's context stack. The context that was active before the corresponding call to `gimp_context_push()` becomes the new current context of the plug-in.

Returns : | TRUE on success.

Since GIMP 2.2

### gimp_context_get_foreground ()

    gboolean            gimp_context_get_foreground         (GimpRGB *foreground);

Get the current GIMP foreground color.

This procedure returns the current GIMP foreground color. The foreground color is used in a variety of tools such as paint tools, blending, and bucket fill.

`foreground` : | The foreground color.
Returns : | TRUE on success.

Since GIMP 2.2

### gimp_context_set_foreground ()

    gboolean            gimp_context_set_foreground         (const GimpRGB *foreground);

Set the current GIMP foreground color.

This procedure sets the current GIMP foreground color. After this is set, operations which use foreground such as paint tools, blending, and bucket fill will use the new value.

`foreground` : | The foreground color.
Returns : | TRUE on success.

Since GIMP 2.2

### gimp_context_get_background ()

    gboolean            gimp_context_get_background         (GimpRGB *background);

Get the current GIMP background color.

This procedure returns the current GIMP background color. The background color is used in a variety of tools such as blending, erasing (with non-alpha images), and image filling.

`background` : | The background color.
Returns : | TRUE on success.

Since GIMP 2.2

### gimp_context_set_background ()

    gboolean            gimp_context_set_background         (const GimpRGB *background);

Set the current GIMP background color.

This procedure sets the current GIMP background color. After this is set, operations which use background such as blending, filling images, clearing, and erasing (in non-alpha images) will use the new value.

`background` : | The background color.
Returns : | TRUE on success.

Since GIMP 2.2

### gimp_context_set_default_colors ()

    gboolean            gimp_context_set_default_colors     (void);

Set the current GIMP foreground and background colors to black and white.

This procedure sets the current GIMP foreground and background colors to their initial default values, black and white.

Returns : | TRUE on success.

Since GIMP 2.2

### gimp_context_swap_colors ()

    gboolean            gimp_context_swap_colors            (void);

Swap the current GIMP foreground and background colors.

This procedure swaps the current GIMP foreground and background colors, so that the new foreground color becomes the old background color and vice versa.

Returns : | TRUE on success.

Since GIMP 2.2

### gimp_context_get_opacity ()

    gdouble             gimp_context_get_opacity            (void);

Get the opacity.

This procedure returns the opacity setting. The return value is a floating point number between 0 and 100.

Returns : | The opacity.

Since GIMP 2.2

### gimp_context_set_opacity ()

    gboolean            gimp_context_set_opacity            (gdouble opacity);

Set the opacity.

This procedure modifies the opacity setting. The value should be a floating point number between 0 and 100.

`opacity` : | The opacity.
Returns : | TRUE on success.

Since GIMP 2.2

### gimp_context_get_paint_mode ()

    GimpLayerModeEffects gimp_context_get_paint_mode        (void);

Get the paint mode.

This procedure returns the paint-mode setting. The return value is an integer which corresponds to the values listed in the argument description.

Returns : | The paint mode.

Since GIMP 2.2

### gimp_context_set_paint_mode ()

    gboolean            gimp_context_set_paint_mode         (GimpLayerModeEffects paint_mode);

Set the paint mode.

This procedure modifies the paint_mode setting.

`paint_mode` : | The paint mode.
Returns : | TRUE on success.

Since GIMP 2.2

### gimp_context_get_brush ()

    gchar*              gimp_context_get_brush              (void);

Retrieve the currently active brush.

This procedure returns the name of the currently active brush. All paint operations and stroke operations use this brush to control the application of paint to the image.

Returns : | The name of the active brush.

Since GIMP 2.2

### gimp_context_set_brush ()

    gboolean            gimp_context_set_brush              (const gchar *name);

Set the specified brush as the active brush.

This procedure allows the active brush to be set by specifying its name. The name is simply a string which corresponds to one of the names of the installed brushes. If there is no matching brush found, this procedure will return an error. Otherwise, the specified brush becomes active and will be used in all subsequent paint operations.

`name` : | The name of the brush.
Returns : | TRUE on success.

Since GIMP 2.2

### gimp_context_get_pattern ()

    gchar*              gimp_context_get_pattern            (void);

Retrieve the currently active pattern.

This procedure returns name of the the currently active pattern. All clone and bucket-fill operations with patterns will use this pattern to control the application of paint to the image.

Returns : | The name of the active pattern.

Since GIMP 2.2

### gimp_context_set_pattern ()

    gboolean            gimp_context_set_pattern            (const gchar *name);

Set the specified pattern as the active pattern.

This procedure allows the active pattern to be set by specifying its name. The name is simply a string which corresponds to one of the names of the installed patterns. If there is no matching pattern found, this procedure will return an error. Otherwise, the specified pattern becomes active and will be used in all subsequent paint operations.

`name` : | The name of the pattern.
Returns : | TRUE on success.

Since GIMP 2.2

### gimp_context_get_gradient ()

    gchar*              gimp_context_get_gradient           (void);

Retrieve the currently active gradient.

This procedure returns the name of the currently active gradient.

Returns : | The name of the active gradient.

Since GIMP 2.2

### gimp_context_set_gradient ()

    gboolean            gimp_context_set_gradient           (const gchar *name);

Sets the specified gradient as the active gradient.

This procedure lets you set the specified gradient as the active or \"current\" one. The name is simply a string which corresponds to one of the loaded gradients. If no matching gradient is found, this procedure will return an error. Otherwise, the specified gradient will become active and will be used for subsequent custom gradient operations.

`name` : | The name of the gradient.
Returns : | TRUE on success.

Since GIMP 2.2

### gimp_context_get_palette ()

    gchar*              gimp_context_get_palette            (void);

Retrieve the currently active palette.

This procedure returns the name of the the currently active palette.

Returns : | The name of the active palette.

Since GIMP 2.2

### gimp_context_set_palette ()

    gboolean            gimp_context_set_palette            (const gchar *name);

Set the specified palette as the active palette.

This procedure allows the active palette to be set by specifying its name. The name is simply a string which corresponds to one of the names of the installed palettes. If no matching palette is found, this procedure will return an error. Otherwise, the specified palette becomes active and will be used in all subsequent palette operations.

`name` : | The name of the palette.
Returns : | TRUE on success.

Since GIMP 2.2

### gimp_context_get_font ()

    gchar*              gimp_context_get_font               (void);

Retrieve the currently active font.

This procedure returns the name of the currently active font.

Returns : | The name of the active font.

Since GIMP 2.2

### gimp_context_set_font ()

    gboolean            gimp_context_set_font               (const gchar *name);

Set the specified font as the active font.

This procedure allows the active font to be set by specifying its name. The name is simply a string which corresponds to one of the names of the installed fonts. If no matching font is found, this procedure will return an error. Otherwise, the specified font becomes active and will be used in all subsequent font operations.

`name` : | The name of the font.
Returns : | TRUE on success.

Since GIMP 2.2

### gimp_context_get_paint_method ()

    gchar*              gimp_context_get_paint_method       (void);

Retrieve the currently active paint method.

This procedure returns the name of the currently active paint method.

Returns : | The name of the active paint method.

Since GIMP 2.4

### gimp_context_set_paint_method ()

    gboolean            gimp_context_set_paint_method       (const gchar *name);

Set the specified paint method as the active paint method.

This procedure allows the active paint method to be set by specifying its name. The name is simply a string which corresponds to one of the names of the available paint methods. If there is no matching method found, this procedure will return an error. Otherwise, the specified method becomes active and will be used in all subsequent paint operations.

`name` : | The name of the paint method.
Returns : | TRUE on success.

Since GIMP 2.4

### gimp_context_list_paint_methods ()

    gboolean            gimp_context_list_paint_methods     (gint *num_paint_methods,
                                                             gchar ***paint_methods);

Lists the available paint methods.

This procedure lists the names of the available paint methods. Any of the results can be used for `gimp_context_set_paint_method()`.

`num_paint_methods` : | The number of the available paint methods.
`paint_methods` : | The names of the available paint methods.
Returns : | TRUE on success.

Since GIMP 2.4