## GtkColorChooser GtkColorChooser — Interface implemented by widgets for choosing colors |

## Synopsis

    #include <gtk/gtk.h>

                        GtkColorChooser;
    void                gtk_color_chooser_get_rgba          (GtkColorChooser *chooser,
                                                             GdkRGBA *color);
    void                gtk_color_chooser_set_rgba          (GtkColorChooser *chooser,
                                                             const GdkRGBA *color);
    gboolean            gtk_color_chooser_get_use_alpha     (GtkColorChooser *chooser);
    void                gtk_color_chooser_set_use_alpha     (GtkColorChooser *chooser,
                                                             gboolean use_alpha);
    void                gtk_color_chooser_add_palette       (GtkColorChooser *chooser,
                                                             GtkOrientation orientation,
                                                             gint colors_per_line,
                                                             gint n_colors,
                                                             GdkRGBA *colors);

## Object Hierarchy

      GInterface
       +----GtkColorChooser

## Prerequisites

GtkColorChooser requires GObject.

## Known Implementations

GtkColorChooser is implemented by GtkColorButton, GtkColorChooserDialog and GtkColorChooserWidget.

## Properties

      "rgba"                     GdkRGBA*              : Read / Write
      "use-alpha"                gboolean              : Read / Write

## Signals

      "color-activated"                                : Run First

## Description

GtkColorChooser is an interface that is implemented by widgets for choosing colors. Depending on the situation, colors may be allowed to have alpha (translucency).

In GTK+, the main widgets that implement this interface are GtkColorChooserWidget, GtkColorChooserDialog and GtkColorButton.

## Details

### GtkColorChooser

    typedef struct _GtkColorChooser GtkColorChooser;

### gtk_color_chooser_get_rgba ()

    void                gtk_color_chooser_get_rgba          (GtkColorChooser *chooser,
                                                             GdkRGBA *color);

Gets the currently-selected color.

`chooser` : | a GtkColorChooser
`color` : | return location for the color

Since 3.4

### gtk_color_chooser_set_rgba ()

    void                gtk_color_chooser_set_rgba          (GtkColorChooser *chooser,
                                                             const GdkRGBA *color);

Sets the color.

`chooser` : | a GtkColorChooser
`color` : | the new color

Since 3.4

### gtk_color_chooser_get_use_alpha ()

    gboolean            gtk_color_chooser_get_use_alpha     (GtkColorChooser *chooser);

Returns whether the color chooser shows the alpha channel.

`chooser` : | a GtkColorChooser
Returns : | `TRUE` if the color chooser uses the alpha channel, `FALSE` if not

Since 3.4

### gtk_color_chooser_set_use_alpha ()

    void                gtk_color_chooser_set_use_alpha     (GtkColorChooser *chooser,
                                                             gboolean use_alpha);

Sets whether or not the color chooser should use the alpha channel.

`chooser` : | a GtkColorChooser
`use_alpha` : | `TRUE` if color chooser should use alpha channel, `FALSE` if not

Since 3.4

### gtk_color_chooser_add_palette ()

    void                gtk_color_chooser_add_palette       (GtkColorChooser *chooser,
                                                             GtkOrientation orientation,
                                                             gint colors_per_line,
                                                             gint n_colors,
                                                             GdkRGBA *colors);

Adds a palette to the color chooser. If `orientation` is horizontal, the colors are grouped in rows, with `colors_per_line` colors in each row. If `horizontal` is `FALSE`, the colors are grouped in columns instead.

The default color palette of GtkColorChooserWidget has 27 colors, organized in columns of 3 colors. The default gray palette has 9 grays in a single row.

The layout of the color chooser widget works best when the palettes have 9-10 columns.

Calling this function for the first time has the side effect of removing the default color and gray palettes from the color chooser.

If `colors` is `NULL`, removes all previously added palettes.

`chooser` : | a GtkColorChooser
`orientation` : | `GTK_ORIENTATION_HORIZONTAL` if the palette should be displayed in rows, `GTK_ORIENTATION_VERTICAL` for columns
`colors_per_line` : | the number of colors to show in each row/column
`n_colors` : | the total number of elements in `colors`
`colors` : | the colors of the palette, or `NULL`. [allow-none][array length=n_colors]

Since 3.4

## Property Details

### The `"rgba"` property

      "rgba"                     GdkRGBA*              : Read / Write

The ::rgba property contains the currently selected color, as a GdkRGBA struct. The property can be set to change the current selection programmatically.

Since 3.4

### The `"use-alpha"` property

      "use-alpha"                gboolean              : Read / Write

When ::use-alpha is `TRUE`, colors may have alpha (translucency) information. When it is `FALSE`, the GdkRGBA struct obtained via the "rgba" property will be forced to have alpha == 1.

Implementations are expected to show alpha by rendering the color over a non-uniform background (like a checkerboard pattern).

Default value: TRUE

Since 3.4

## Signal Details

### The `"color-activated"` signal

    void                user_function                      (GtkColorChooser *chooser,
                                                            GdkRGBA         *color,
                                                            gpointer         user_data)      : Run First

Emitted when a color is activated from the color chooser. This usually happens when the user clicks a color swatch, or a color is selected and the user presses one of the keys Space, Shift+Space, Return or Enter.

`chooser` : | the object which received the signal
`color` : | the color
`user_data` : | user data set when the signal handler was connected.

Since 3.4

## See Also

GtkColorChooserDialog, GtkColorChooserWidget, GtkColorButton