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 Library 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 * Library General Public License for more details.
14 * You should have received a copy of the GNU Library 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/.
27 #include "gtkcolorseldialog.h"
30 #include "gtkbutton.h"
34 static void gtk_color_selection_dialog_class_init (GtkColorSelectionDialogClass *klass);
35 static void gtk_color_selection_dialog_init (GtkColorSelectionDialog *colorseldiag);
37 static GtkWindowClass *color_selection_dialog_parent_class = NULL;
40 /***************************/
41 /* GtkColorSelectionDialog */
42 /***************************/
45 gtk_color_selection_dialog_get_type (void)
47 static GtkType color_selection_dialog_type = 0;
49 if (!color_selection_dialog_type)
51 GtkTypeInfo colorsel_diag_info =
53 "GtkColorSelectionDialog",
54 sizeof (GtkColorSelectionDialog),
55 sizeof (GtkColorSelectionDialogClass),
56 (GtkClassInitFunc) gtk_color_selection_dialog_class_init,
57 (GtkObjectInitFunc) gtk_color_selection_dialog_init,
58 /* reserved_1 */ NULL,
59 /* reserved_2 */ NULL,
60 (GtkClassInitFunc) NULL,
63 color_selection_dialog_type = gtk_type_unique (GTK_TYPE_DIALOG, &colorsel_diag_info);
66 return color_selection_dialog_type;
70 gtk_color_selection_dialog_class_init (GtkColorSelectionDialogClass *klass)
72 GtkObjectClass *object_class;
74 object_class = (GtkObjectClass*) klass;
76 color_selection_dialog_parent_class = gtk_type_class (GTK_TYPE_DIALOG);
80 gtk_color_selection_dialog_init (GtkColorSelectionDialog *colorseldiag)
82 GtkWidget *action_area_button_box, *frame;
84 gtk_widget_set_colormap (GTK_WIDGET (colorseldiag), gdk_rgb_get_cmap ());
85 gtk_widget_push_colormap (gdk_rgb_get_cmap ());
87 frame = gtk_frame_new (NULL);
88 gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_NONE);
89 gtk_container_add (GTK_CONTAINER (GTK_DIALOG (colorseldiag)->vbox), frame);
90 gtk_container_set_border_width (GTK_CONTAINER (frame), 10);
91 gtk_widget_show (frame);
93 colorseldiag->colorsel = gtk_color_selection_new ();
94 gtk_color_selection_set_use_palette (GTK_COLOR_SELECTION(colorseldiag->colorsel), FALSE);
95 gtk_color_selection_set_use_opacity (GTK_COLOR_SELECTION(colorseldiag->colorsel), FALSE);
96 gtk_container_add (GTK_CONTAINER (frame), colorseldiag->colorsel);
97 gtk_widget_show (colorseldiag->colorsel);
99 action_area_button_box = gtk_hbutton_box_new ();
100 gtk_button_box_set_layout (GTK_BUTTON_BOX(action_area_button_box), GTK_BUTTONBOX_END);
101 gtk_button_box_set_spacing (GTK_BUTTON_BOX(action_area_button_box), 5);
102 gtk_box_pack_end (GTK_BOX (GTK_DIALOG (colorseldiag)->action_area), action_area_button_box, TRUE, TRUE, 0);
103 gtk_widget_show (action_area_button_box);
105 colorseldiag->ok_button = gtk_button_new_with_label (_("OK"));
106 GTK_WIDGET_SET_FLAGS (colorseldiag->ok_button, GTK_CAN_DEFAULT);
107 gtk_box_pack_start (GTK_BOX (action_area_button_box), colorseldiag->ok_button, TRUE, TRUE, 0);
108 gtk_widget_grab_default (colorseldiag->ok_button);
109 gtk_widget_show (colorseldiag->ok_button);
111 colorseldiag->cancel_button = gtk_button_new_with_label (_("Cancel"));
112 GTK_WIDGET_SET_FLAGS (colorseldiag->cancel_button, GTK_CAN_DEFAULT);
113 gtk_box_pack_start (GTK_BOX (action_area_button_box), colorseldiag->cancel_button, TRUE, TRUE, 0);
114 gtk_widget_show (colorseldiag->cancel_button);
116 colorseldiag->help_button = gtk_button_new_with_label (_("Help"));
117 GTK_WIDGET_SET_FLAGS (colorseldiag->help_button, GTK_CAN_DEFAULT);
118 gtk_box_pack_start (GTK_BOX (action_area_button_box), colorseldiag->help_button, TRUE, TRUE, 0);
119 gtk_widget_show (colorseldiag->help_button);
121 gtk_widget_pop_colormap ();
125 gtk_color_selection_dialog_new (const gchar *title)
127 GtkColorSelectionDialog *colorseldiag;
129 colorseldiag = gtk_type_new (GTK_TYPE_COLOR_SELECTION_DIALOG);
130 gtk_window_set_title (GTK_WINDOW (colorseldiag), title);
131 gtk_window_set_policy(GTK_WINDOW (colorseldiag), FALSE, FALSE, TRUE);
133 return GTK_WIDGET (colorseldiag);