CtkColorSelection

CtkColorSelection — Widget used to select a color

Functions

Properties

guint current-alpha Read / Write
CdkColor * current-color Read / Write
CdkRGBA * current-rgba Read / Write
gboolean has-opacity-control Read / Write
gboolean has-palette Read / Write

Signals

void color-changed Run First

Types and Values

Object Hierarchy

    GObject
    ╰── GInitiallyUnowned
        ╰── CtkWidget
            ╰── CtkContainer
                ╰── CtkBox
                    ╰── CtkColorSelection

Implemented Interfaces

CtkColorSelection implements AtkImplementorIface, CtkBuildable and CtkOrientable.

Includes

#include <ctk/ctk.h>

Description

The CtkColorSelection is a widget that is used to select a color. It consists of a color wheel and number of sliders and entry boxes for color parameters such as hue, saturation, value, red, green, blue, and opacity. It is found on the standard color selection dialog box CtkColorSelectionDialog.

Functions

ctk_color_selection_new ()

CtkWidget *
ctk_color_selection_new (void);

Creates a new CtkColorSelection.

Returns

a new CtkColorSelection


ctk_color_selection_set_has_opacity_control ()

void
ctk_color_selection_set_has_opacity_control
                               (CtkColorSelection *colorsel,
                                gboolean has_opacity);

Sets the colorsel to use or not use opacity.

Parameters

colorsel

a CtkColorSelection

 

has_opacity

TRUE if colorsel can set the opacity, FALSE otherwise

 

ctk_color_selection_get_has_opacity_control ()

gboolean
ctk_color_selection_get_has_opacity_control
                               (CtkColorSelection *colorsel);

Determines whether the colorsel has an opacity control.

Parameters

colorsel

a CtkColorSelection

 

Returns

TRUE if the colorsel has an opacity control, FALSE if it does't


ctk_color_selection_set_has_palette ()

void
ctk_color_selection_set_has_palette (CtkColorSelection *colorsel,
                                     gboolean has_palette);

Shows and hides the palette based upon the value of has_palette .

Parameters

colorsel

a CtkColorSelection

 

has_palette

TRUE if palette is to be visible, FALSE otherwise

 

ctk_color_selection_get_has_palette ()

gboolean
ctk_color_selection_get_has_palette (CtkColorSelection *colorsel);

Determines whether the color selector has a color palette.

Parameters

colorsel

a CtkColorSelection

 

Returns

TRUE if the selector has a palette, FALSE if it hasn't


ctk_color_selection_get_current_alpha ()

guint16
ctk_color_selection_get_current_alpha (CtkColorSelection *colorsel);

Returns the current alpha value.

Parameters

colorsel

a CtkColorSelection

 

Returns

an integer between 0 and 65535


ctk_color_selection_set_current_alpha ()

void
ctk_color_selection_set_current_alpha (CtkColorSelection *colorsel,
                                       guint16 alpha);

Sets the current opacity to be alpha .

The first time this is called, it will also set the original opacity to be alpha too.

Parameters

colorsel

a CtkColorSelection

 

alpha

an integer between 0 and 65535

 

ctk_color_selection_get_current_color ()

void
ctk_color_selection_get_current_color (CtkColorSelection *colorsel,
                                       CdkColor *color);

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

Parameters

colorsel

a CtkColorSelection

 

color

a CdkColor to fill in with the current color.

[out]

ctk_color_selection_set_current_color ()

void
ctk_color_selection_set_current_color (CtkColorSelection *colorsel,
                                       const CdkColor *color);

Sets the current color to be color .

The first time this is called, it will also set the original color to be color too.

Parameters

colorsel

a CtkColorSelection

 

color

a CdkColor to set the current color with

 

ctk_color_selection_get_previous_alpha ()

guint16
ctk_color_selection_get_previous_alpha
                               (CtkColorSelection *colorsel);

Returns the previous alpha value.

Parameters

colorsel

a CtkColorSelection

 

Returns

an integer between 0 and 65535


ctk_color_selection_set_previous_alpha ()

void
ctk_color_selection_set_previous_alpha
                               (CtkColorSelection *colorsel,
                                guint16 alpha);

Sets the “previous” alpha to be alpha .

This function should be called with some hesitations, as it might seem confusing to have that alpha change.

Parameters

colorsel

a CtkColorSelection

 

alpha

an integer between 0 and 65535

 

ctk_color_selection_get_previous_color ()

void
ctk_color_selection_get_previous_color
                               (CtkColorSelection *colorsel,
                                CdkColor *color);

Fills color in with the original color value.

Parameters

colorsel

a CtkColorSelection

 

color

a CdkColor to fill in with the original color value.

[out]

ctk_color_selection_set_previous_color ()

void
ctk_color_selection_set_previous_color
                               (CtkColorSelection *colorsel,
                                const CdkColor *color);

Sets the “previous” color to be color .

This function should be called with some hesitations, as it might seem confusing to have that color change. Calling ctk_color_selection_set_current_color() will also set this color the first time it is called.

Parameters

colorsel

a CtkColorSelection

 

color

a CdkColor to set the previous color with

 

ctk_color_selection_get_current_rgba ()

void
ctk_color_selection_get_current_rgba (CtkColorSelection *colorsel,
                                      CdkRGBA *rgba);

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

