1 /* GTK - The GIMP Toolkit
3 * Copyright (C) 2012, Red Hat, Inc.
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the
17 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 * Boston, MA 02111-1307, USA.
23 #include "gtkcolorchooser.h"
24 #include "gtkcolorchooserprivate.h"
26 #include "gtktypebuiltins.h"
27 #include "gtkprivate.h"
35 static guint signals[LAST_SIGNAL];
37 G_DEFINE_INTERFACE (GtkColorChooser, gtk_color_chooser, G_TYPE_OBJECT);
40 gtk_color_chooser_default_init (GtkColorChooserInterface *iface)
42 g_object_interface_install_property (iface,
43 g_param_spec_boxed ("color",
45 P_("Current color, as a GdkRGBA"),
47 GTK_PARAM_READWRITE));
50 * GtkColorChooser::color-activated:
51 * @self: the object which received the signal
54 * Emitted when a color is activated from the color chooser.
55 * This usually happens when the user clicks a color swatch,
56 * or a color is selected and the user presses one of the keys
57 * Space, Shift+Space, Return or Enter.
59 signals[COLOR_ACTIVATED] =
60 g_signal_new ("color-activated",
61 GTK_TYPE_COLOR_CHOOSER,
63 G_STRUCT_OFFSET (GtkColorChooserInterface, color_activated),
71 * gtk_color_chooser_get_color:
72 * @chooser: a #GtkColorChooser
73 * @color: return location for the color
75 * Gets the currently-selected color.
78 gtk_color_chooser_get_color (GtkColorChooser *chooser,
81 g_return_if_fail (GTK_IS_COLOR_CHOOSER (chooser));
83 GTK_COLOR_CHOOSER_GET_IFACE (chooser)->get_color (chooser, color);
87 * gtk_color_chooser_set_color:
88 * @chooser: a #GtkColorChooser
89 * @color: the new color
91 * Sets the currently-selected color.
94 gtk_color_chooser_set_color (GtkColorChooser *chooser,
97 g_return_if_fail (GTK_IS_COLOR_CHOOSER (chooser));
98 g_return_if_fail (color != NULL);
100 GTK_COLOR_CHOOSER_GET_IFACE (chooser)->set_color (chooser, color);
104 _gtk_color_chooser_color_activated (GtkColorChooser *chooser,
105 const GdkRGBA *color)
107 g_return_if_fail (GTK_IS_COLOR_CHOOSER (chooser));
109 g_signal_emit (chooser, signals[COLOR_ACTIVATED], 0, color);