Package: gtk

Class gtk:color-button

Superclasses

Documented Subclasses

None

Direct Slots

modal
The modal property of type :boolean (Read / Write)
Whether the color chooser dialog is modal.
Default value: true
show-editor
The show-editor property of type :boolean (Read / Write)
Set the property to true to skip the palette in the color chooser 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.
Default value: false
title
The title property of type :string (Read / Write)
The title of the color chooser dialog.
Default value: "Pick a Color"

Details

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

Figure: GtkColorButton

CSS nodes

colorbutton
╰── button.color
    ╰── [content]    
The gtk:color-button implementation has a single CSS node with name colorbutton which contains a button node. To differentiate it from a plain gtk:button widget, it gets the .color style class.

Examples

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 do-color-button (&optional application)
  (let* ((button (make-instance 'gtk:color-button
                                 :rgba (gdk:rgba-parse "Blue")
                                 :title "Choose a color from the palette"
                                 :margin-top 48
                                 :margin-bottom 48
                                 :margin-start 48
                                 :margin-end 48))
         (window (make-instance 'gtk:window
                                 :title "Color Button"
                                 :application application
                                 :child button
                                 :default-width 270
                                 :default-height 210)))
    (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:window-present window)))    

Warning

The gtk:color-button implementation is deprecated since 4.10. Use the gtk:color-dialog-button widget instead.

Signal Details

The "activate" signal
lambda (button)    :run-first      
button
The gtk:color-button widget which received the signal.
The signal on the gtk:color-button widget is an action signal and emitting it causes the button to pop up its color chooser dialog. Since 4.4
The "color-set" signal
lambda (button)    :run-first      
button
The gtk:color-button widget which received the signal.
The signal is emitted when the user selects a color. When handling this signal, use the gtk:color-chooser-rgba function 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.
 

Returned by

Slot Access Functions

Inherited Slot Access Functions

See also

2024-5-21