2 * GTK - The GIMP Toolkit
3 * Copyright (C) 1998, 1999 Red Hat, Inc.
6 * This Library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public License as
8 * published by the Free Software Foundation; either version 2 of the
9 * License, or (at your option) any later version.
11 * This Library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
16 * You should have received a copy of the GNU Library General Public
17 * License along with this library. If not, see <http://www.gnu.org/licenses/>.
19 /* Color picker button for GNOME
21 * Author: Federico Mena <federico@nuclecu.unam.mx>
23 * Modified by the GTK+ Team and others 2003. See the AUTHORS
24 * file for a list of people on the GTK+ Team. See the ChangeLog
25 * files for a list of changes. These files are distributed with
26 * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
29 #define GDK_DISABLE_DEPRECATION_WARNINGS
32 #include "gtkcolorbutton.h"
34 #include "gtkbutton.h"
36 #include "gtkcolorchooser.h"
37 #include "gtkcolorchooserprivate.h"
38 #include "gtkcolorchooserdialog.h"
40 #include "gtkdrawingarea.h"
41 #include "gtkmarshalers.h"
42 #include "gtkprivate.h"
47 * SECTION:gtkcolorbutton
48 * @Short_description: A button to launch a color selection dialog
49 * @Title: GtkColorButton
50 * @See_also: #GtkColorSelectionDialog, #GtkFontButton
52 * The #GtkColorButton is a button which displays the currently selected
53 * color an allows to open a color selection dialog to change the color.
54 * It is suitable widget for selecting a color in a preference dialog.
58 /* Size of checks and gray levels for alpha compositing checkerboard */
60 #define CHECK_DARK (1.0 / 3.0)
61 #define CHECK_LIGHT (2.0 / 3.0)
63 #define COLOR_SAMPLE_MARGIN 1
65 struct _GtkColorButtonPrivate
67 GtkWidget *draw_area; /* Widget where we draw the color sample */
68 GtkWidget *cs_dialog; /* Color selection dialog */
70 gchar *title; /* Title for the color selection window */
73 guint use_alpha : 1; /* Use alpha or not */
95 static void gtk_color_button_finalize (GObject *object);
96 static void gtk_color_button_set_property (GObject *object,
100 static void gtk_color_button_get_property (GObject *object,
105 /* gtkwidget signals */
106 static void gtk_color_button_state_changed (GtkWidget *widget,
107 GtkStateType previous_state);
109 /* gtkbutton signals */
110 static void gtk_color_button_clicked (GtkButton *button);
112 /* source side drag signals */
113 static void gtk_color_button_drag_begin (GtkWidget *widget,
114 GdkDragContext *context,
116 static void gtk_color_button_drag_data_get (GtkWidget *widget,
117 GdkDragContext *context,
118 GtkSelectionData *selection_data,
121 GtkColorButton *button);
123 /* target side drag signals */
124 static void gtk_color_button_drag_data_received (GtkWidget *widget,
125 GdkDragContext *context,
128 GtkSelectionData *selection_data,
131 GtkColorButton *button);
134 static guint color_button_signals[LAST_SIGNAL] = { 0 };
136 static const GtkTargetEntry drop_types[] = { { "application/x-color", 0, 0 } };
138 static void gtk_color_button_iface_init (GtkColorChooserInterface *iface);
140 G_DEFINE_TYPE_WITH_CODE (GtkColorButton, gtk_color_button, GTK_TYPE_BUTTON,
141 G_IMPLEMENT_INTERFACE (GTK_TYPE_COLOR_CHOOSER,
142 gtk_color_button_iface_init))
145 gtk_color_button_class_init (GtkColorButtonClass *klass)
147 GObjectClass *gobject_class;
148 GtkWidgetClass *widget_class;
149 GtkButtonClass *button_class;
151 gobject_class = G_OBJECT_CLASS (klass);
152 widget_class = GTK_WIDGET_CLASS (klass);
153 button_class = GTK_BUTTON_CLASS (klass);
155 gobject_class->get_property = gtk_color_button_get_property;
156 gobject_class->set_property = gtk_color_button_set_property;
157 gobject_class->finalize = gtk_color_button_finalize;
158 widget_class->state_changed = gtk_color_button_state_changed;
159 button_class->clicked = gtk_color_button_clicked;
160 klass->color_set = NULL;
163 * GtkColorButton:use-alpha:
165 * If this property is set to %TRUE, the color swatch on the button is
166 * rendered against a checkerboard background to show its opacity and
167 * the opacity slider is displayed in the color selection dialog.
171 g_object_class_install_property (gobject_class,
173 g_param_spec_boolean ("use-alpha", P_("Use alpha"),
174 P_("Whether to give the color an alpha value"),
176 GTK_PARAM_READWRITE));
179 * GtkColorButton:title:
181 * The title of the color selection dialog
185 g_object_class_install_property (gobject_class,
187 g_param_spec_string ("title",
189 P_("The title of the color selection dialog"),
191 GTK_PARAM_READWRITE));
194 * GtkColorButton:color:
196 * The selected color.
200 * Deprecated: 3.4: Use #GtkColorButton:rgba instead.
202 g_object_class_install_property (gobject_class,
204 g_param_spec_boxed ("color",
206 P_("The selected color"),
208 GTK_PARAM_READWRITE | G_PARAM_DEPRECATED));
211 * GtkColorButton:alpha:
213 * The selected opacity value (0 fully transparent, 65535 fully opaque).
217 g_object_class_install_property (gobject_class,
219 g_param_spec_uint ("alpha",
221 P_("The selected opacity value (0 fully transparent, 65535 fully opaque)"),
223 GTK_PARAM_READWRITE));
226 * GtkColorButton:rgba:
232 g_object_class_install_property (gobject_class,
234 g_param_spec_boxed ("rgba",
235 P_("Current RGBA Color"),
236 P_("The selected RGBA color"),
238 GTK_PARAM_READWRITE));
242 * GtkColorButton::color-set:
243 * @widget: the object which received the signal.
245 * The ::color-set signal is emitted when the user selects a color.
246 * When handling this signal, use gtk_color_button_get_color() and
247 * gtk_color_button_get_alpha() (or gtk_color_button_get_rgba()) to
248 * find out which color was just selected.
250 * Note that this signal is only emitted when the <emphasis>user</emphasis>
251 * changes the color. If you need to react to programmatic color changes
252 * as well, use the notify::color signal.
256 color_button_signals[COLOR_SET] = g_signal_new (I_("color-set"),
257 G_TYPE_FROM_CLASS (gobject_class),
259 G_STRUCT_OFFSET (GtkColorButtonClass, color_set),
261 _gtk_marshal_VOID__VOID,
264 g_type_class_add_private (gobject_class, sizeof (GtkColorButtonPrivate));
268 gtk_color_button_has_alpha (GtkColorButton *button)
270 return button->priv->use_alpha && button->priv->rgba.alpha < 1;
273 /* Handle exposure events for the color picker's drawing area */
275 gtk_color_button_draw_cb (GtkWidget *widget,
279 GtkColorButton *button = GTK_COLOR_BUTTON (data);
280 cairo_pattern_t *checkered;
282 if (gtk_color_button_has_alpha (button))
284 cairo_set_source_rgb (cr, CHECK_DARK, CHECK_DARK, CHECK_DARK);
287 cairo_set_source_rgb (cr, CHECK_LIGHT, CHECK_LIGHT, CHECK_LIGHT);
288 cairo_scale (cr, CHECK_SIZE, CHECK_SIZE);
290 checkered = _gtk_color_chooser_get_checkered_pattern ();
291 cairo_mask (cr, checkered);
292 cairo_pattern_destroy (checkered);
294 gdk_cairo_set_source_rgba (cr, &button->priv->rgba);
298 cairo_set_source_rgb (cr,
299 button->priv->rgba.red,
300 button->priv->rgba.green,
301 button->priv->rgba.blue);
306 if (!gtk_widget_is_sensitive (GTK_WIDGET (button)))
308 GtkStyleContext *context;
311 context = gtk_widget_get_style_context (widget);
312 gtk_style_context_get_background_color (context, GTK_STATE_FLAG_INSENSITIVE, &color);
314 gdk_cairo_set_source_rgba (cr, &color);
315 checkered = _gtk_color_chooser_get_checkered_pattern ();
316 cairo_mask (cr, checkered);
317 cairo_pattern_destroy (checkered);
324 gtk_color_button_state_changed (GtkWidget *widget,
325 GtkStateType previous_state)
327 gtk_widget_queue_draw (widget);
331 gtk_color_button_drag_data_received (GtkWidget *widget,
332 GdkDragContext *context,
335 GtkSelectionData *selection_data,
338 GtkColorButton *button)
343 length = gtk_selection_data_get_length (selection_data);
348 /* We accept drops with the wrong format, since the KDE color
349 * chooser incorrectly drops application/x-color with format 8.
353 g_warning ("%s: Received invalid color data", G_STRFUNC);
358 dropped = (guint16 *) gtk_selection_data_get_data (selection_data);
360 button->priv->rgba.red = dropped[0] / 65535.;
361 button->priv->rgba.green = dropped[1] / 65535.;
362 button->priv->rgba.blue = dropped[2] / 65535.;
363 button->priv->rgba.alpha = dropped[3] / 65535.;
365 gtk_widget_queue_draw (button->priv->draw_area);
367 g_signal_emit (button, color_button_signals[COLOR_SET], 0);
369 g_object_freeze_notify (G_OBJECT (button));
370 g_object_notify (G_OBJECT (button), "color");
371 g_object_notify (G_OBJECT (button), "alpha");
372 g_object_notify (G_OBJECT (button), "rgba");
373 g_object_thaw_notify (G_OBJECT (button));
377 set_color_icon (GdkDragContext *context,
380 cairo_surface_t *surface;
383 surface = cairo_image_surface_create (CAIRO_FORMAT_RGB24,
385 cr = cairo_create (surface);
387 gdk_cairo_set_source_rgba (cr, rgba);
390 gtk_drag_set_icon_surface (context, surface);
393 cairo_surface_destroy (surface);
397 gtk_color_button_drag_begin (GtkWidget *widget,
398 GdkDragContext *context,
401 GtkColorButton *button = data;
403 set_color_icon (context, &button->priv->rgba);
407 gtk_color_button_drag_data_get (GtkWidget *widget,
408 GdkDragContext *context,
409 GtkSelectionData *selection_data,
412 GtkColorButton *button)
416 dropped[0] = (guint16) (button->priv->rgba.red * 65535);
417 dropped[1] = (guint16) (button->priv->rgba.green * 65535);
418 dropped[2] = (guint16) (button->priv->rgba.blue * 65535);
419 dropped[3] = (guint16) (button->priv->rgba.alpha * 65535);
421 gtk_selection_data_set (selection_data,
422 gtk_selection_data_get_target (selection_data),
423 16, (guchar *)dropped, 8);
427 gtk_color_button_init (GtkColorButton *button)
432 /* Create the widgets */
433 button->priv = G_TYPE_INSTANCE_GET_PRIVATE (button,
434 GTK_TYPE_COLOR_BUTTON,
435 GtkColorButtonPrivate);
437 gtk_widget_push_composite_child ();
439 button->priv->draw_area = gtk_drawing_area_new ();
440 g_object_set (button->priv->draw_area,
441 "margin-top", COLOR_SAMPLE_MARGIN,
442 "margin-bottom", COLOR_SAMPLE_MARGIN,
447 layout = gtk_widget_create_pango_layout (GTK_WIDGET (button), "Black");
448 pango_layout_get_pixel_extents (layout, NULL, &rect);
449 g_object_unref (layout);
451 gtk_widget_set_size_request (button->priv->draw_area,
452 rect.width, rect.height - 2 * COLOR_SAMPLE_MARGIN);
454 g_signal_connect (button->priv->draw_area, "draw",
455 G_CALLBACK (gtk_color_button_draw_cb), button);
456 gtk_container_add (GTK_CONTAINER (button), button->priv->draw_area);
457 gtk_widget_show (button->priv->draw_area);
459 button->priv->title = g_strdup (_("Pick a Color")); /* default title */
461 /* Start with opaque black, alpha disabled */
462 button->priv->rgba.red = 0;
463 button->priv->rgba.green = 0;
464 button->priv->rgba.blue = 0;
465 button->priv->rgba.alpha = 1;
466 button->priv->use_alpha = FALSE;
468 gtk_drag_dest_set (GTK_WIDGET (button),
469 GTK_DEST_DEFAULT_MOTION |
470 GTK_DEST_DEFAULT_HIGHLIGHT |
471 GTK_DEST_DEFAULT_DROP,
472 drop_types, 1, GDK_ACTION_COPY);
473 gtk_drag_source_set (GTK_WIDGET (button),
474 GDK_BUTTON1_MASK|GDK_BUTTON3_MASK,
477 g_signal_connect (button, "drag-begin",
478 G_CALLBACK (gtk_color_button_drag_begin), button);
479 g_signal_connect (button, "drag-data-received",
480 G_CALLBACK (gtk_color_button_drag_data_received), button);
481 g_signal_connect (button, "drag-data-get",
482 G_CALLBACK (gtk_color_button_drag_data_get), button);
484 gtk_widget_pop_composite_child ();
488 gtk_color_button_finalize (GObject *object)
490 GtkColorButton *button = GTK_COLOR_BUTTON (object);
492 if (button->priv->cs_dialog != NULL)
493 gtk_widget_destroy (button->priv->cs_dialog);
494 button->priv->cs_dialog = NULL;
496 g_free (button->priv->title);
497 button->priv->title = NULL;
499 G_OBJECT_CLASS (gtk_color_button_parent_class)->finalize (object);
504 * gtk_color_button_new:
506 * Creates a new color button.
508 * This returns a widget in the form of a small button containing
509 * a swatch representing the current selected color. When the button
510 * is clicked, a color-selection dialog will open, allowing the user
511 * to select a color. The swatch will be updated to reflect the new
512 * color when the user finishes.
514 * Returns: a new color button
519 gtk_color_button_new (void)
521 return g_object_new (GTK_TYPE_COLOR_BUTTON, NULL);
525 * gtk_color_button_new_with_color:
526 * @color: A #GdkColor to set the current color with
528 * Creates a new color button.
530 * Returns: a new color button
534 * Deprecated: 3.4: Use gtk_color_button_new_with_rgba() instead.
537 gtk_color_button_new_with_color (const GdkColor *color)
539 return g_object_new (GTK_TYPE_COLOR_BUTTON, "color", color, NULL);
543 * gtk_color_button_new_with_rgba:
544 * @rgba: A #GdkRGBA to set the current color with
546 * Creates a new color button.
548 * Returns: a new color button
553 gtk_color_button_new_with_rgba (const GdkRGBA *rgba)
555 return g_object_new (GTK_TYPE_COLOR_BUTTON, "rgba", rgba, NULL);
559 dialog_destroy (GtkWidget *widget,
562 GtkColorButton *button = GTK_COLOR_BUTTON (data);
564 button->priv->cs_dialog = NULL;
570 dialog_response (GtkDialog *dialog,
574 if (response == GTK_RESPONSE_CANCEL)
575 gtk_widget_hide (GTK_WIDGET (dialog));
576 else if (response == GTK_RESPONSE_OK)
578 GtkColorButton *button = GTK_COLOR_BUTTON (data);
580 gtk_color_chooser_get_rgba (GTK_COLOR_CHOOSER (dialog),
581 &button->priv->rgba);
583 gtk_widget_hide (GTK_WIDGET (dialog));
585 gtk_widget_queue_draw (button->priv->draw_area);
587 g_signal_emit (button, color_button_signals[COLOR_SET], 0);
589 g_object_freeze_notify (G_OBJECT (button));
590 g_object_notify (G_OBJECT (button), "color");
591 g_object_notify (G_OBJECT (button), "alpha");
592 g_object_notify (G_OBJECT (button), "rgba");
593 g_object_thaw_notify (G_OBJECT (button));
598 gtk_color_button_clicked (GtkButton *b)
600 GtkColorButton *button = GTK_COLOR_BUTTON (b);
603 /* if dialog already exists, make sure it's shown and raised */
604 if (!button->priv->cs_dialog)
606 /* Create the dialog and connects its buttons */
609 parent = gtk_widget_get_toplevel (GTK_WIDGET (button));
611 button->priv->cs_dialog = dialog = gtk_color_chooser_dialog_new (button->priv->title, NULL);
613 if (gtk_widget_is_toplevel (parent) && GTK_IS_WINDOW (parent))
615 if (GTK_WINDOW (parent) != gtk_window_get_transient_for (GTK_WINDOW (dialog)))
616 gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (parent));
618 gtk_window_set_modal (GTK_WINDOW (dialog),
619 gtk_window_get_modal (GTK_WINDOW (parent)));
622 g_signal_connect (dialog, "response",
623 G_CALLBACK (dialog_response), button);
624 g_signal_connect (dialog, "destroy",
625 G_CALLBACK (dialog_destroy), button);
628 gtk_color_chooser_set_use_alpha (GTK_COLOR_CHOOSER (button->priv->cs_dialog),
629 button->priv->use_alpha);
631 gtk_window_present (GTK_WINDOW (button->priv->cs_dialog));
635 * gtk_color_button_set_color:
636 * @button: a #GtkColorButton
637 * @color: A #GdkColor to set the current color with
639 * Sets the current color to be @color.
643 * Deprecated: Use gtk_color_chooser_set_rgba() instead.
646 gtk_color_button_set_color (GtkColorButton *button,
647 const GdkColor *color)
649 g_return_if_fail (GTK_IS_COLOR_BUTTON (button));
650 g_return_if_fail (color != NULL);
652 button->priv->rgba.red = color->red / 65535.;
653 button->priv->rgba.green = color->green / 65535.;
654 button->priv->rgba.blue = color->blue / 65535.;
656 gtk_widget_queue_draw (button->priv->draw_area);
658 g_object_notify (G_OBJECT (button), "color");
659 g_object_notify (G_OBJECT (button), "rgba");
664 * gtk_color_button_set_alpha:
665 * @button: a #GtkColorButton
666 * @alpha: an integer between 0 and 65535
668 * Sets the current opacity to be @alpha.
672 * Deprecated: 3.4: Use gtk_color_chooser_set_rgba() instead.
675 gtk_color_button_set_alpha (GtkColorButton *button,
678 g_return_if_fail (GTK_IS_COLOR_BUTTON (button));
680 button->priv->rgba.alpha = alpha / 65535.;
682 gtk_widget_queue_draw (button->priv->draw_area);
684 g_object_notify (G_OBJECT (button), "alpha");
685 g_object_notify (G_OBJECT (button), "rgba");
689 * gtk_color_button_get_color:
690 * @button: a #GtkColorButton
691 * @color: (out): a #GdkColor to fill in with the current color
693 * Sets @color to be the current color in the #GtkColorButton widget.
697 * Deprecated: 3.4: Use gtk_color_chooser_get_rgba() instead.
700 gtk_color_button_get_color (GtkColorButton *button,
703 g_return_if_fail (GTK_IS_COLOR_BUTTON (button));
705 color->red = (guint16) (button->priv->rgba.red * 65535);
706 color->green = (guint16) (button->priv->rgba.green * 65535);
707 color->blue = (guint16) (button->priv->rgba.blue * 65535);
711 * gtk_color_button_get_alpha:
712 * @button: a #GtkColorButton
714 * Returns the current alpha value.
716 * Return value: an integer between 0 and 65535
720 * Deprecated: 3.4: Use gtk_color_chooser_get_rgba() instead.
723 gtk_color_button_get_alpha (GtkColorButton *button)
725 g_return_val_if_fail (GTK_IS_COLOR_BUTTON (button), 0);
727 return (guint16) (button->priv->rgba.alpha * 65535);
731 * gtk_color_button_set_rgba:
732 * @button: a #GtkColorButton
733 * @rgba: a #GdkRGBA to set the current color with
735 * Sets the current color to be @rgba.
739 * Deprecated: 3.4: Use gtk_color_chooser_set_rgba() instead.
742 gtk_color_button_set_rgba (GtkColorButton *button,
745 g_return_if_fail (GTK_IS_COLOR_BUTTON (button));
746 g_return_if_fail (rgba != NULL);
748 button->priv->rgba = *rgba;
749 gtk_widget_queue_draw (button->priv->draw_area);
751 g_object_notify (G_OBJECT (button), "color");
752 g_object_notify (G_OBJECT (button), "alpha");
753 g_object_notify (G_OBJECT (button), "rgba");
757 * gtk_color_button_get_rgba:
758 * @button: a #GtkColorButton
759 * @rgba: (out): a #GdkRGBA to fill in with the current color
761 * Sets @rgba to be the current color in the #GtkColorButton widget.
765 * Deprecated: 3.4: Use gtk_color_chooser_get_rgba() instead.
768 gtk_color_button_get_rgba (GtkColorButton *button,
771 g_return_if_fail (GTK_IS_COLOR_BUTTON (button));
772 g_return_if_fail (rgba != NULL);
774 *rgba = button->priv->rgba;
778 * gtk_color_button_set_use_alpha:
779 * @button: a #GtkColorButton
780 * @use_alpha: %TRUE if color button should use alpha channel, %FALSE if not
782 * Sets whether or not the color button should use the alpha channel.
786 * Deprecated: 3.4: Use gtk_color_chooser_set_use_alpha() instead.
789 gtk_color_button_set_use_alpha (GtkColorButton *button,
792 g_return_if_fail (GTK_IS_COLOR_BUTTON (button));
794 use_alpha = (use_alpha != FALSE);
796 if (button->priv->use_alpha != use_alpha)
798 button->priv->use_alpha = use_alpha;
800 gtk_widget_queue_draw (button->priv->draw_area);
802 g_object_notify (G_OBJECT (button), "use-alpha");
807 * gtk_color_button_get_use_alpha:
808 * @button: a #GtkColorButton
810 * Does the color selection dialog use the alpha channel ?
812 * Returns: %TRUE if the color sample uses alpha channel, %FALSE if not
816 * Deprecated: 3.4: Use gtk_color_chooser_get_use_alpha() instead.
819 gtk_color_button_get_use_alpha (GtkColorButton *button)
821 g_return_val_if_fail (GTK_IS_COLOR_BUTTON (button), FALSE);
823 return button->priv->use_alpha;
828 * gtk_color_button_set_title:
829 * @button: a #GtkColorButton
830 * @title: String containing new window title
832 * Sets the title for the color selection dialog.
837 gtk_color_button_set_title (GtkColorButton *button,
842 g_return_if_fail (GTK_IS_COLOR_BUTTON (button));
844 old_title = button->priv->title;
845 button->priv->title = g_strdup (title);
848 if (button->priv->cs_dialog)
849 gtk_window_set_title (GTK_WINDOW (button->priv->cs_dialog),
850 button->priv->title);
852 g_object_notify (G_OBJECT (button), "title");
856 * gtk_color_button_get_title:
857 * @button: a #GtkColorButton
859 * Gets the title of the color selection dialog.
861 * Returns: An internal string, do not free the return value
866 gtk_color_button_get_title (GtkColorButton *button)
868 g_return_val_if_fail (GTK_IS_COLOR_BUTTON (button), NULL);
870 return button->priv->title;
874 gtk_color_button_set_property (GObject *object,
879 GtkColorButton *button = GTK_COLOR_BUTTON (object);
884 gtk_color_button_set_use_alpha (button, g_value_get_boolean (value));
887 gtk_color_button_set_title (button, g_value_get_string (value));
894 color = g_value_get_boxed (value);
896 rgba.red = color->red / 65535.0;
897 rgba.green = color->green / 65535.0;
898 rgba.blue = color->blue / 65535.0;
901 gtk_color_button_set_rgba (button, &rgba);
905 gtk_color_button_set_alpha (button, g_value_get_uint (value));
908 gtk_color_button_set_rgba (button, g_value_get_boxed (value));
911 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
917 gtk_color_button_get_property (GObject *object,
922 GtkColorButton *button = GTK_COLOR_BUTTON (object);
927 g_value_set_boolean (value, gtk_color_button_get_use_alpha (button));
930 g_value_set_string (value, gtk_color_button_get_title (button));
937 gtk_color_button_get_rgba (button, &rgba);
939 color.red = (guint16) (rgba.red * 65535 + 0.5);
940 color.green = (guint16) (rgba.green * 65535 + 0.5);
941 color.blue = (guint16) (rgba.blue * 65535 + 0.5);
943 g_value_set_boxed (value, &color);
947 g_value_set_uint (value, gtk_color_button_get_alpha (button));
953 gtk_color_button_get_rgba (button, &rgba);
954 g_value_set_boxed (value, &rgba);
958 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
964 gtk_color_button_add_palette (GtkColorChooser *chooser,
965 GtkOrientation orientation,
966 gint colors_per_line,
970 GtkColorButton *button = GTK_COLOR_BUTTON (chooser);
972 if (button->priv->cs_dialog)
973 gtk_color_chooser_add_palette (GTK_COLOR_CHOOSER (button->priv->cs_dialog),
974 orientation, colors_per_line, n_colors, colors);
977 typedef void (* get_rgba) (GtkColorChooser *, GdkRGBA *);
978 typedef void (* set_rgba) (GtkColorChooser *, const GdkRGBA *);
981 gtk_color_button_iface_init (GtkColorChooserInterface *iface)
983 iface->get_rgba = (get_rgba)gtk_color_button_get_rgba;
984 iface->set_rgba = (set_rgba)gtk_color_button_set_rgba;
985 iface->add_palette = gtk_color_button_add_palette;