1 /* GTK - The GIMP Toolkit
2 * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
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.
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.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
21 * Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
22 * file for a list of people on the GTK+ Team. See the ChangeLog
23 * files for a list of changes. These files are distributed with
24 * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
29 #include "gtkcolorseldialog.h"
32 #include "gtkbutton.h"
35 #include "gtkbuildable.h"
47 /***************************/
48 /* GtkColorSelectionDialog */
49 /***************************/
51 static void gtk_color_selection_dialog_buildable_interface_init (GtkBuildableIface *iface);
52 static GObject * gtk_color_selection_dialog_buildable_get_internal_child (GtkBuildable *buildable,
54 const gchar *childname);
56 G_DEFINE_TYPE_WITH_CODE (GtkColorSelectionDialog, gtk_color_selection_dialog,
58 G_IMPLEMENT_INTERFACE (GTK_TYPE_BUILDABLE,
59 gtk_color_selection_dialog_buildable_interface_init))
61 static GtkBuildableIface *parent_buildable_iface;
64 gtk_color_selection_dialog_get_property (GObject *object,
69 GtkColorSelectionDialog *colorsel;
71 colorsel = GTK_COLOR_SELECTION_DIALOG (object);
75 case PROP_COLOR_SELECTION:
76 g_value_set_object (value, colorsel->colorsel);
79 g_value_set_object (value, colorsel->ok_button);
81 case PROP_CANCEL_BUTTON:
82 g_value_set_object (value, colorsel->cancel_button);
84 case PROP_HELP_BUTTON:
85 g_value_set_object (value, colorsel->help_button);
88 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
94 gtk_color_selection_dialog_class_init (GtkColorSelectionDialogClass *klass)
96 GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
97 gobject_class->get_property = gtk_color_selection_dialog_get_property;
99 g_object_class_install_property (gobject_class,
100 PROP_COLOR_SELECTION,
101 g_param_spec_object ("color-selection",
102 P_("Color Selection"),
103 P_("The color selection embedded in the dialog."),
106 g_object_class_install_property (gobject_class,
108 g_param_spec_object ("ok-button",
110 P_("The OK button of the dialog."),
113 g_object_class_install_property (gobject_class,
115 g_param_spec_object ("cancel-button",
117 P_("The cancel button of the dialog."),
120 g_object_class_install_property (gobject_class,
122 g_param_spec_object ("help-button",
124 P_("The help button of the dialog."),
130 gtk_color_selection_dialog_init (GtkColorSelectionDialog *colorseldiag)
132 GtkDialog *dialog = GTK_DIALOG (colorseldiag);
134 gtk_dialog_set_has_separator (dialog, FALSE);
135 gtk_container_set_border_width (GTK_CONTAINER (dialog), 5);
136 gtk_box_set_spacing (GTK_BOX (dialog->vbox), 2); /* 2 * 5 + 2 = 12 */
137 gtk_container_set_border_width (GTK_CONTAINER (dialog->action_area), 5);
138 gtk_box_set_spacing (GTK_BOX (dialog->action_area), 6);
140 colorseldiag->colorsel = gtk_color_selection_new ();
141 gtk_container_set_border_width (GTK_CONTAINER (colorseldiag->colorsel), 5);
142 gtk_color_selection_set_has_palette (GTK_COLOR_SELECTION(colorseldiag->colorsel), FALSE);
143 gtk_color_selection_set_has_opacity_control (GTK_COLOR_SELECTION(colorseldiag->colorsel), FALSE);
144 gtk_container_add (GTK_CONTAINER (GTK_DIALOG (colorseldiag)->vbox), colorseldiag->colorsel);
145 gtk_widget_show (colorseldiag->colorsel);
147 colorseldiag->cancel_button = gtk_dialog_add_button (GTK_DIALOG (colorseldiag),
149 GTK_RESPONSE_CANCEL);
151 colorseldiag->ok_button = gtk_dialog_add_button (GTK_DIALOG (colorseldiag),
155 gtk_widget_grab_default (colorseldiag->ok_button);
157 colorseldiag->help_button = gtk_dialog_add_button (GTK_DIALOG (colorseldiag),
161 gtk_widget_hide (colorseldiag->help_button);
163 gtk_dialog_set_alternative_button_order (GTK_DIALOG (colorseldiag),
169 gtk_window_set_title (GTK_WINDOW (colorseldiag),
170 _("Color Selection"));
172 _gtk_dialog_set_ignore_separator (dialog, TRUE);
176 gtk_color_selection_dialog_new (const gchar *title)
178 GtkColorSelectionDialog *colorseldiag;
180 colorseldiag = g_object_new (GTK_TYPE_COLOR_SELECTION_DIALOG, NULL);
183 gtk_window_set_title (GTK_WINDOW (colorseldiag), title);
185 gtk_window_set_resizable (GTK_WINDOW (colorseldiag), FALSE);
187 return GTK_WIDGET (colorseldiag);
191 * gtk_color_selection_dialog_get_color_selection:
192 * @colorsel: a #GtkColorSelectionDialog
194 * Retrieves the #GtkColorSelection widget embedded in the dialog.
196 * Returns: the embedded #GtkColorSelection
201 gtk_color_selection_dialog_get_color_selection (GtkColorSelectionDialog *colorsel)
203 g_return_val_if_fail (GTK_IS_COLOR_SELECTION_DIALOG (colorsel), NULL);
205 return colorsel->colorsel;
209 gtk_color_selection_dialog_buildable_interface_init (GtkBuildableIface *iface)
211 parent_buildable_iface = g_type_interface_peek_parent (iface);
212 iface->get_internal_child = gtk_color_selection_dialog_buildable_get_internal_child;
216 gtk_color_selection_dialog_buildable_get_internal_child (GtkBuildable *buildable,
218 const gchar *childname)
220 if (strcmp(childname, "ok_button") == 0)
221 return G_OBJECT (GTK_COLOR_SELECTION_DIALOG (buildable)->ok_button);
222 else if (strcmp(childname, "cancel_button") == 0)
223 return G_OBJECT (GTK_COLOR_SELECTION_DIALOG (buildable)->cancel_button);
224 else if (strcmp(childname, "help_button") == 0)
225 return G_OBJECT (GTK_COLOR_SELECTION_DIALOG(buildable)->help_button);
226 else if (strcmp(childname, "color_selection") == 0)
227 return G_OBJECT (GTK_COLOR_SELECTION_DIALOG(buildable)->colorsel);
229 return parent_buildable_iface->get_internal_child (buildable, builder, childname);
233 #define __GTK_COLOR_SELECTION_DIALOG_C__
234 #include "gtkaliasdef.c"