GtkColorButton

GtkColorButton — A button to launch a color selection dialog

Properties

guint alpha Read / Write
GdkColor * color Read / Write
GdkRGBA * rgba Read / Write
gboolean show-editor Read / Write
char * title Read / Write
gboolean use-alpha Read / Write

Signals

void color-set Run First

Types and Values

Object Hierarchy

    GObject
    ╰── GInitiallyUnowned
        ╰── GtkWidget
            ╰── GtkContainer
                ╰── GtkBin
                    ╰── GtkButton
                        ╰── GtkColorButton

Implemented Interfaces

GtkColorButton implements AtkImplementorIface, GtkBuildable, GtkActionable, GtkActivatable and GtkColorChooser.

Includes

#include <gtk/gtk.h>

Description

The GtkColorButton is a button which displays the currently selected color and allows to open a color selection dialog to change the color. It is suitable widget for selecting a color in a preference dialog.

CSS nodes

GtkColorButton has a single CSS node with name button. To differentiate it from a plain GtkButton, it gets the .color style class.

Functions

gtk_color_button_new ()

GtkWidget *
gtk_color_button_new (void);

Creates a new color button.

This returns a widget in the form of a small button containing a swatch representing the current selected color. When the button is clicked, a color-selection dialog will open, allowing the user to select a color. The swatch will be updated to reflect the new color when the user finishes.

Returns

a new color button

Since: 2.4

gtk_color_button_new_with_color ()

GtkWidget *
gtk_color_button_new_with_color (const GdkColor *color);

gtk_color_button_new_with_color has been deprecated since version 3.4 and should not be used in newly-written code.

Use gtk_color_button_new_with_rgba() instead.

Creates a new color button.

Parameters

color

A GdkColor to set the current color with

Returns

a new color button

Since: 2.4

gtk_color_button_new_with_rgba ()

GtkWidget *
gtk_color_button_new_with_rgba (const GdkRGBA *rgba);

Creates a new color button.

Parameters

rgba

A GdkRGBA to set the current color with

Returns

a new color button

Since: 3.0

gtk_color_button_set_color ()

void
gtk_color_button_set_color (GtkColorButton *button,
                            const GdkColor *color);

gtk_color_button_set_color is deprecated and should not be used in newly-written code.

Use gtk_color_chooser_set_rgba() instead.

Sets the current color to be color .

Parameters

button

a GtkColorButton

color

A GdkColor to set the current color with

Since: 2.4

gtk_color_button_get_color ()

void
gtk_color_button_get_color (GtkColorButton *button,
                            GdkColor *color);

gtk_color_button_get_color has been deprecated since version 3.4 and should not be used in newly-written code.

Use gtk_color_chooser_get_rgba() instead.

Sets color to be the current color in the GtkColorButton widget.

Parameters

button

a GtkColorButton

color

a GdkColor to fill in with the current color.

[out]

Since: 2.4

gtk_color_button_set_alpha ()

void
gtk_color_button_set_alpha (GtkColorButton *button,
                            guint16 alpha);

gtk_color_button_set_alpha has been deprecated since version 3.4 and should not be used in newly-written code.

Use gtk_color_chooser_set_rgba() instead.

Sets the current opacity to be alpha .

Parameters

button

a GtkColorButton

alpha

an integer between 0 and 65535

Since: 2.4

gtk_color_button_get_alpha ()

guint16
gtk_color_button_get_alpha (GtkColorButton *button);

gtk_color_button_get_alpha has been deprecated since version 3.4 and should not be used in newly-written code.

Use gtk_color_chooser_get_rgba() instead.

Returns the current alpha value.

Parameters

button

a GtkColorButton

Returns

an integer between 0 and 65535

Since: 2.4

gtk_color_button_set_rgba ()

void
gtk_color_button_set_rgba (GtkColorButton *button,
                           const GdkRGBA *rgba);

gtk_color_button_set_rgba has been deprecated since version 3.4 and should not be used in newly-written code.

Use gtk_color_chooser_set_rgba() instead.

Sets the current color to be rgba .

[skip]

Parameters

button

a GtkColorButton

rgba

a GdkRGBA to set the current color with

