Gtk.ColorButton¶
class — extends Widget, Accessible, Buildable, ColorChooser, ConstraintTarget
:::warning Deprecated since 4.10 This API is deprecated. :::
The GtkColorButton allows to open a color chooser dialog to change
the color.
<picture> <source srcset="color-button-dark.png" media="(prefers-color-scheme: dark)"> <img alt="An example GtkColorButton" src="color-button.png"> </picture>
It is suitable widget for selecting a color in a preference dialog.
CSS nodes¶
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.
Constructors¶
new¶
:::warning Deprecated since 4.10 This API is deprecated. :::
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 chooser dialog will open, allowing the user to select a color. The swatch will be updated to reflect the new color when the user finishes.
new_with_rgba¶
Creates a new color button showing the given color.
Parameters:
rgba— AGdkRGBAto set the current color with
Methods¶
get_modal¶
:::warning Deprecated since 4.10 This API is deprecated. :::
Gets whether the dialog is modal.
get_title¶
:::warning Deprecated since 4.10 This API is deprecated. :::
Gets the title of the color chooser dialog.
set_modal¶
:::warning Deprecated since 4.10 This API is deprecated. :::
Sets whether the dialog should be modal.
Parameters:
modal—Trueto make the dialog modal
set_title¶
:::warning Deprecated since 4.10 This API is deprecated. :::
Sets the title for the color chooser dialog.
Parameters:
title— String containing new window title
Properties¶
modal¶
Whether the color chooser dialog should be modal.
show_editor¶
Whether the color chooser should open in editor mode.
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.
title¶
The title of the color chooser dialog
Signals¶
activate¶
Emitted to when the color button is activated.
The ::activate signal on GtkMenuButton is an action signal and
emitting it causes the button to pop up its dialog.
color-set¶
Emitted when the user selects a color.
When handling this signal, use ColorChooser.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::rgba signal.