2 * This file is part of hildon-libs
4 * Copyright (C) 2005, 2006 Nokia Corporation, all rights reserved.
6 * Author: Kuisma Salonen <kuisma.salonen@nokia.com>
7 * Contact: Michael Dominic Kostrzewa <michael.kostrzewa@nokia.com>
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public License
11 * as published by the Free Software Foundation; version 2.1 of
12 * the License or any later version.
14 * This library is distributed in the hope that it will be useful, but
15 * WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this library; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
28 * SECTION:hildon-color-chooser-dialog
29 * @short_description: A dialog to choose a color.
30 * @see_also: #HildonColorButton, #HildonColorChooser
32 * HildonColorChooserDialog is a widget widget to choose a color.
37 #include "hildon-color-chooser-dialog.h"
39 #include "hildon-plugin-widget.h"
48 static HildonPluginWidgetInfo *global_plugin = NULL;
51 static guint color_chooser_dialog_signals[LAST_SIGNAL] = { 0 };
54 static void hildon_color_chooser_dialog_init(HildonColorChooserDialog *object);
55 static void hildon_color_chooser_dialog_class_init(HildonColorChooserDialogClass *klass);
58 GtkType hildon_color_chooser_dialog_get_type ()
60 static GtkType chooser_type = 0;
64 static const GtkTypeInfo chooser_info =
66 "HildonColorChooserDialog",
67 sizeof (HildonColorChooserDialog),
68 sizeof (HildonColorChooserDialogClass),
69 (GtkClassInitFunc) hildon_color_chooser_dialog_class_init,
70 (GtkObjectInitFunc) hildon_color_chooser_dialog_init,
71 /* reserved_1 */ NULL,
72 /* reserved_1 */ NULL,
73 (GtkClassInitFunc) NULL
76 chooser_type = gtk_type_unique (GTK_TYPE_DIALOG, &chooser_info);
83 static void hildon_color_chooser_dialog_init(HildonColorChooserDialog *object)
88 object->color.red = 0x0000;
89 object->color.green = 0x0000;
90 object->color.blue = 0x0000;
91 object->color.pixel = 0x00000000;
94 for(i = 0; i < 32; i++) {
95 object->reserved[i] = 0;
99 static void hildon_color_chooser_dialog_class_init(HildonColorChooserDialogClass *klass)
101 GtkObjectClass *object_klass = GTK_OBJECT_CLASS(klass);
105 for(i = 0; i < 32; i++) {
106 klass->reserved[i] = 0;
109 klass->set_color = 0;
112 color_chooser_dialog_signals[COLOR_CHANGED] = g_signal_new("color-changed", G_OBJECT_CLASS_TYPE (object_klass),
113 G_SIGNAL_RUN_FIRST, G_STRUCT_OFFSET (HildonColorChooserDialogClass, color_changed),
114 NULL, NULL, g_cclosure_marshal_VOID__BOXED, G_TYPE_NONE, 1, GDK_TYPE_COLOR);
118 * hildon_color_chooser_dialog_new:
120 * Creates a new color chooser dialog. The dialog is created through
121 * HildonPluginWidget API and is loaded from plugin. The initially selected
122 * color can be anything, so it's recommended to call
123 * hildon_color_chooser_dialog_set_color () after creating the widget.
125 * Returns: a new color chooser dialog
127 GtkWidget *hildon_color_chooser_dialog_new()
130 global_plugin = hildon_plugin_info_initialize(HILDON_TYPE_COLOR_CHOOSER_DIALOG, NULL);
131 g_return_val_if_fail (global_plugin != NULL, NULL);
134 return hildon_plugin_info_construct_widget(global_plugin);
138 * hildon_color_chooser_dialog_set_color:
139 * @chooser: a #HildonColorChooserDialog
140 * @color: a color to be set
142 * Sets the color selected in the dialog.
144 void hildon_color_chooser_dialog_set_color(HildonColorChooserDialog *chooser, GdkColor *color)
146 HildonColorChooserDialogClass *klass = HILDON_COLOR_CHOOSER_DIALOG_CLASS(G_OBJECT_GET_CLASS(chooser));
149 chooser->color = *color;
151 if(klass->set_color) {
152 klass->set_color(chooser, color);
157 * hildon_color_chooser_dialog_get_color:
158 * @chooser: a #HildonColorChooserDialog
159 * @color: a pointer to #GdkColor to be filled by the function
161 * Gets the color selected in the dialog.
163 void hildon_color_chooser_dialog_get_color(HildonColorChooserDialog *chooser, GdkColor *color)
165 *color = chooser->color;
169 void hildon_color_chooser_dialog_emit_color_changed(HildonColorChooserDialog *chooser)
171 g_signal_emit(chooser, color_chooser_dialog_signals[COLOR_CHANGED], 0, &chooser->color);