Parameters

colorsel

a CtkColorSelection

 

rgba

a CdkRGBA to fill in with the current color.

[out]

Since: 3.0


ctk_color_selection_set_current_rgba ()

void
ctk_color_selection_set_current_rgba (CtkColorSelection *colorsel,
                                      const CdkRGBA *rgba);

Sets the current color to be rgba .

The first time this is called, it will also set the original color to be rgba too.

Parameters

colorsel

a CtkColorSelection

 

rgba

A CdkRGBA to set the current color with

 

Since: 3.0


ctk_color_selection_get_previous_rgba ()

void
ctk_color_selection_get_previous_rgba (CtkColorSelection *colorsel,
                                       CdkRGBA *rgba);

Fills rgba in with the original color value.

Parameters

colorsel

a CtkColorSelection

 

rgba

a CdkRGBA to fill in with the original color value.

[out]

Since: 3.0


ctk_color_selection_set_previous_rgba ()

void
ctk_color_selection_set_previous_rgba (CtkColorSelection *colorsel,
                                       const CdkRGBA *rgba);

Sets the “previous” color to be rgba .

This function should be called with some hesitations, as it might seem confusing to have that color change. Calling ctk_color_selection_set_current_rgba() will also set this color the first time it is called.

Parameters

colorsel

a CtkColorSelection

 

rgba

a CdkRGBA to set the previous color with

 

Since: 3.0


ctk_color_selection_is_adjusting ()

gboolean
ctk_color_selection_is_adjusting (CtkColorSelection *colorsel);

Gets the current state of the colorsel .

Parameters

colorsel

a CtkColorSelection

 

Returns

TRUE if the user is currently dragging a color around, and FALSE if the selection has stopped


ctk_color_selection_palette_from_string ()

gboolean
ctk_color_selection_palette_from_string
                               (const gchar *str,
                                CdkColor **colors,
                                gint *n_colors);

Parses a color palette string; the string is a colon-separated list of color names readable by cdk_color_parse().

Parameters

str

a string encoding a color palette

 

colors

return location for allocated array of CdkColor.

[out][array length=n_colors]

n_colors

return location for length of array

 

Returns

TRUE if a palette was successfully parsed


ctk_color_selection_palette_to_string ()

gchar *
ctk_color_selection_palette_to_string (const CdkColor *colors,
                                       gint n_colors);

Encodes a palette as a string, useful for persistent storage.

Parameters

colors

an array of colors.

[array length=n_colors]

n_colors

length of the array

 

Returns

allocated string encoding the palette


CtkColorSelectionChangePaletteFunc ()

void
(*CtkColorSelectionChangePaletteFunc) (const CdkColor *colors,
                                       gint n_colors);

Parameters

colors

Array of colors.

[array length=n_colors]

n_colors

Number of colors in the array

 

ctk_color_selection_set_change_palette_with_screen_hook ()

CtkColorSelectionChangePaletteWithScreenFunc
ctk_color_selection_set_change_palette_with_screen_hook
                               (CtkColorSelectionChangePaletteWithScreenFunc func);

Installs a global function to be called whenever the user tries to modify the palette in a color selection.

This function should save the new palette contents, and update the “ctk-color-palette” CtkSettings property so all CtkColorSelection widgets will be modified.

[skip]

Parameters

func

a function to call when the custom palette needs saving

 

Returns

the previous change palette hook (that was replaced)

Since: 2.2


CtkColorSelectionChangePaletteWithScreenFunc ()

void
(*CtkColorSelectionChangePaletteWithScreenFunc)
                               (CdkScreen *screen,
                                const CdkColor *colors,
                                gint n_colors);

Parameters

colors

Array of colors.

[array length=n_colors]

n_colors

Number of colors in the array

 

Since: 2.2

Types and Values

struct CtkColorSelection

struct CtkColorSelection;

struct CtkColorSelectionClass

struct CtkColorSelectionClass {
  CtkBoxClass parent_class;

  void (*color_changed) (CtkColorSelection *color_selection);
};

Members

color_changed ()

   

Property Details

The “current-alpha” property

  “current-alpha”            guint

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

Owner: CtkColorSelection

Flags: Read / Write

Allowed values: <= 65535

Default value: 65535


The “current-color” property

  “current-color”            CdkColor *

The current CdkColor color.

Owner: CtkColorSelection

Flags: Read / Write


The “current-rgba” property

  “current-rgba”             CdkRGBA *

The current RGBA color.

Owner: CtkColorSelection

Flags: Read / Write

Since: 3.0


The “has-opacity-control” property

  “has-opacity-control”      gboolean

Whether the color selector should allow setting opacity.

Owner: CtkColorSelection

Flags: Read / Write

Default value: FALSE


The “has-palette” property

  “has-palette”              gboolean

Whether a palette should be used.

Owner: CtkColorSelection

Flags: Read / Write

Default value: FALSE

Signal Details

The “color-changed” signal

void
user_function (CtkColorSelection *colorselection,
               gpointer           user_data)

This signal is emitted when the color changes in the CtkColorSelection according to its update policy.

Parameters

colorselection

the object which received the signal.

 

user_data

user data set when the signal handler was connected.

 

Flags: Run First