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 struct _GtkColorButtonPrivate
65 GtkWidget *draw_area; /* Widget where we draw the color sample */
66 GtkWidget *cs_dialog; /* Color selection dialog */
68 gchar *title; /* Title for the color selection window */
71 guint use_alpha : 1; /* Use alpha or not */
93 static void gtk_color_button_finalize (GObject *object);
94 static void gtk_color_button_set_property (GObject *object,
98 static void gtk_color_button_get_property (GObject *object,
103 /* gtkwidget signals */
104 static void gtk_color_button_state_changed (GtkWidget *widget,
105 GtkStateType previous_state);
107 /* gtkbutton signals */
108 static void gtk_color_button_clicked (GtkButton *button);
110 /* source side drag signals */
111 static void gtk_color_button_drag_begin (GtkWidget *widget,
112 GdkDragContext *context,
114 static void gtk_color_button_drag_data_get (GtkWidget *widget,
115 GdkDragContext *context,
116 GtkSelectionData *selection_data,
119 GtkColorButton *button);
121 /* target side drag signals */
122 static void gtk_color_button_drag_data_received (GtkWidget *widget,
123 GdkDragContext *context,
126 GtkSelectionData *selection_data,
129 GtkColorButton *button);
132 static guint color_button_signals[LAST_SIGNAL] = { 0 };
134 static const GtkTargetEntry drop_types[] = { { "application/x-color", 0, 0 } };
136 static void gtk_color_button_iface_init (GtkColorChooserInterface *iface);
138 G_DEFINE_TYPE_WITH_CODE (GtkColorButton, gtk_color_button, GTK_TYPE_BUTTON,
139 G_IMPLEMENT_INTERFACE (GTK_TYPE_COLOR_CHOOSER,
140 gtk_color_button_iface_init))
143 gtk_color_button_class_init (GtkColorButtonClass *klass)
145 GObjectClass *gobject_class;
146 GtkWidgetClass *widget_class;
147 GtkButtonClass *button_class;
149 gobject_class = G_OBJECT_CLASS (klass);
150 widget_class = GTK_WIDGET_CLASS (klass);
151 button_class = GTK_BUTTON_CLASS (klass);
153 gobject_class->get_property = gtk_color_button_get_property;
154 gobject_class->set_property = gtk_color_button_set_property;
155 gobject_class->finalize = gtk_color_button_finalize;
156 widget_class->state_changed = gtk_color_button_state_changed;
157 button_class->clicked = gtk_color_button_clicked;
158 klass->color_set = NULL;
161 * GtkColorButton:use-alpha:
163 * If this property is set to %TRUE, the color swatch on the button is
164 * rendered against a checkerboard background to show its opacity and
165 * the opacity slider is displayed in the color selection dialog.
169 g_object_class_install_property (gobject_class,
171 g_param_spec_boolean ("use-alpha", P_("Use alpha"),
172 P_("Whether to give the color an alpha value"),
174 GTK_PARAM_READWRITE));
177 * GtkColorButton:title:
179 * The title of the color selection dialog
183 g_object_class_install_property (gobject_class,
185 g_param_spec_string ("title",
187 P_("The title of the color selection dialog"),
189 GTK_PARAM_READWRITE));
192 * GtkColorButton:color:
194 * The selected color.
198 * Deprecated: 3.4: Use #GtkColorButton:rgba instead.
200 g_object_class_install_property (gobject_class,
202 g_param_spec_boxed ("color",
204 P_("The selected color"),
206 GTK_PARAM_READWRITE | G_PARAM_DEPRECATED));
209 * GtkColorButton:alpha:
211 * The selected opacity value (0 fully transparent, 65535 fully opaque).
215 g_object_class_install_property (gobject_class,
217 g_param_spec_uint ("alpha",
219 P_("The selected opacity value (0 fully transparent, 65535 fully opaque)"),
221 GTK_PARAM_READWRITE));
224 * GtkColorButton:rgba:
230 g_object_class_install_property (gobject_class,
232 g_param_spec_boxed ("rgba",
233 P_("Current RGBA Color"),
234 P_("The selected RGBA color"),
236 GTK_PARAM_READWRITE));
240 * GtkColorButton::color-set:
241 * @widget: the object which received the signal.
243 * The ::color-set signal is emitted when the user selects a color.
244 * When handling this signal, use gtk_color_button_get_rgba() to
245 * find out which color was just selected.
247 * Note that this signal is only emitted when the <emphasis>user</emphasis>
248 * changes the color. If you need to react to programmatic color changes
249 * as well, use the notify::color signal.
253 color_button_signals[COLOR_SET] = g_signal_new (I_("color-set"),
254 G_TYPE_FROM_CLASS (gobject_class),
256 G_STRUCT_OFFSET (GtkColorButtonClass, color_set),
258 _gtk_marshal_VOID__VOID,
261 g_type_class_add_private (gobject_class, sizeof (GtkColorButtonPrivate));
265 gtk_color_button_has_alpha (GtkColorButton *button)
267 return button->priv->use_alpha && button->priv->rgba.alpha < 1;
270 /* Handle exposure events for the color picker's drawing area */
272 gtk_color_button_draw_cb (GtkWidget *widget,
276 GtkColorButton *button = GTK_COLOR_BUTTON (data);
277 cairo_pattern_t *checkered;
279 if (gtk_color_button_has_alpha (button))
281 cairo_set_source_rgb (cr, CHECK_DARK, CHECK_DARK, CHECK_DARK);
284 cairo_set_source_rgb (cr, CHECK_LIGHT, CHECK_LIGHT, CHECK_LIGHT);
285 cairo_scale (cr, CHECK_SIZE, CHECK_SIZE);
287 checkered = _gtk_color_chooser_get_checkered_pattern ();
288 cairo_mask (cr, checkered);
289 cairo_pattern_destroy (checkered);
291 gdk_cairo_set_source_rgba (cr, &button->priv->rgba);
295 cairo_set_source_rgb (cr,
296 button->priv->rgba.red,
297 button->priv->rgba.green,
298 button->priv->rgba.blue);
303 if (!gtk_widget_is_sensitive (GTK_WIDGET (button)))
305 GtkStyleContext *context;
308 context = gtk_widget_get_style_context (widget);
309 gtk_style_context_get_background_color (context, GTK_STATE_FLAG_INSENSITIVE, &color);
311 gdk_cairo_set_source_rgba (cr, &color);
312 checkered = _gtk_color_chooser_get_checkered_pattern ();
313 cairo_mask (cr, checkered);
314 cairo_pattern_destroy (checkered);
321 gtk_color_button_state_changed (GtkWidget *widget,
322 GtkStateType previous_state)
324 gtk_widget_queue_draw (widget);
328 gtk_color_button_drag_data_received (GtkWidget *widget,
329 GdkDragContext *context,
332 GtkSelectionData *selection_data,
335 GtkColorButton *button)
340 length = gtk_selection_data_get_length (selection_data);
345 /* We accept drops with the wrong format, since the KDE color
346 * chooser incorrectly drops application/x-color with format 8.
350 g_warning ("%s: Received invalid color data", G_STRFUNC);
355 dropped = (guint16 *) gtk_selection_data_get_data (selection_data);
357 button->priv->rgba.red = dropped[0] / 65535.;
358 button->priv->rgba.green = dropped[1] / 65535.;
359 button->priv->rgba.blue = dropped[2] / 65535.;
360 button->priv->rgba.alpha = dropped[3] / 65535.;
362 gtk_widget_queue_draw (button->priv->draw_area);
364 g_signal_emit (button, color_button_signals[COLOR_SET], 0);
366 g_object_freeze_notify (G_OBJECT (button));
367 g_object_notify (G_OBJECT (button), "color");
368 g_object_notify (G_OBJECT (button), "alpha");
369 g_object_notify (G_OBJECT (button), "rgba");
370 g_object_thaw_notify (G_OBJECT (button));
374 set_color_icon (GdkDragContext *context,
377 cairo_surface_t *surface;
380 surface = cairo_image_surface_create (CAIRO_FORMAT_RGB24,
382 cr = cairo_create (surface);
384 gdk_cairo_set_source_rgba (cr, rgba);
387 gtk_drag_set_icon_surface (context, surface);
390 cairo_surface_destroy (surface);
394 gtk_color_button_drag_begin (GtkWidget *widget,
395 GdkDragContext *context,
398 GtkColorButton *button = data;
400 set_color_icon (context, &button->priv->rgba);
404 gtk_color_button_drag_data_get (GtkWidget *widget,
405 GdkDragContext *context,
406 GtkSelectionData *selection_data,
409 GtkColorButton *button)
413 dropped[0] = (guint16) (button->priv->rgba.red * 65535);
414 dropped[1] = (guint16) (button->priv->rgba.green * 65535);
415 dropped[2] = (guint16) (button->priv->rgba.blue * 65535);
416 dropped[3] = (guint16) (button->priv->rgba.alpha * 65535);
418 gtk_selection_data_set (selection_data,
419 gtk_selection_data_get_target (selection_data),
420 16, (guchar *)dropped, 8);
424 gtk_color_button_init (GtkColorButton *button)
429 /* Create the widgets */
430 button->priv = G_TYPE_INSTANCE_GET_PRIVATE (button,
431 GTK_TYPE_COLOR_BUTTON,
432 GtkColorButtonPrivate);
434 gtk_widget_push_composite_child ();
436 button->priv->draw_area = gtk_drawing_area_new ();
437 layout = gtk_widget_create_pango_layout (GTK_WIDGET (button), "Black");
438 pango_layout_get_pixel_extents (layout, NULL, &rect);
439 g_object_unref (layout);
441 gtk_widget_set_size_request (button->priv->draw_area,
442 rect.width, rect.height);
444 g_signal_connect (button->priv->draw_area, "draw",
445 G_CALLBACK (gtk_color_button_draw_cb), button);
446 gtk_container_add (GTK_CONTAINER (button), button->priv->draw_area);
447 gtk_widget_show (button->priv->draw_area);
449 button->priv->title = g_strdup (_("Pick a Color")); /* default title */
451 /* Start with opaque black, alpha disabled */
452 button->priv->rgba.red = 0;
453 button->priv->rgba.green = 0;
454 button->priv->rgba.blue = 0;
455 button->priv->rgba.alpha = 1;
456 button->priv->use_alpha = FALSE;
458 gtk_drag_dest_set (GTK_WIDGET (button),
459 GTK_DEST_DEFAULT_MOTION |
460 GTK_DEST_DEFAULT_HIGHLIGHT |
461 GTK_DEST_DEFAULT_DROP,
462 drop_types, 1, GDK_ACTION_COPY);
463 gtk_drag_source_set (GTK_WIDGET (button),
464 GDK_BUTTON1_MASK|GDK_BUTTON3_MASK,
467 g_signal_connect (button, "drag-begin",
468 G_CALLBACK (gtk_color_button_drag_begin), button);
469 g_signal_connect (button, "drag-data-received",
470 G_CALLBACK (gtk_color_button_drag_data_received), button);
471 g_signal_connect (button, "drag-data-get",
472 G_CALLBACK (gtk_color_button_drag_data_get), button);
474 gtk_widget_pop_composite_child ();
478 gtk_color_button_finalize (GObject *object)
480 GtkColorButton *button = GTK_COLOR_BUTTON (object);
482 if (button->priv->cs_dialog != NULL)
483 gtk_widget_destroy (button->priv->cs_dialog);
484 button->priv->cs_dialog = NULL;
486 g_free (button->priv->title);
487 button->priv->title = NULL;
489 G_OBJECT_CLASS (gtk_color_button_parent_class)->finalize (object);
494 * gtk_color_button_new:
496 * Creates a new color button.
498 * This returns a widget in the form of a small button containing
499 * a swatch representing the current selected color. When the button
500 * is clicked, a color-selection dialog will open, allowing the user
501 * to select a color. The swatch will be updated to reflect the new
502 * color when the user finishes.
504 * Returns: a new color button
509 gtk_color_button_new (void)
511 return g_object_new (GTK_TYPE_COLOR_BUTTON, NULL);
515 * gtk_color_button_new_with_color:
516 * @color: A #GdkColor to set the current color with
518 * Creates a new color button.
520 * Returns: a new color button
524 * Deprecated: 3.4: Use gtk_color_button_new_with_rgba() instead.
527 gtk_color_button_new_with_color (const GdkColor *color)
529 return g_object_new (GTK_TYPE_COLOR_BUTTON, "color", color, NULL);
533 * gtk_color_button_new_with_rgba:
534 * @rgba: A #GdkRGBA to set the current color with
536 * Creates a new color button.
538 * Returns: a new color button
543 gtk_color_button_new_with_rgba (const GdkRGBA *rgba)
545 return g_object_new (GTK_TYPE_COLOR_BUTTON, "rgba", rgba, NULL);
549 dialog_destroy (GtkWidget *widget,
552 GtkColorButton *button = GTK_COLOR_BUTTON (data);
554 button->priv->cs_dialog = NULL;
560 dialog_response (GtkDialog *dialog,
564 if (response == GTK_RESPONSE_CANCEL)
565 gtk_widget_hide (GTK_WIDGET (dialog));
566 else if (response == GTK_RESPONSE_OK)
568 GtkColorButton *button = GTK_COLOR_BUTTON (data);
570 gtk_color_chooser_get_rgba (GTK_COLOR_CHOOSER (dialog),
571 &button->priv->rgba);
573 gtk_widget_hide (GTK_WIDGET (dialog));
575 gtk_widget_queue_draw (button->priv->draw_area);
577 g_signal_emit (button, color_button_signals[COLOR_SET], 0);
579 g_object_freeze_notify (G_OBJECT (button));
580 g_object_notify (G_OBJECT (button), "color");
581 g_object_notify (G_OBJECT (button), "alpha");
582 g_object_notify (G_OBJECT (button), "rgba");
583 g_object_thaw_notify (G_OBJECT (button));
587 /* Create the dialog and connects its buttons */
589 ensure_dialog (GtkColorButton *button)
591 GtkWidget *parent, *dialog;
593 if (button->priv->cs_dialog != NULL)
596 parent = gtk_widget_get_toplevel (GTK_WIDGET (button));
598 button->priv->cs_dialog = dialog = gtk_color_chooser_dialog_new (button->priv->title, NULL);
600 if (gtk_widget_is_toplevel (parent) && GTK_IS_WINDOW (parent))
602 if (GTK_WINDOW (parent) != gtk_window_get_transient_for (GTK_WINDOW (dialog)))
603 gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (parent));
605 gtk_window_set_modal (GTK_WINDOW (dialog),
606 gtk_window_get_modal (GTK_WINDOW (parent)));
609 g_signal_connect (dialog, "response",
610 G_CALLBACK (dialog_response), button);
611 g_signal_connect (dialog, "destroy",
612 G_CALLBACK (dialog_destroy), button);
617 gtk_color_button_clicked (GtkButton *b)
619 GtkColorButton *button = GTK_COLOR_BUTTON (b);
621 /* if dialog already exists, make sure it's shown and raised */
622 ensure_dialog (button);
624 gtk_color_chooser_set_use_alpha (GTK_COLOR_CHOOSER (button->priv->cs_dialog),
625 button->priv->use_alpha);
627 gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (button->priv->cs_dialog),
628 &button->priv->rgba);
630 gtk_window_present (GTK_WINDOW (button->priv->cs_dialog));
634 * gtk_color_button_set_color:
635 * @button: a #GtkColorButton
636 * @color: A #GdkColor to set the current color with
638 * Sets the current color to be @color.
642 * Deprecated: Use gtk_color_chooser_set_rgba() instead.
645 gtk_color_button_set_color (GtkColorButton *button,
646 const GdkColor *color)
648 g_return_if_fail (GTK_IS_COLOR_BUTTON (button));
649 g_return_if_fail (color != NULL);
651 button->priv->rgba.red = color->red / 65535.;
652 button->priv->rgba.green = color->green / 65535.;
653 button->priv->rgba.blue = color->blue / 65535.;
655 gtk_widget_queue_draw (button->priv->draw_area);
657 g_object_notify (G_OBJECT (button), "color");
658 g_object_notify (G_OBJECT (button), "rgba");
663 * gtk_color_button_set_alpha:
664 * @button: a #GtkColorButton
665 * @alpha: an integer between 0 and 65535
667 * Sets the current opacity to be @alpha.
671 * Deprecated: 3.4: Use gtk_color_chooser_set_rgba() instead.
674 gtk_color_button_set_alpha (GtkColorButton *button,
677 g_return_if_fail (GTK_IS_COLOR_BUTTON (button));
679 button->priv->rgba.alpha = alpha / 65535.;
681 gtk_widget_queue_draw (button->priv->draw_area);
683 g_object_notify (G_OBJECT (button), "alpha");
684 g_object_notify (G_OBJECT (button), "rgba");
688 * gtk_color_button_get_color:
689 * @button: a #GtkColorButton
690 * @color: (out): a #GdkColor to fill in with the current color
692 * Sets @color to be the current color in the #GtkColorButton widget.
696 * Deprecated: 3.4: Use gtk_color_chooser_get_rgba() instead.
699 gtk_color_button_get_color (GtkColorButton *button,
702 g_return_if_fail (GTK_IS_COLOR_BUTTON (button));
704 color->red = (guint16) (button->priv->rgba.red * 65535);
705 color->green = (guint16) (button->priv->rgba.green * 65535);
706 color->blue = (guint16) (button->priv->rgba.blue * 65535);
710 * gtk_color_button_get_alpha:
711 * @button: a #GtkColorButton
713 * Returns the current alpha value.
715 * Return value: an integer between 0 and 65535
719 * Deprecated: 3.4: Use gtk_color_chooser_get_rgba() instead.
722 gtk_color_button_get_alpha (GtkColorButton *button)
724 g_return_val_if_fail (GTK_IS_COLOR_BUTTON (button), 0);
726 return (guint16) (button->priv->rgba.alpha * 65535);
730 * gtk_color_button_set_rgba: (skip)
731 * @button: a #GtkColorButton
732 * @rgba: a #GdkRGBA to set the current color with
734 * Sets the current color to be @rgba.
738 * Deprecated: 3.4: Use gtk_color_chooser_set_rgba() instead.
741 gtk_color_button_set_rgba (GtkColorButton *button,
744 g_return_if_fail (GTK_IS_COLOR_BUTTON (button));
745 g_return_if_fail (rgba != NULL);
747 button->priv->rgba = *rgba;
748 gtk_widget_queue_draw (button->priv->draw_area);
750 g_object_notify (G_OBJECT (button), "color");
751 g_object_notify (G_OBJECT (button), "alpha");
752 g_object_notify (G_OBJECT (button), "rgba");
756 * gtk_color_button_get_rgba: (skip)
757 * @button: a #GtkColorButton
758 * @rgba: (out): a #GdkRGBA to fill in with the current color
760 * Sets @rgba to be the current color in the #GtkColorButton widget.
764 * Deprecated: 3.4: Use gtk_color_chooser_get_rgba() instead.
767 gtk_color_button_get_rgba (GtkColorButton *button,
770 g_return_if_fail (GTK_IS_COLOR_BUTTON (button));
771 g_return_if_fail (rgba != NULL);
773 *rgba = button->priv->rgba;
777 * gtk_color_button_set_use_alpha:
778 * @button: a #GtkColorButton
779 * @use_alpha: %TRUE if color button should use alpha channel, %FALSE if not
781 * Sets whether or not the color button should use the alpha channel.
785 * Deprecated: 3.4: Use gtk_color_chooser_set_use_alpha() instead.
788 gtk_color_button_set_use_alpha (GtkColorButton *button,
791 g_return_if_fail (GTK_IS_COLOR_BUTTON (button));
793 use_alpha = (use_alpha != FALSE);
795 if (button->priv->use_alpha != use_alpha)
797 button->priv->use_alpha = use_alpha;
799 gtk_widget_queue_draw (button->priv->draw_area);
801 g_object_notify (G_OBJECT (button), "use-alpha");
806 * gtk_color_button_get_use_alpha:
807 * @button: a #GtkColorButton
809 * Does the color selection dialog use the alpha channel ?
811 * Returns: %TRUE if the color sample uses alpha channel, %FALSE if not
815 * Deprecated: 3.4: Use gtk_color_chooser_get_use_alpha() instead.
818 gtk_color_button_get_use_alpha (GtkColorButton *button)
820 g_return_val_if_fail (GTK_IS_COLOR_BUTTON (button), FALSE);
822 return button->priv->use_alpha;
827 * gtk_color_button_set_title:
828 * @button: a #GtkColorButton
829 * @title: String containing new window title
831 * Sets the title for the color selection dialog.
836 gtk_color_button_set_title (GtkColorButton *button,
841 g_return_if_fail (GTK_IS_COLOR_BUTTON (button));
843 old_title = button->priv->title;
844 button->priv->title = g_strdup (title);
847 if (button->priv->cs_dialog)
848 gtk_window_set_title (GTK_WINDOW (button->priv->cs_dialog),
849 button->priv->title);
851 g_object_notify (G_OBJECT (button), "title");
855 * gtk_color_button_get_title:
856 * @button: a #GtkColorButton
858 * Gets the title of the color selection dialog.
860 * Returns: An internal string, do not free the return value
865 gtk_color_button_get_title (GtkColorButton *button)
867 g_return_val_if_fail (GTK_IS_COLOR_BUTTON (button), NULL);
869 return button->priv->title;
873 gtk_color_button_set_property (GObject *object,
878 GtkColorButton *button = GTK_COLOR_BUTTON (object);
883 gtk_color_button_set_use_alpha (button, g_value_get_boolean (value));
886 gtk_color_button_set_title (button, g_value_get_string (value));
893 color = g_value_get_boxed (value);
895 rgba.red = color->red / 65535.0;
896 rgba.green = color->green / 65535.0;
897 rgba.blue = color->blue / 65535.0;
900 gtk_color_button_set_rgba (button, &rgba);
904 gtk_color_button_set_alpha (button, g_value_get_uint (value));
907 gtk_color_button_set_rgba (button, g_value_get_boxed (value));
910 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
916 gtk_color_button_get_property (GObject *object,
921 GtkColorButton *button = GTK_COLOR_BUTTON (object);
926 g_value_set_boolean (value, gtk_color_button_get_use_alpha (button));
929 g_value_set_string (value, gtk_color_button_get_title (button));
936 gtk_color_button_get_rgba (button, &rgba);
938 color.red = (guint16) (rgba.red * 65535 + 0.5);
939 color.green = (guint16) (rgba.green * 65535 + 0.5);
940 color.blue = (guint16) (rgba.blue * 65535 + 0.5);
942 g_value_set_boxed (value, &color);
946 g_value_set_uint (value, gtk_color_button_get_alpha (button));
952 gtk_color_button_get_rgba (button, &rgba);
953 g_value_set_boxed (value, &rgba);
957 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
963 gtk_color_button_add_palette (GtkColorChooser *chooser,
964 GtkOrientation orientation,
965 gint colors_per_line,
969 GtkColorButton *button = GTK_COLOR_BUTTON (chooser);
971 ensure_dialog (button);
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;