CtkColorButton

CtkColorButton — A button to launch a color selection dialog

Functions

Properties

guint alpha Read / Write
CdkColor * color Read / Write
CdkRGBA * 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
        ╰── CtkWidget
            ╰── CtkContainer
                ╰── CtkBin
                    ╰── CtkButton
                        ╰── CtkColorButton

Implemented Interfaces

CtkColorButton implements AtkImplementorIface, CtkBuildable, CtkActionable, CtkActivatable and CtkColorChooser.

Includes

#include <ctk/ctk.h>

Description

The CtkColorButton 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

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

Functions

ctk_color_button_new ()

CtkWidget *
ctk_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


ctk_color_button_new_with_color ()

CtkWidget *
ctk_color_button_new_with_color (const CdkColor *color);

Creates a new color button.

Parameters

color

A CdkColor to set the current color with

 

Returns

a new color button

Since: 2.4


ctk_color_button_new_with_rgba ()

CtkWidget *
ctk_color_button_new_with_rgba (const CdkRGBA *rgba);

Creates a new color button.

Parameters

rgba

A CdkRGBA to set the current color with

 

Returns

a new color button

Since: 3.0


ctk_color_button_set_color ()

void
ctk_color_button_set_color (CtkColorButton *button,
                            const CdkColor *color);

Sets the current color to be color .

Parameters

button

a CtkColorButton

 

color

A CdkColor to set the current color with

 

Since: 2.4


ctk_color_button_get_color ()

void
ctk_color_button_get_color (CtkColorButton *button,
                            CdkColor *color);

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

Parameters

button

a CtkColorButton

 

color

a CdkColor to fill in with the current color.

[out]

Since: 2.4


ctk_color_button_set_alpha ()

void
ctk_color_button_set_alpha (CtkColorButton *button,
                            guint16 alpha);

Sets the current opacity to be alpha .

Parameters

button

a CtkColorButton

 

alpha

an integer between 0 and 65535

 

Since: 2.4


ctk_color_button_get_alpha ()

guint16
ctk_color_button_get_alpha (CtkColorButton *button);

Returns the current alpha value.

Parameters

button

a CtkColorButton

 

Returns

an integer between 0 and 65535

Since: 2.4


ctk_color_button_set_rgba ()

void
ctk_color_button_set_rgba (CtkColorButton *button,
                           const CdkRGBA *rgba);

Sets the current color to be rgba .

[skip]

Parameters

button

a CtkColorButton

 

rgba

a CdkRGBA to set the current color with

 

Since: 3.0


ctk_color_button_get_rgba ()

void
ctk_color_button_get_rgba (CtkColorButton *button,
                           CdkRGBA *rgba);

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

[skip]

Parameters

button

a CtkColorButton

 

rgba

a CdkRGBA to fill in with the current color.

[out]

Since: 3.0


ctk_color_button_set_use_alpha ()

void
ctk_color_button_set_use_alpha (CtkColorButton *button,
                                gboolean use_alpha);

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

Parameters

button

a CtkColorButton

 

use_alpha

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

 

Since: 2.4


ctk_color_button_get_use_alpha ()

gboolean
ctk_color_button_get_use_alpha (CtkColorButton *button);

Does the color selection dialog use the alpha channel ?

Parameters

button

a CtkColorButton

 

Returns

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

Since: 2.4


ctk_color_button_set_title ()

void
ctk_color_button_set_title (CtkColorButton *button,
                            const gchar *title);

Sets the title for the color selection dialog.

Parameters

button

a CtkColorButton

 

title

String containing new window title

 

Since: 2.4


ctk_color_button_get_title ()

const gchar *
ctk_color_button_get_title (CtkColorButton *button);

Gets the title of the color selection dialog.

Parameters

button

a CtkColorButton

 

Returns

An internal string, do not free the return value

Since: 2.4

Types and Values

struct CtkColorButton

struct CtkColorButton;

Property Details

The “alpha” property

  “alpha”                    guint

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

Owner: CtkColorButton

Flags: Read / Write

Allowed values: <= 65535

Default value: 65535

Since: 2.4


The “color” property

  “color”                    CdkColor *

The selected color.

Owner: CtkColorButton

Flags: Read / Write

Since: 2.4


The “rgba” property

  “rgba”                     CdkRGBA *

The RGBA color.

Owner: CtkColorButton

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: CtkColorButton

Flags: Read / Write

Default value: FALSE

Since: 3.20


The “title” property

  “title”                    char *

The title of the color selection dialog

Owner: CtkColorButton

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: CtkColorButton

Flags: Read / Write

Default value: FALSE

Since: 2.4

Signal Details

The “color-set” signal

void
user_function (CtkColorButton *widget,
               gpointer        user_data)

The ::color-set signal is emitted when the user selects a color. When handling this signal, use ctk_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

See Also

CtkColorSelectionDialog, CtkFontButton