Since: 3.0

gtk_color_button_get_rgba ()

void
gtk_color_button_get_rgba (GtkColorButton *button,
                           GdkRGBA *rgba);

gtk_color_button_get_rgba has been deprecated since version 3.4 and should not be used in newly-written code.

Use gtk_color_chooser_get_rgba() instead.

Sets rgba to be the current color in the GtkColorButton widget.

[skip]

Parameters

button

a GtkColorButton

rgba

a GdkRGBA to fill in with the current color.

[out]

Since: 3.0

gtk_color_button_set_use_alpha ()

void
gtk_color_button_set_use_alpha (GtkColorButton *button,
                                gboolean use_alpha);

gtk_color_button_set_use_alpha has been deprecated since version 3.4 and should not be used in newly-written code.

Use gtk_color_chooser_set_use_alpha() instead.

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

Parameters

button

a GtkColorButton

use_alpha

TRUE if color button should use alpha channel, FALSE if not

Since: 2.4

gtk_color_button_get_use_alpha ()

gboolean
gtk_color_button_get_use_alpha (GtkColorButton *button);

gtk_color_button_get_use_alpha has been deprecated since version 3.4 and should not be used in newly-written code.

Use gtk_color_chooser_get_use_alpha() instead.

Does the color selection dialog use the alpha channel ?

Parameters

button

a GtkColorButton

Returns

TRUE if the color sample uses alpha channel, FALSE if not

Since: 2.4

gtk_color_button_set_title ()

void
gtk_color_button_set_title (GtkColorButton *button,
                            const gchar *title);

Sets the title for the color selection dialog.

Parameters

button

a GtkColorButton

title

String containing new window title

Since: 2.4

gtk_color_button_get_title ()

const gchar *
gtk_color_button_get_title (GtkColorButton *button);

Gets the title of the color selection dialog.

Parameters

button

a GtkColorButton

Returns

An internal string, do not free the return value

Since: 2.4

Types and Values

struct GtkColorButton

struct GtkColorButton;

Property Details

The “alpha” property

  “alpha”                    guint

The selected opacity value (0 fully transparent, 65535 fully opaque).

Owner: GtkColorButton

Flags: Read / Write

Allowed values: <= 65535

Default value: 65535

Since: 2.4

The “color” property

  “color”                    GdkColor *

The selected color.

GtkColorButton:color has been deprecated since version 3.4 and should not be used in newly-written code.

Use “rgba” instead.

Owner: GtkColorButton

Flags: Read / Write

Since: 2.4

The “rgba” property

  “rgba”                     GdkRGBA *

The RGBA color.

Owner: GtkColorButton

Flags: Read / Write

Since: 3.0

The “show-editor” property

  “show-editor”              gboolean

Set this property to TRUE to skip the palette in the dialog and go directly to the color editor.

This property should be used in cases where the palette in the editor would be redundant, such as when the color button is already part of a palette.

Owner: GtkColorButton

Flags: Read / Write

Default value: FALSE

Since: 3.20

The “title” property

  “title”                    char *

The title of the color selection dialog

Owner: GtkColorButton

Flags: Read / Write

Default value: "Pick a Color"

Since: 2.4

The “use-alpha” property

  “use-alpha”                gboolean

If this property is set to TRUE, the color swatch on the button is rendered against a checkerboard background to show its opacity and the opacity slider is displayed in the color selection dialog.

Owner: GtkColorButton

Flags: Read / Write

Default value: FALSE

Since: 2.4

Signal Details

The “color-set” signal

void
user_function (GtkColorButton *widget,
               gpointer        user_data)

The ::color-set signal is emitted when the user selects a color. When handling this signal, use gtk_color_button_get_rgba() to find out which color was just selected.

Note that this signal is only emitted when the user changes the color. If you need to react to programmatic color changes as well, use the notify::color signal.

Parameters

widget

the object which received the signal.

user_data

user data set when the signal handler was connected.

Flags: Run First

Since: 2.4

© 2005–2020 The GNOME Project
Licensed under the GNU Lesser General Public License version 2.1 or later.
https://developer.gnome.org/gtk3/3.24/GtkColorButton.html