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_color() and
245 * gtk_color_button_get_alpha() (or gtk_color_button_get_rgba()) to
246 * find out which color was just selected.
248 * Note that this signal is only emitted when the <emphasis>user</emphasis>
249 * changes the color. If you need to react to programmatic color changes
250 * as well, use the notify::color signal.
254 color_button_signals[COLOR_SET] = g_signal_new (I_("color-set"),
255 G_TYPE_FROM_CLASS (gobject_class),
257 G_STRUCT_OFFSET (GtkColorButtonClass, color_set),
259 _gtk_marshal_VOID__VOID,
262 g_type_class_add_private (gobject_class, sizeof (GtkColorButtonPrivate));
266 gtk_color_button_has_alpha (GtkColorButton *button)
268 return button->priv->use_alpha && button->priv->rgba.alpha < 1;
271 /* Handle exposure events for the color picker's drawing area */
273 gtk_color_button_draw_cb (GtkWidget *widget,
277 GtkColorButton *button = GTK_COLOR_BUTTON (data);
278 cairo_pattern_t *checkered;
280 if (gtk_color_button_has_alpha (button))
282 cairo_set_source_rgb (cr, CHECK_DARK, CHECK_DARK, CHECK_DARK);
285 cairo_set_source_rgb (cr, CHECK_LIGHT, CHECK_LIGHT, CHECK_LIGHT);
286 cairo_scale (cr, CHECK_SIZE, CHECK_SIZE);
288 checkered = _gtk_color_chooser_get_checkered_pattern ();
289 cairo_mask (cr, checkered);
290 cairo_pattern_destroy (checkered);
292 gdk_cairo_set_source_rgba (cr, &button->priv->rgba);
296 cairo_set_source_rgb (cr,
297 button->priv->rgba.red,
298 button->priv->rgba.green,
299 button->priv->rgba.blue);
304 if (!gtk_widget_is_sensitive (GTK_WIDGET (button)))
306 GtkStyleContext *context;
309 context = gtk_widget_get_style_context (widget);
310 gtk_style_context_get_background_color (context, GTK_STATE_FLAG_INSENSITIVE, &color);
312 gdk_cairo_set_source_rgba (cr, &color);
313 checkered = _gtk_color_chooser_get_checkered_pattern ();
314 cairo_mask (cr, checkered);
315 cairo_pattern_destroy (checkered);
322 gtk_color_button_state_changed (GtkWidget *widget,
323 GtkStateType previous_state)
325 gtk_widget_queue_draw (widget);
329 gtk_color_button_drag_data_received (GtkWidget *widget,
330 GdkDragContext *context,
333 GtkSelectionData *selection_data,
336 GtkColorButton *button)
341 length = gtk_selection_data_get_length (selection_data);
346 /* We accept drops with the wrong format, since the KDE color
347 * chooser incorrectly drops application/x-color with format 8.
351 g_warning ("%s: Received invalid color data", G_STRFUNC);
356 dropped = (guint16 *) gtk_selection_data_get_data (selection_data);
358 button->priv->rgba.red = dropped[0] / 65535.;
359 button->priv->rgba.green = dropped[1] / 65535.;
360 button->priv->rgba.blue = dropped[2] / 65535.;
361 button->priv->rgba.alpha = dropped[3] / 65535.;
363 gtk_widget_queue_draw (button->priv->draw_area);
365 g_signal_emit (button, color_button_signals[COLOR_SET], 0);
367 g_object_freeze_notify (G_OBJECT (button));
368 g_object_notify (G_OBJECT (button), "color");
369 g_object_notify (G_OBJECT (button), "alpha");
370 g_object_notify (G_OBJECT (button), "rgba");
371 g_object_thaw_notify (G_OBJECT (button));
375 set_color_icon (GdkDragContext *context,
378 cairo_surface_t *surface;
381 surface = cairo_image_surface_create (CAIRO_FORMAT_RGB24,
383 cr = cairo_create (surface);
385 gdk_cairo_set_source_rgba (cr, rgba);
388 gtk_drag_set_icon_surface (context, surface);
391 cairo_surface_destroy (surface);
395 gtk_color_button_drag_begin (GtkWidget *widget,
396 GdkDragContext *context,
399 GtkColorButton *button = data;
401 set_color_icon (context, &button->priv->rgba);
405 gtk_color_button_drag_data_get (GtkWidget *widget,
406 GdkDragContext *context,
407 GtkSelectionData *selection_data,
410 GtkColorButton *button)
414 dropped[0] = (guint16) (button->priv->rgba.red * 65535);
415 dropped[1] = (guint16) (button->priv->rgba.green * 65535);
416 dropped[2] = (guint16) (button->priv->rgba.blue * 65535);
417 dropped[3] = (guint16) (button->priv->rgba.alpha * 65535);
419 gtk_selection_data_set (selection_data,
420 gtk_selection_data_get_target (selection_data),
421 16, (guchar *)dropped, 8);
425 gtk_color_button_init (GtkColorButton *button)
430 /* Create the widgets */
431 button->priv = G_TYPE_INSTANCE_GET_PRIVATE (button,
432 GTK_TYPE_COLOR_BUTTON,
433 GtkColorButtonPrivate);
435 gtk_widget_push_composite_child ();
437 button->priv->draw_area = gtk_drawing_area_new ();
438 layout = gtk_widget_create_pango_layout (GTK_WIDGET (button), "Black");
439 pango_layout_get_pixel_extents (layout, NULL, &rect);
440 g_object_unref (layout);
442 gtk_widget_set_size_request (button->priv->draw_area,
443 rect.width, rect.height);
445 g_signal_connect (button->priv->draw_area, "draw",
446 G_CALLBACK (gtk_color_button_draw_cb), button);
447 gtk_container_add (GTK_CONTAINER (button), button->priv->draw_area);
448 gtk_widget_show (button->priv->draw_area);
450 button->priv->title = g_strdup (_("Pick a Color")); /* default title */
452 /* Start with opaque black, alpha disabled */
453 button->priv->rgba.red = 0;
454 button->priv->rgba.green = 0;
455 button->priv->rgba.blue = 0;
456 button->priv->rgba.alpha = 1;
457 button->priv->use_alpha = FALSE;
459 gtk_drag_dest_set (GTK_WIDGET (button),
460 GTK_DEST_DEFAULT_MOTION |
461 GTK_DEST_DEFAULT_HIGHLIGHT |
462 GTK_DEST_DEFAULT_DROP,
463 drop_types, 1, GDK_ACTION_COPY);
464 gtk_drag_source_set (GTK_WIDGET (button),
465 GDK_BUTTON1_MASK|GDK_BUTTON3_MASK,
468 g_signal_connect (button, "drag-begin",
469 G_CALLBACK (gtk_color_button_drag_begin), button);
470 g_signal_connect (button, "drag-data-received",
471 G_CALLBACK (gtk_color_button_drag_data_received), button);
472 g_signal_connect (button, "drag-data-get",
473 G_CALLBACK (gtk_color_button_drag_data_get), button);
475 gtk_widget_pop_composite_child ();
479 gtk_color_button_finalize (GObject *object)
481 GtkColorButton *button = GTK_COLOR_BUTTON (object);
483 if (button->priv->cs_dialog != NULL)
484 gtk_widget_destroy (button->priv->cs_dialog);
485 button->priv->cs_dialog = NULL;
487 g_free (button->priv->title);
488 button->priv->title = NULL;
490 G_OBJECT_CLASS (gtk_color_button_parent_class)->finalize (object);
495 * gtk_color_button_new:
497 * Creates a new color button.
499 * This returns a widget in the form of a small button containing
500 * a swatch representing the current selected color. When the button
501 * is clicked, a color-selection dialog will open, allowing the user
502 * to select a color. The swatch will be updated to reflect the new
503 * color when the user finishes.
505 * Returns: a new color button
510 gtk_color_button_new (void)
512 return g_object_new (GTK_TYPE_COLOR_BUTTON, NULL);
516 * gtk_color_button_new_with_color:
517 * @color: A #GdkColor to set the current color with
519 * Creates a new color button.
521 * Returns: a new color button
525 * Deprecated: 3.4: Use gtk_color_button_new_with_rgba() instead.
528 gtk_color_button_new_with_color (const GdkColor *color)
530 return g_object_new (GTK_TYPE_COLOR_BUTTON, "color", color, NULL);
534 * gtk_color_button_new_with_rgba:
535 * @rgba: A #GdkRGBA to set the current color with
537 * Creates a new color button.
539 * Returns: a new color button
544 gtk_color_button_new_with_rgba (const GdkRGBA *rgba)
546 return g_object_new (GTK_TYPE_COLOR_BUTTON, "rgba", rgba, NULL);
550 dialog_destroy (GtkWidget *widget,
553 GtkColorButton *button = GTK_COLOR_BUTTON (data);
555 button->priv->cs_dialog = NULL;
561 dialog_response (GtkDialog *dialog,
565 if (response == GTK_RESPONSE_CANCEL)
566 gtk_widget_hide (GTK_WIDGET (dialog));
567 else if (response == GTK_RESPONSE_OK)
569 GtkColorButton *button = GTK_COLOR_BUTTON (data);
571 gtk_color_chooser_get_rgba (GTK_COLOR_CHOOSER (dialog),
572 &button->priv->rgba);
574 gtk_widget_hide (GTK_WIDGET (dialog));
576 gtk_widget_queue_draw (button->priv->draw_area);
578 g_signal_emit (button, color_button_signals[COLOR_SET], 0);
580 g_object_freeze_notify (G_OBJECT (button));
581 g_object_notify (G_OBJECT (button), "color");
582 g_object_notify (G_OBJECT (button), "alpha");
583 g_object_notify (G_OBJECT (button), "rgba");
584 g_object_thaw_notify (G_OBJECT (button));
589 gtk_color_button_clicked (GtkButton *b)
591 GtkColorButton *button = GTK_COLOR_BUTTON (b);
594 /* if dialog already exists, make sure it's shown and raised */
595 if (!button->priv->cs_dialog)
597 /* Create the dialog and connects its buttons */
600 parent = gtk_widget_get_toplevel (GTK_WIDGET (button));
602 button->priv->cs_dialog = dialog = gtk_color_chooser_dialog_new (button->priv->title, NULL);
604 if (gtk_widget_is_toplevel (parent) && GTK_IS_WINDOW (parent))
606 if (GTK_WINDOW (parent) != gtk_window_get_transient_for (GTK_WINDOW (dialog)))
607 gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (parent));
609 gtk_window_set_modal (GTK_WINDOW (dialog),
610 gtk_window_get_modal (GTK_WINDOW (parent)));
613 g_signal_connect (dialog, "response",
614 G_CALLBACK (dialog_response), button);
615 g_signal_connect (dialog, "destroy",
616 G_CALLBACK (dialog_destroy), button);
619 gtk_color_chooser_set_use_alpha (GTK_COLOR_CHOOSER (button->priv->cs_dialog),
620 button->priv->use_alpha);
622 gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (button->priv->cs_dialog),
623 &button->priv->rgba);
625 gtk_window_present (GTK_WINDOW (button->priv->cs_dialog));
629 * gtk_color_button_set_color:
630 * @button: a #GtkColorButton
631 * @color: A #GdkColor to set the current color with
633 * Sets the current color to be @color.
637 * Deprecated: Use gtk_color_chooser_set_rgba() instead.
640 gtk_color_button_set_color (GtkColorButton *button,
641 const GdkColor *color)
643 g_return_if_fail (GTK_IS_COLOR_BUTTON (button));
644 g_return_if_fail (color != NULL);
646 button->priv->rgba.red = color->red / 65535.;
647 button->priv->rgba.green = color->green / 65535.;
648 button->priv->rgba.blue = color->blue / 65535.;
650 gtk_widget_queue_draw (button->priv->draw_area);
652 g_object_notify (G_OBJECT (button), "color");
653 g_object_notify (G_OBJECT (button), "rgba");
658 * gtk_color_button_set_alpha:
659 * @button: a #GtkColorButton
660 * @alpha: an integer between 0 and 65535
662 * Sets the current opacity to be @alpha.
666 * Deprecated: 3.4: Use gtk_color_chooser_set_rgba() instead.
669 gtk_color_button_set_alpha (GtkColorButton *button,
672 g_return_if_fail (GTK_IS_COLOR_BUTTON (button));
674 button->priv->rgba.alpha = alpha / 65535.;
676 gtk_widget_queue_draw (button->priv->draw_area);
678 g_object_notify (G_OBJECT (button), "alpha");
679 g_object_notify (G_OBJECT (button), "rgba");
683 * gtk_color_button_get_color:
684 * @button: a #GtkColorButton
685 * @color: (out): a #GdkColor to fill in with the current color
687 * Sets @color to be the current color in the #GtkColorButton widget.
691 * Deprecated: 3.4: Use gtk_color_chooser_get_rgba() instead.
694 gtk_color_button_get_color (GtkColorButton *button,
697 g_return_if_fail (GTK_IS_COLOR_BUTTON (button));
699 color->red = (guint16) (button->priv->rgba.red * 65535);
700 color->green = (guint16) (button->priv->rgba.green * 65535);
701 color->blue = (guint16) (button->priv->rgba.blue * 65535);
705 * gtk_color_button_get_alpha:
706 * @button: a #GtkColorButton
708 * Returns the current alpha value.
710 * Return value: an integer between 0 and 65535
714 * Deprecated: 3.4: Use gtk_color_chooser_get_rgba() instead.
717 gtk_color_button_get_alpha (GtkColorButton *button)
719 g_return_val_if_fail (GTK_IS_COLOR_BUTTON (button), 0);
721 return (guint16) (button->priv->rgba.alpha * 65535);
725 * gtk_color_button_set_rgba:
726 * @button: a #GtkColorButton
727 * @rgba: a #GdkRGBA to set the current color with
729 * Sets the current color to be @rgba.
733 * Deprecated: 3.4: Use gtk_color_chooser_set_rgba() instead.
736 gtk_color_button_set_rgba (GtkColorButton *button,
739 g_return_if_fail (GTK_IS_COLOR_BUTTON (button));
740 g_return_if_fail (rgba != NULL);
742 button->priv->rgba = *rgba;
743 gtk_widget_queue_draw (button->priv->draw_area);
745 g_object_notify (G_OBJECT (button), "color");
746 g_object_notify (G_OBJECT (button), "alpha");
747 g_object_notify (G_OBJECT (button), "rgba");
751 * gtk_color_button_get_rgba:
752 * @button: a #GtkColorButton
753 * @rgba: (out): a #GdkRGBA to fill in with the current color
755 * Sets @rgba to be the current color in the #GtkColorButton widget.
759 * Deprecated: 3.4: Use gtk_color_chooser_get_rgba() instead.
762 gtk_color_button_get_rgba (GtkColorButton *button,
765 g_return_if_fail (GTK_IS_COLOR_BUTTON (button));
766 g_return_if_fail (rgba != NULL);
768 *rgba = button->priv->rgba;
772 * gtk_color_button_set_use_alpha:
773 * @button: a #GtkColorButton
774 * @use_alpha: %TRUE if color button should use alpha channel, %FALSE if not
776 * Sets whether or not the color button should use the alpha channel.
780 * Deprecated: 3.4: Use gtk_color_chooser_set_use_alpha() instead.
783 gtk_color_button_set_use_alpha (GtkColorButton *button,
786 g_return_if_fail (GTK_IS_COLOR_BUTTON (button));
788 use_alpha = (use_alpha != FALSE);
790 if (button->priv->use_alpha != use_alpha)
792 button->priv->use_alpha = use_alpha;
794 gtk_widget_queue_draw (button->priv->draw_area);
796 g_object_notify (G_OBJECT (button), "use-alpha");
801 * gtk_color_button_get_use_alpha:
802 * @button: a #GtkColorButton
804 * Does the color selection dialog use the alpha channel ?
806 * Returns: %TRUE if the color sample uses alpha channel, %FALSE if not
810 * Deprecated: 3.4: Use gtk_color_chooser_get_use_alpha() instead.
813 gtk_color_button_get_use_alpha (GtkColorButton *button)
815 g_return_val_if_fail (GTK_IS_COLOR_BUTTON (button), FALSE);
817 return button->priv->use_alpha;
822 * gtk_color_button_set_title:
823 * @button: a #GtkColorButton
824 * @title: String containing new window title
826 * Sets the title for the color selection dialog.
831 gtk_color_button_set_title (GtkColorButton *button,
836 g_return_if_fail (GTK_IS_COLOR_BUTTON (button));
838 old_title = button->priv->title;
839 button->priv->title = g_strdup (title);
842 if (button->priv->cs_dialog)
843 gtk_window_set_title (GTK_WINDOW (button->priv->cs_dialog),
844 button->priv->title);
846 g_object_notify (G_OBJECT (button), "title");
850 * gtk_color_button_get_title:
851 * @button: a #GtkColorButton
853 * Gets the title of the color selection dialog.
855 * Returns: An internal string, do not free the return value
860 gtk_color_button_get_title (GtkColorButton *button)
862 g_return_val_if_fail (GTK_IS_COLOR_BUTTON (button), NULL);
864 return button->priv->title;
868 gtk_color_button_set_property (GObject *object,
873 GtkColorButton *button = GTK_COLOR_BUTTON (object);
878 gtk_color_button_set_use_alpha (button, g_value_get_boolean (value));
881 gtk_color_button_set_title (button, g_value_get_string (value));
888 color = g_value_get_boxed (value);
890 rgba.red = color->red / 65535.0;
891 rgba.green = color->green / 65535.0;
892 rgba.blue = color->blue / 65535.0;
895 gtk_color_button_set_rgba (button, &rgba);
899 gtk_color_button_set_alpha (button, g_value_get_uint (value));
902 gtk_color_button_set_rgba (button, g_value_get_boxed (value));
905 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
911 gtk_color_button_get_property (GObject *object,
916 GtkColorButton *button = GTK_COLOR_BUTTON (object);
921 g_value_set_boolean (value, gtk_color_button_get_use_alpha (button));
924 g_value_set_string (value, gtk_color_button_get_title (button));
931 gtk_color_button_get_rgba (button, &rgba);
933 color.red = (guint16) (rgba.red * 65535 + 0.5);
934 color.green = (guint16) (rgba.green * 65535 + 0.5);
935 color.blue = (guint16) (rgba.blue * 65535 + 0.5);
937 g_value_set_boxed (value, &color);
941 g_value_set_uint (value, gtk_color_button_get_alpha (button));
947 gtk_color_button_get_rgba (button, &rgba);
948 g_value_set_boxed (value, &rgba);
952 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
958 gtk_color_button_add_palette (GtkColorChooser *chooser,
959 GtkOrientation orientation,
960 gint colors_per_line,
964 GtkColorButton *button = GTK_COLOR_BUTTON (chooser);
966 if (button->priv->cs_dialog)
967 gtk_color_chooser_add_palette (GTK_COLOR_CHOOSER (button->priv->cs_dialog),
968 orientation, colors_per_line, n_colors, colors);
971 typedef void (* get_rgba) (GtkColorChooser *, GdkRGBA *);
972 typedef void (* set_rgba) (GtkColorChooser *, const GdkRGBA *);
975 gtk_color_button_iface_init (GtkColorChooserInterface *iface)
977 iface->get_rgba = (get_rgba)gtk_color_button_get_rgba;
978 iface->set_rgba = (set_rgba)gtk_color_button_set_rgba;
979 iface->add_palette = gtk_color_button_add_palette;