Package: gtk

Class gtk-color-button

Superclasses

Documented Subclasses

None

Direct Slots

alpha
The alpha property of tpye :uint (Read / Write)
The selected opacity value, 0 fully transparent, 65535 fully opaque.
Allowed values: <= 65535
Default value: 65535
color
The color property of type gdk-color (Read / Write)
The selected color.
Warning: The color property has been deprecated since version 3.4 and should not be used in newly written code. Use the rgba property instead.
rgba
The rgba property of type gdk-rgba (Read / Write)
The selected RGBA color.
show-editor
The show-editor property of type :boolean (Read / Write)
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. Since 3.20
Default value: false
title
The title property of type :string (Read / Write)
The title of the color selection dialog.
Default value: "Pick a Color"
use-alpha
The use-alpha property of type :boolean (Read / Write)
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.
Default value: false

Details

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

CSS nodes

The gtk-color-button implementation has a single CSS node with name button. To differentiate it from a plain gtk-button widget, it gets the .color style class.

Example

The example shows a color button. The button is initialized with the color "Blue". The handler for the "color-set" signal prints the selected color on the console.
(defun example-color-button ()
  (within-main-loop
    (let ((window (make-instance 'gtk-window
                                 :title "Example Color Button"
                                 :border-width 12
                                 :default-width 250
                                 :default-height 200))
          (button (make-instance 'gtk-color-button
                                 :rgba (gdk-rgba-parse "Blue"))))
      (g-signal-connect window "destroy"
                        (lambda (widget)
                          (declare (ignore widget))
                          (leave-gtk-main)))
      (g-signal-connect button "color-set"
         (lambda (widget)
           (let ((rgba (gtk-color-chooser-rgba widget)))
             (format t "Selected color is ~A~%" (gdk-rgba-to-string rgba)))))
      (gtk-container-add window button)
      (gtk-widget-show-all window))))    

Signal Details

The "color-set" signal
 lambda (button)    : Run First      
The "color-set" signal is emitted when the user selects a color. When handling this signal, use the function gtk-color-chooser-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.
button
The gtk-color-button widget which received the signal.
 

Slot Access Functions

Inherited Slot Access Functions

See also

*2021-1-24