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 the Gnome Library; see the file COPYING.LIB. If not,
18 * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
21 /* Color picker button for GNOME
23 * Author: Federico Mena <federico@nuclecu.unam.mx>
25 * Modified by the GTK+ Team and others 2003. See the AUTHORS
26 * file for a list of people on the GTK+ Team. See the ChangeLog
27 * files for a list of changes. These files are distributed with
28 * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
33 #include "gtkcolorbutton.h"
35 #include "gtkbutton.h"
37 #include "gtkalignment.h"
38 #include "gtkcolorsel.h"
39 #include "gtkcolorseldialog.h"
41 #include "gtkdrawingarea.h"
43 #include "gtkmarshalers.h"
44 #include "gtkprivate.h"
49 * SECTION:gtkcolorbutton
50 * @Short_description: A button to launch a color selection dialog
51 * @Title: GtkColorButton
52 * @See_also: #GtkColorSelectionDialog, #GtkFontButton
54 * The #GtkColorButton is a button which displays the currently selected
55 * color an allows to open a color selection dialog to change the color.
56 * It is suitable widget for selecting a color in a preference dialog.
60 /* Size of checks and gray levels for alpha compositing checkerboard */
62 #define CHECK_DARK (1.0 / 3.0)
63 #define CHECK_LIGHT (2.0 / 3.0)
66 struct _GtkColorButtonPrivate
68 GtkWidget *draw_area; /* Widget where we draw the color sample */
69 GtkWidget *cs_dialog; /* Color selection dialog */
71 gchar *title; /* Title for the color selection window */
74 guint use_alpha : 1; /* Use alpha or not */
96 static void gtk_color_button_finalize (GObject *object);
97 static void gtk_color_button_set_property (GObject *object,
101 static void gtk_color_button_get_property (GObject *object,
106 /* gtkwidget signals */
107 static void gtk_color_button_state_changed (GtkWidget *widget,
108 GtkStateType previous_state);
110 /* gtkbutton signals */
111 static void gtk_color_button_clicked (GtkButton *button);
113 /* source side drag signals */
114 static void gtk_color_button_drag_begin (GtkWidget *widget,
115 GdkDragContext *context,
117 static void gtk_color_button_drag_data_get (GtkWidget *widget,
118 GdkDragContext *context,
119 GtkSelectionData *selection_data,
122 GtkColorButton *color_button);
124 /* target side drag signals */
125 static void gtk_color_button_drag_data_received (GtkWidget *widget,
126 GdkDragContext *context,
129 GtkSelectionData *selection_data,
132 GtkColorButton *color_button);
135 static guint color_button_signals[LAST_SIGNAL] = { 0 };
137 static const GtkTargetEntry drop_types[] = { { "application/x-color", 0, 0 } };
139 G_DEFINE_TYPE (GtkColorButton, gtk_color_button, GTK_TYPE_BUTTON)
142 gtk_color_button_class_init (GtkColorButtonClass *klass)
144 GObjectClass *gobject_class;
145 GtkWidgetClass *widget_class;
146 GtkButtonClass *button_class;
148 gobject_class = G_OBJECT_CLASS (klass);
149 widget_class = GTK_WIDGET_CLASS (klass);
150 button_class = GTK_BUTTON_CLASS (klass);
152 gobject_class->get_property = gtk_color_button_get_property;
153 gobject_class->set_property = gtk_color_button_set_property;
154 gobject_class->finalize = gtk_color_button_finalize;
155 widget_class->state_changed = gtk_color_button_state_changed;
156 button_class->clicked = gtk_color_button_clicked;
157 klass->color_set = NULL;
160 * GtkColorButton:use-alpha:
162 * If this property is set to %TRUE, the color swatch on the button is rendered against a
163 * checkerboard background to show its opacity and the opacity slider is displayed in the
164 * color selection dialog.
168 g_object_class_install_property (gobject_class,
170 g_param_spec_boolean ("use-alpha", P_("Use alpha"),
171 P_("Whether to give the color an alpha value"),
173 GTK_PARAM_READWRITE));
176 * GtkColorButton:title:
178 * The title of the color selection dialog
182 g_object_class_install_property (gobject_class,
184 g_param_spec_string ("title",
186 P_("The title of the color selection dialog"),
188 GTK_PARAM_READWRITE));
191 * GtkColorButton:color:
193 * The selected color.
197 g_object_class_install_property (gobject_class,
199 g_param_spec_boxed ("color",
201 P_("The selected color"),
203 GTK_PARAM_READWRITE));
206 * GtkColorButton:alpha:
208 * The selected opacity value (0 fully transparent, 65535 fully opaque).
212 g_object_class_install_property (gobject_class,
214 g_param_spec_uint ("alpha",
216 P_("The selected opacity value (0 fully transparent, 65535 fully opaque)"),
218 GTK_PARAM_READWRITE));
221 * GtkColorButton:rgba:
227 g_object_class_install_property (gobject_class,
229 g_param_spec_boxed ("rgba",
230 P_("Current RGBA Color"),
231 P_("The selected RGBA color"),
233 GTK_PARAM_READWRITE));
237 * GtkColorButton::color-set:
238 * @widget: the object which received the signal.
240 * The ::color-set signal is emitted when the user selects a color.
241 * When handling this signal, use gtk_color_button_get_color() and
242 * gtk_color_button_get_alpha() (or gtk_color_button_get_rgba()) to
243 * find out which color was just selected.
245 * Note that this signal is only emitted when the <emphasis>user</emphasis>
246 * changes the color. If you need to react to programmatic color changes
247 * as well, use the notify::color signal.
251 color_button_signals[COLOR_SET] = g_signal_new (I_("color-set"),
252 G_TYPE_FROM_CLASS (gobject_class),
254 G_STRUCT_OFFSET (GtkColorButtonClass, color_set),
256 _gtk_marshal_VOID__VOID,
259 g_type_class_add_private (gobject_class, sizeof (GtkColorButtonPrivate));
263 gtk_color_button_has_alpha (GtkColorButton *color_button)
265 return color_button->priv->use_alpha &&
266 color_button->priv->rgba.alpha < 1;
269 static cairo_pattern_t *
270 gtk_color_button_get_checkered (void)
272 /* need to respect pixman's stride being a multiple of 4 */
273 static unsigned char data[8] = { 0xFF, 0x00, 0x00, 0x00,
274 0x00, 0xFF, 0x00, 0x00 };
275 static cairo_surface_t *checkered = NULL;
276 cairo_pattern_t *pattern;
278 if (checkered == NULL)
280 checkered = cairo_image_surface_create_for_data (data,
285 pattern = cairo_pattern_create_for_surface (checkered);
286 cairo_pattern_set_extend (pattern, CAIRO_EXTEND_REPEAT);
287 cairo_pattern_set_filter (pattern, CAIRO_FILTER_NEAREST);
292 /* Handle exposure events for the color picker's drawing area */
294 gtk_color_button_draw_cb (GtkWidget *widget,
298 GtkColorButton *color_button = GTK_COLOR_BUTTON (data);
299 cairo_pattern_t *checkered;
301 if (gtk_color_button_has_alpha (color_button))
303 cairo_set_source_rgb (cr, CHECK_DARK, CHECK_DARK, CHECK_DARK);
306 cairo_set_source_rgb (cr, CHECK_LIGHT, CHECK_LIGHT, CHECK_LIGHT);
307 cairo_scale (cr, CHECK_SIZE, CHECK_SIZE);
309 checkered = gtk_color_button_get_checkered ();
310 cairo_mask (cr, checkered);
311 cairo_pattern_destroy (checkered);
313 gdk_cairo_set_source_rgba (cr, &color_button->priv->rgba);
317 cairo_set_source_rgb (cr,
318 color_button->priv->rgba.red,
319 color_button->priv->rgba.green,
320 color_button->priv->rgba.blue);
325 if (!gtk_widget_is_sensitive (GTK_WIDGET (color_button)))
327 GtkStyleContext *context;
330 context = gtk_widget_get_style_context (widget);
331 gtk_style_context_get_background_color (context, GTK_STATE_FLAG_INSENSITIVE, &color);
333 gdk_cairo_set_source_rgba (cr, &color);
334 checkered = gtk_color_button_get_checkered ();
335 cairo_mask (cr, checkered);
336 cairo_pattern_destroy (checkered);
343 gtk_color_button_state_changed (GtkWidget *widget,
344 GtkStateType previous_state)
346 gtk_widget_queue_draw (widget);
350 gtk_color_button_drag_data_received (GtkWidget *widget,
351 GdkDragContext *context,
354 GtkSelectionData *selection_data,
357 GtkColorButton *color_button)
362 length = gtk_selection_data_get_length (selection_data);
367 /* We accept drops with the wrong format, since the KDE color
368 * chooser incorrectly drops application/x-color with format 8.
372 g_warning (_("Received invalid color data\n"));
377 dropped = (guint16 *) gtk_selection_data_get_data (selection_data);
379 color_button->priv->rgba.red = dropped[0] / 65535.;
380 color_button->priv->rgba.green = dropped[1] / 65535.;
381 color_button->priv->rgba.blue = dropped[2] / 65535.;
382 color_button->priv->rgba.alpha = dropped[3] / 65535.;
384 gtk_widget_queue_draw (color_button->priv->draw_area);
386 g_signal_emit (color_button, color_button_signals[COLOR_SET], 0);
388 g_object_freeze_notify (G_OBJECT (color_button));
389 g_object_notify (G_OBJECT (color_button), "color");
390 g_object_notify (G_OBJECT (color_button), "alpha");
391 g_object_notify (G_OBJECT (color_button), "rgba");
392 g_object_thaw_notify (G_OBJECT (color_button));
396 set_color_icon (GdkDragContext *context,
399 cairo_surface_t *surface;
402 surface = cairo_image_surface_create (CAIRO_FORMAT_RGB24,
404 cr = cairo_create (surface);
406 gdk_cairo_set_source_rgba (cr, rgba);
409 gtk_drag_set_icon_surface (context, surface);
412 cairo_surface_destroy (surface);
416 gtk_color_button_drag_begin (GtkWidget *widget,
417 GdkDragContext *context,
420 GtkColorButton *color_button = data;
422 set_color_icon (context, &color_button->priv->rgba);
426 gtk_color_button_drag_data_get (GtkWidget *widget,
427 GdkDragContext *context,
428 GtkSelectionData *selection_data,
431 GtkColorButton *color_button)
435 dropped[0] = (guint16) (color_button->priv->rgba.red * 65535);
436 dropped[1] = (guint16) (color_button->priv->rgba.green * 65535);
437 dropped[2] = (guint16) (color_button->priv->rgba.blue * 65535);
438 dropped[3] = (guint16) (color_button->priv->rgba.alpha * 65535);
440 gtk_selection_data_set (selection_data,
441 gtk_selection_data_get_target (selection_data),
442 16, (guchar *)dropped, 8);
446 gtk_color_button_init (GtkColorButton *color_button)
448 GtkWidget *alignment;
453 /* Create the widgets */
454 color_button->priv = G_TYPE_INSTANCE_GET_PRIVATE (color_button,
455 GTK_TYPE_COLOR_BUTTON,
456 GtkColorButtonPrivate);
458 gtk_widget_push_composite_child ();
460 alignment = gtk_alignment_new (0.5, 0.5, 0.5, 1.0);
461 gtk_container_set_border_width (GTK_CONTAINER (alignment), 1);
462 gtk_container_add (GTK_CONTAINER (color_button), alignment);
463 gtk_widget_show (alignment);
465 frame = gtk_frame_new (NULL);
466 gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_ETCHED_OUT);
467 gtk_container_add (GTK_CONTAINER (alignment), frame);
468 gtk_widget_show (frame);
470 /* Just some widget we can hook to expose-event on */
471 color_button->priv->draw_area = gtk_alignment_new (0.5, 0.5, 0.0, 0.0);
473 layout = gtk_widget_create_pango_layout (GTK_WIDGET (color_button), "Black");
474 pango_layout_get_pixel_extents (layout, NULL, &rect);
475 g_object_unref (layout);
477 gtk_widget_set_size_request (color_button->priv->draw_area, rect.width - 2, rect.height - 2);
478 g_signal_connect (color_button->priv->draw_area, "draw",
479 G_CALLBACK (gtk_color_button_draw_cb), color_button);
480 gtk_container_add (GTK_CONTAINER (frame), color_button->priv->draw_area);
481 gtk_widget_show (color_button->priv->draw_area);
483 color_button->priv->title = g_strdup (_("Pick a Color")); /* default title */
485 /* Start with opaque black, alpha disabled */
487 color_button->priv->rgba.red = 0;
488 color_button->priv->rgba.green = 0;
489 color_button->priv->rgba.blue = 0;
490 color_button->priv->rgba.alpha = 1;
491 color_button->priv->use_alpha = FALSE;
493 gtk_drag_dest_set (GTK_WIDGET (color_button),
494 GTK_DEST_DEFAULT_MOTION |
495 GTK_DEST_DEFAULT_HIGHLIGHT |
496 GTK_DEST_DEFAULT_DROP,
497 drop_types, 1, GDK_ACTION_COPY);
498 gtk_drag_source_set (GTK_WIDGET(color_button),
499 GDK_BUTTON1_MASK|GDK_BUTTON3_MASK,
502 g_signal_connect (color_button, "drag-begin",
503 G_CALLBACK (gtk_color_button_drag_begin), color_button);
504 g_signal_connect (color_button, "drag-data-received",
505 G_CALLBACK (gtk_color_button_drag_data_received), color_button);
506 g_signal_connect (color_button, "drag-data-get",
507 G_CALLBACK (gtk_color_button_drag_data_get), color_button);
509 gtk_widget_pop_composite_child ();
513 gtk_color_button_finalize (GObject *object)
515 GtkColorButton *color_button = GTK_COLOR_BUTTON (object);
517 if (color_button->priv->cs_dialog != NULL)
518 gtk_widget_destroy (color_button->priv->cs_dialog);
519 color_button->priv->cs_dialog = NULL;
521 g_free (color_button->priv->title);
522 color_button->priv->title = NULL;
524 G_OBJECT_CLASS (gtk_color_button_parent_class)->finalize (object);
529 * gtk_color_button_new:
531 * Creates a new color button.
533 * This returns a widget in the form of a small button containing
534 * a swatch representing the current selected color. When the button
535 * is clicked, a color-selection dialog will open, allowing the user
536 * to select a color. The swatch will be updated to reflect the new
537 * color when the user finishes.
539 * Returns: a new color button
544 gtk_color_button_new (void)
546 return g_object_new (GTK_TYPE_COLOR_BUTTON, NULL);
550 * gtk_color_button_new_with_color:
551 * @color: A #GdkColor to set the current color with
553 * Creates a new color button.
555 * Returns: a new color button
560 gtk_color_button_new_with_color (const GdkColor *color)
562 return g_object_new (GTK_TYPE_COLOR_BUTTON, "color", color, NULL);
566 * gtk_color_button_new_with_rgba:
567 * @rgba: A #GdkRGBA to set the current color with
569 * Creates a new color button.
571 * Returns: a new color button
576 gtk_color_button_new_with_rgba (const GdkRGBA *rgba)
578 return g_object_new (GTK_TYPE_COLOR_BUTTON, "rgba", rgba, NULL);
582 dialog_ok_clicked (GtkWidget *widget,
585 GtkColorButton *color_button = GTK_COLOR_BUTTON (data);
586 GtkColorSelection *color_selection;
587 GtkColorSelectionDialog *selection_dialog;
589 selection_dialog = GTK_COLOR_SELECTION_DIALOG (color_button->priv->cs_dialog);
590 color_selection = GTK_COLOR_SELECTION (gtk_color_selection_dialog_get_color_selection (selection_dialog));
592 gtk_color_selection_get_current_rgba (color_selection, &color_button->priv->rgba);
594 gtk_widget_hide (color_button->priv->cs_dialog);
596 gtk_widget_queue_draw (color_button->priv->draw_area);
598 g_signal_emit (color_button, color_button_signals[COLOR_SET], 0);
600 g_object_freeze_notify (G_OBJECT (color_button));
601 g_object_notify (G_OBJECT (color_button), "color");
602 g_object_notify (G_OBJECT (color_button), "alpha");
603 g_object_notify (G_OBJECT (color_button), "rgba");
604 g_object_thaw_notify (G_OBJECT (color_button));
608 dialog_destroy (GtkWidget *widget,
611 GtkColorButton *color_button = GTK_COLOR_BUTTON (data);
613 color_button->priv->cs_dialog = NULL;
619 dialog_cancel_clicked (GtkWidget *widget,
622 GtkColorButton *color_button = GTK_COLOR_BUTTON (data);
624 gtk_widget_hide (color_button->priv->cs_dialog);
628 gtk_color_button_clicked (GtkButton *button)
630 GtkColorButton *color_button = GTK_COLOR_BUTTON (button);
631 GtkColorSelection *color_selection;
632 GtkColorSelectionDialog *color_dialog;
634 /* if dialog already exists, make sure it's shown and raised */
635 if (!color_button->priv->cs_dialog)
637 /* Create the dialog and connects its buttons */
639 GtkWidget *ok_button, *cancel_button;
641 parent = gtk_widget_get_toplevel (GTK_WIDGET (color_button));
643 color_button->priv->cs_dialog = gtk_color_selection_dialog_new (color_button->priv->title);
645 color_dialog = GTK_COLOR_SELECTION_DIALOG (color_button->priv->cs_dialog);
647 if (gtk_widget_is_toplevel (parent) && GTK_IS_WINDOW (parent))
649 if (GTK_WINDOW (parent) != gtk_window_get_transient_for (GTK_WINDOW (color_dialog)))
650 gtk_window_set_transient_for (GTK_WINDOW (color_dialog), GTK_WINDOW (parent));
652 gtk_window_set_modal (GTK_WINDOW (color_dialog),
653 gtk_window_get_modal (GTK_WINDOW (parent)));
656 g_object_get (color_dialog,
657 "ok-button", &ok_button,
658 "cancel-button", &cancel_button,
661 g_signal_connect (ok_button, "clicked",
662 G_CALLBACK (dialog_ok_clicked), color_button);
663 g_signal_connect (cancel_button, "clicked",
664 G_CALLBACK (dialog_cancel_clicked), color_button);
665 g_signal_connect (color_dialog, "destroy",
666 G_CALLBACK (dialog_destroy), color_button);
669 color_dialog = GTK_COLOR_SELECTION_DIALOG (color_button->priv->cs_dialog);
670 color_selection = GTK_COLOR_SELECTION (gtk_color_selection_dialog_get_color_selection (color_dialog));
672 gtk_color_selection_set_has_opacity_control (color_selection,
673 color_button->priv->use_alpha);
675 gtk_color_selection_set_previous_rgba (color_selection,
676 &color_button->priv->rgba);
677 gtk_color_selection_set_current_rgba (color_selection,
678 &color_button->priv->rgba);
680 gtk_window_present (GTK_WINDOW (color_button->priv->cs_dialog));
684 * gtk_color_button_set_color:
685 * @color_button: a #GtkColorButton
686 * @color: A #GdkColor to set the current color with
688 * Sets the current color to be @color.
693 gtk_color_button_set_color (GtkColorButton *color_button,
694 const GdkColor *color)
696 g_return_if_fail (GTK_IS_COLOR_BUTTON (color_button));
697 g_return_if_fail (color != NULL);
699 color_button->priv->rgba.red = color->red / 65535.;
700 color_button->priv->rgba.green = color->green / 65535.;
701 color_button->priv->rgba.blue = color->blue / 65535.;
703 gtk_widget_queue_draw (color_button->priv->draw_area);
705 g_object_notify (G_OBJECT (color_button), "color");
706 g_object_notify (G_OBJECT (color_button), "rgba");
711 * gtk_color_button_set_alpha:
712 * @color_button: a #GtkColorButton
713 * @alpha: an integer between 0 and 65535
715 * Sets the current opacity to be @alpha.
720 gtk_color_button_set_alpha (GtkColorButton *color_button,
723 g_return_if_fail (GTK_IS_COLOR_BUTTON (color_button));
725 color_button->priv->rgba.alpha = alpha / 65535.;
727 gtk_widget_queue_draw (color_button->priv->draw_area);
729 g_object_notify (G_OBJECT (color_button), "alpha");
730 g_object_notify (G_OBJECT (color_button), "rgba");
734 * gtk_color_button_get_color:
735 * @color_button: a #GtkColorButton
736 * @color: (out): a #GdkColor to fill in with the current color
738 * Sets @color to be the current color in the #GtkColorButton widget.
743 gtk_color_button_get_color (GtkColorButton *color_button,
746 g_return_if_fail (GTK_IS_COLOR_BUTTON (color_button));
748 color->red = (guint16) (color_button->priv->rgba.red * 65535);
749 color->green = (guint16) (color_button->priv->rgba.green * 65535);
750 color->blue = (guint16) (color_button->priv->rgba.blue * 65535);
754 * gtk_color_button_get_alpha:
755 * @color_button: a #GtkColorButton
757 * Returns the current alpha value.
759 * Return value: an integer between 0 and 65535
764 gtk_color_button_get_alpha (GtkColorButton *color_button)
766 g_return_val_if_fail (GTK_IS_COLOR_BUTTON (color_button), 0);
768 return (guint16) (color_button->priv->rgba.alpha * 65535);
772 * gtk_color_button_set_rgba:
773 * @color_button: a #GtkColorButton
774 * @rgba: a #GdkRGBA to set the current color with
776 * Sets the current color to be @rgba.
781 gtk_color_button_set_rgba (GtkColorButton *color_button,
784 g_return_if_fail (GTK_IS_COLOR_BUTTON (color_button));
785 g_return_if_fail (rgba != NULL);
787 color_button->priv->rgba = *rgba;
789 gtk_widget_queue_draw (color_button->priv->draw_area);
791 g_object_notify (G_OBJECT (color_button), "rgba");
795 * gtk_color_button_get_rgba:
796 * @color_button: a #GtkColorButton
797 * @rgba: (out): a #GdkRGBA to fill in with the current color
799 * Sets @rgba to be the current color in the #GtkColorButton widget.
804 gtk_color_button_get_rgba (GtkColorButton *color_button,
807 g_return_if_fail (GTK_IS_COLOR_BUTTON (color_button));
808 g_return_if_fail (rgba != NULL);
810 *rgba = color_button->priv->rgba;
814 * gtk_color_button_set_use_alpha:
815 * @color_button: a #GtkColorButton
816 * @use_alpha: %TRUE if color button should use alpha channel, %FALSE if not
818 * Sets whether or not the color button should use the alpha channel.
823 gtk_color_button_set_use_alpha (GtkColorButton *color_button,
826 g_return_if_fail (GTK_IS_COLOR_BUTTON (color_button));
828 use_alpha = (use_alpha != FALSE);
830 if (color_button->priv->use_alpha != use_alpha)
832 color_button->priv->use_alpha = use_alpha;
834 gtk_widget_queue_draw (color_button->priv->draw_area);
836 g_object_notify (G_OBJECT (color_button), "use-alpha");
841 * gtk_color_button_get_use_alpha:
842 * @color_button: a #GtkColorButton
844 * Does the color selection dialog use the alpha channel ?
846 * Returns: %TRUE if the color sample uses alpha channel, %FALSE if not
851 gtk_color_button_get_use_alpha (GtkColorButton *color_button)
853 g_return_val_if_fail (GTK_IS_COLOR_BUTTON (color_button), FALSE);
855 return color_button->priv->use_alpha;
860 * gtk_color_button_set_title:
861 * @color_button: a #GtkColorButton
862 * @title: String containing new window title
864 * Sets the title for the color selection dialog.
869 gtk_color_button_set_title (GtkColorButton *color_button,
874 g_return_if_fail (GTK_IS_COLOR_BUTTON (color_button));
876 old_title = color_button->priv->title;
877 color_button->priv->title = g_strdup (title);
880 if (color_button->priv->cs_dialog)
881 gtk_window_set_title (GTK_WINDOW (color_button->priv->cs_dialog),
882 color_button->priv->title);
884 g_object_notify (G_OBJECT (color_button), "title");
888 * gtk_color_button_get_title:
889 * @color_button: a #GtkColorButton
891 * Gets the title of the color selection dialog.
893 * Returns: An internal string, do not free the return value
897 G_CONST_RETURN gchar *
898 gtk_color_button_get_title (GtkColorButton *color_button)
900 g_return_val_if_fail (GTK_IS_COLOR_BUTTON (color_button), NULL);
902 return color_button->priv->title;
906 gtk_color_button_set_property (GObject *object,
911 GtkColorButton *color_button = GTK_COLOR_BUTTON (object);
916 gtk_color_button_set_use_alpha (color_button, g_value_get_boolean (value));
919 gtk_color_button_set_title (color_button, g_value_get_string (value));
922 gtk_color_button_set_color (color_button, g_value_get_boxed (value));
925 gtk_color_button_set_alpha (color_button, g_value_get_uint (value));
928 gtk_color_button_set_rgba (color_button, g_value_get_boxed (value));
931 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
937 gtk_color_button_get_property (GObject *object,
942 GtkColorButton *color_button = GTK_COLOR_BUTTON (object);
948 g_value_set_boolean (value, gtk_color_button_get_use_alpha (color_button));
951 g_value_set_string (value, gtk_color_button_get_title (color_button));
954 gtk_color_button_get_color (color_button, &color);
955 g_value_set_boxed (value, &color);
958 g_value_set_uint (value, gtk_color_button_get_alpha (color_button));
964 gtk_color_button_get_rgba (color_button, &rgba);
965 g_value_set_boxed (value, &rgba);
969 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);