1/* GTK - The GIMP Toolkit
2 * Copyright (C) 2018, Red Hat, Inc
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#include "config.h"
19
20#include "gtkcolorpickerprivate.h"
21#include "gtkcolorpickerportalprivate.h"
22#include "gtkcolorpickershellprivate.h"
23#include "gtkcolorpickerkwinprivate.h"
24#include <gio/gio.h>
25
26
27G_DEFINE_INTERFACE_WITH_CODE (GtkColorPicker, gtk_color_picker, G_TYPE_OBJECT,
28 g_type_interface_add_prerequisite (g_define_type_id, G_TYPE_INITABLE);)
29
30static void
31gtk_color_picker_default_init (GtkColorPickerInterface *iface)
32{
33}
34
35void
36gtk_color_picker_pick (GtkColorPicker *picker,
37 GAsyncReadyCallback callback,
38 gpointer user_data)
39{
40 GTK_COLOR_PICKER_GET_INTERFACE (picker)->pick (picker, callback, user_data);
41}
42
43GdkRGBA *
44gtk_color_picker_pick_finish (GtkColorPicker *picker,
45 GAsyncResult *res,
46 GError **error)
47{
48 return GTK_COLOR_PICKER_GET_INTERFACE (picker)->pick_finish (picker, res, error);
49}
50
51GtkColorPicker *
52gtk_color_picker_new (void)
53{
54 GtkColorPicker *picker;
55
56 picker = gtk_color_picker_portal_new ();
57 if (!picker)
58 picker = gtk_color_picker_shell_new ();
59 if (!picker)
60 picker = gtk_color_picker_kwin_new ();
61
62 if (!picker)
63 g_debug ("No suitable GtkColorPicker implementation");
64 else
65 g_debug ("Using %s for picking colors", G_OBJECT_TYPE_NAME (picker));
66
67 return picker;
68}
69
70

source code of gtk/gtk/gtkcolorpicker.c