]> Pileus Git - ~andy/gtk/blob - gtk/gtkcolorseldialog.c
g_string_printfa => g_string_append_printf.
[~andy/gtk] / gtk / gtkcolorseldialog.c
1 /* GTK - The GIMP Toolkit
2  * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
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, write to the
16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17  * Boston, MA 02111-1307, USA.
18  */
19
20 /*
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/. 
25  */
26 #include <glib.h>
27 #include "gtkcolorseldialog.h"
28 #include "gtkframe.h"
29 #include "gtkhbbox.h"
30 #include "gtkbutton.h"
31 #include "gtkstock.h"
32 #include "gtkintl.h"
33
34
35 static void gtk_color_selection_dialog_class_init (GtkColorSelectionDialogClass *klass);
36 static void gtk_color_selection_dialog_init (GtkColorSelectionDialog *colorseldiag);
37
38 static GtkWindowClass *color_selection_dialog_parent_class = NULL;
39
40
41 /***************************/
42 /* GtkColorSelectionDialog */
43 /***************************/
44
45 GtkType
46 gtk_color_selection_dialog_get_type (void)
47 {
48   static GtkType color_selection_dialog_type = 0;
49   
50   if (!color_selection_dialog_type)
51     {
52       GtkTypeInfo colorsel_diag_info =
53       {
54         "GtkColorSelectionDialog",
55         sizeof (GtkColorSelectionDialog),
56         sizeof (GtkColorSelectionDialogClass),
57         (GtkClassInitFunc) gtk_color_selection_dialog_class_init,
58         (GtkObjectInitFunc) gtk_color_selection_dialog_init,
59         /* reserved_1 */ NULL,
60         /* reserved_2 */ NULL,
61         (GtkClassInitFunc) NULL,
62       };
63       
64       color_selection_dialog_type = gtk_type_unique (GTK_TYPE_DIALOG, &colorsel_diag_info);
65     }
66   
67   return color_selection_dialog_type;
68 }
69
70 static void
71 gtk_color_selection_dialog_class_init (GtkColorSelectionDialogClass *klass)
72 {
73   GtkObjectClass *object_class;
74   
75   object_class = (GtkObjectClass*) klass;
76   
77   color_selection_dialog_parent_class = gtk_type_class (GTK_TYPE_DIALOG);
78 }
79
80 static void
81 gtk_color_selection_dialog_init (GtkColorSelectionDialog *colorseldiag)
82 {
83   GtkWidget *action_area_button_box, *frame;  
84   
85   frame = gtk_frame_new (NULL);
86   gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_NONE);
87   gtk_container_add (GTK_CONTAINER (GTK_DIALOG (colorseldiag)->vbox), frame);
88   gtk_container_set_border_width (GTK_CONTAINER (frame), 10); 
89   gtk_widget_show (frame); 
90   
91   colorseldiag->colorsel = gtk_color_selection_new ();
92   gtk_color_selection_set_has_palette (GTK_COLOR_SELECTION(colorseldiag->colorsel), FALSE); 
93   gtk_color_selection_set_has_opacity_control (GTK_COLOR_SELECTION(colorseldiag->colorsel), FALSE);
94   gtk_container_add (GTK_CONTAINER (frame), colorseldiag->colorsel);
95   gtk_widget_show (colorseldiag->colorsel);
96   
97   action_area_button_box = GTK_DIALOG (colorseldiag)->action_area;
98
99   colorseldiag->ok_button = gtk_dialog_add_button (GTK_DIALOG (colorseldiag),
100                                                    GTK_STOCK_OK,
101                                                    GTK_RESPONSE_OK);
102                                                    
103   gtk_widget_grab_default (colorseldiag->ok_button);
104   
105   colorseldiag->cancel_button = gtk_dialog_add_button (GTK_DIALOG (colorseldiag),
106                                                        GTK_STOCK_CANCEL,
107                                                        GTK_RESPONSE_CANCEL);
108   
109   colorseldiag->help_button = gtk_dialog_add_button (GTK_DIALOG (colorseldiag),
110                                                      GTK_STOCK_HELP,
111                                                      GTK_RESPONSE_HELP);
112
113   gtk_widget_hide (colorseldiag->help_button);
114 }
115
116 GtkWidget*
117 gtk_color_selection_dialog_new (const gchar *title)
118 {
119   GtkColorSelectionDialog *colorseldiag;
120   
121   colorseldiag = gtk_type_new (GTK_TYPE_COLOR_SELECTION_DIALOG);
122   gtk_window_set_title (GTK_WINDOW (colorseldiag), title);
123   gtk_window_set_policy(GTK_WINDOW (colorseldiag), FALSE, FALSE, TRUE);
124   
125   return GTK_WIDGET (colorseldiag);
126 }