]> Pileus Git - ~andy/gtk/blob - gtk/gtkdialog.h
create some stock buttons with the default accel group (create_image):
[~andy/gtk] / gtk / gtkdialog.h
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
27 #ifndef __GTK_DIALOG_H__
28 #define __GTK_DIALOG_H__
29
30
31 #include <gdk/gdk.h>
32 #include <gtk/gtkwindow.h>
33
34
35 #ifdef __cplusplus
36 extern "C" {
37 #endif /* __cplusplus */
38
39 /* Parameters for dialog construction */
40 typedef enum
41 {
42   GTK_DIALOG_MODAL,              /* call gtk_window_set_modal (win, TRUE) */
43   GTK_DIALOG_DESTROY_WITH_PARENT /* call gtk_window_set_destroy_with_parent () */
44
45 } GtkDialogFlags;
46
47 /* Convenience enum to use for action_id's.  Positive values are
48  * totally user-interpreted. GTK will sometimes return
49  * GTK_ACTION_NONE if no action_id is available.
50  *
51  *  Typical usage is:
52  *     if (gtk_dialog_run(dialog) == GTK_ACTION_ACCEPT)
53  *       blah();
54  */
55 typedef enum
56 {
57   /* GTK returns this if a response widget has no response_id,
58    * or the dialog gets destroyed with no response
59    */
60   GTK_RESPONSE_NONE = -1,
61   /* GTK won't return these unless you pass them in
62    * as the response for an action widget
63    */
64   GTK_RESPONSE_REJECT = -2,
65   GTK_RESPONSE_ACCEPT = -3
66 } GtkResponseType;
67
68
69 #define GTK_TYPE_DIALOG                  (gtk_dialog_get_type ())
70 #define GTK_DIALOG(obj)                  (GTK_CHECK_CAST ((obj), GTK_TYPE_DIALOG, GtkDialog))
71 #define GTK_DIALOG_CLASS(klass)          (GTK_CHECK_CLASS_CAST ((klass), GTK_TYPE_DIALOG, GtkDialogClass))
72 #define GTK_IS_DIALOG(obj)               (GTK_CHECK_TYPE ((obj), GTK_TYPE_DIALOG))
73 #define GTK_IS_DIALOG_CLASS(klass)       (GTK_CHECK_CLASS_TYPE ((klass), GTK_TYPE_DIALOG))
74 #define GTK_DIALOG_GET_CLASS(obj)        (GTK_CHECK_GET_CLASS ((obj), GTK_TYPE_DIALOG, GtkDialogClass))
75
76
77 typedef struct _GtkDialog        GtkDialog;
78 typedef struct _GtkDialogClass   GtkDialogClass;
79
80 struct _GtkDialog
81 {
82   GtkWindow window;
83
84   GtkWidget *vbox;
85   GtkWidget *action_area;
86 };
87
88 struct _GtkDialogClass
89 {
90   GtkWindowClass parent_class;
91
92   void (* response) (GtkDialog *dialog, gint response_id);
93 };
94
95
96 GtkType    gtk_dialog_get_type (void) G_GNUC_CONST;
97 GtkWidget* gtk_dialog_new      (void);
98
99 GtkWidget* gtk_dialog_new_with_buttons (const gchar     *title,
100                                         GtkWindow       *parent,
101                                         GtkDialogFlags   flags,
102                                         const gchar     *first_button_text,
103                                         ...);
104
105 void gtk_dialog_add_action_widget  (GtkDialog *dialog,
106                                     GtkWidget *child,
107                                     gint       response_id);
108
109 void gtk_dialog_add_button         (GtkDialog   *dialog,
110                                     const gchar *button_text,
111                                     gint         response_id);
112
113 void gtk_dialog_add_buttons        (GtkDialog   *dialog,
114                                     const gchar *first_button_text,
115                                     ...);
116
117 /* Emit response signal */
118 void gtk_dialog_response           (GtkDialog *dialog,
119                                     gint       response_id);
120
121 /* Returns response_id */
122 gint gtk_dialog_run                (GtkDialog *dialog);
123
124 #ifdef __cplusplus
125 }
126 #endif /* __cplusplus */
127
128
129 #endif /* __GTK_DIALOG_H__ */