GtkColorButton

GtkColorButton — A button to launch a color selection dialog

Properties

gboolean modal Read / Write
gboolean show-editor Read / Write
char * title Read / Write

Signals

void color-set Run First

Types and Values

Object Hierarchy

    GObject
    ╰── GInitiallyUnowned
        ╰── GtkWidget
            ╰── GtkColorButton

Implemented Interfaces

GtkColorButton implements GtkAccessible, GtkBuildable, GtkConstraintTarget 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

1
2
3
colorbutton
╰── button.color
    ╰── [content]

GtkColorButton has a single CSS node with name colorbutton which contains a button node. 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


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


gtk_color_button_set_title ()

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

Sets the title for the color selection dialog.

Parameters

button

a GtkColorButton

 

title

String containing new window title

 

gtk_color_button_get_title ()

const char *
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


gtk_color_button_set_modal ()

void
gtk_color_button_set_modal (GtkColorButton *button,
                            gboolean modal);

Sets whether the dialog should be modal.

Parameters

button

a GtkColorButton

 

modal

TRUE to make the dialog modal

 

gtk_color_button_get_modal ()

gboolean
gtk_color_button_get_modal (GtkColorButton *button);

Gets whether the dialog is modal.

Parameters

button

a GtkColorButton

 

Returns

TRUE if the dialog is modal

Types and Values

GtkColorButton

typedef struct _GtkColorButton GtkColorButton;

Property Details

The “modal” property

  “modal”                    gboolean

Whether the dialog is modal.

Owner: GtkColorButton

Flags: Read / Write

Default value: TRUE


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


The “title” property

  “title”                    char *

The title of the color selection dialog

Owner: GtkColorButton

Flags: Read / Write

Default value: "Pick a Color"

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_chooser_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

See Also

GtkFontButton