Delete extra_split if we're not using it. This keeps its handle from
[metze/wireshark/wip.git] / ui / simple_dialog.h
1 /* simple_dialog.h
2  * Definitions for alert box routines with toolkit-independent APIs but
3  * toolkit-dependent implementations.
4  *
5  * $Id$
6  *
7  * Wireshark - Network traffic analyzer
8  * By Gerald Combs <gerald@wireshark.org>
9  * Copyright 1998 Gerald Combs
10  *
11  * This program is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU General Public License
13  * as published by the Free Software Foundation; either version 2
14  * of the License, or (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program; if not, write to the Free Software
23  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24  */
25
26 #ifndef __DIALOG_H__
27 #define __DIALOG_H__
28
29 #ifdef __cplusplus
30 extern "C" {
31 #endif /* __cplusplus */
32
33 /** @file
34  *  Simple dialog box.
35  *  @ingroup dialog_group
36  */
37
38
39 /** Dialog types. */
40 typedef enum {
41     ESD_TYPE_INFO,          /**< tells the user something they should know, but not requiring
42                                     any action; the only button should be "OK" */
43     ESD_TYPE_WARN,          /**< tells the user about a problem; the only button should be "OK" */
44     ESD_TYPE_CONFIRMATION,  /**< asks the user for confirmation; there should be more than
45                                     one button */
46     ESD_TYPE_ERROR,         /**< tells the user about a serious problem; the only button should be "OK" */
47     ESD_TYPE_STOP           /**< tells the user a stop action is in progress, there should be no button */
48 } ESD_TYPE_E;
49
50 /** display no buttons at all */
51 #define ESD_BTN_NONE   0x00
52 /** display an "Ok" button */
53 #define ESD_BTN_OK     0x01
54 /** display a "Cancel" button */
55 #define ESD_BTN_CANCEL 0x02
56 /** display a "Yes" button */
57 #define ESD_BTN_YES    0x04
58 /** display a "No" button */
59 #define ESD_BTN_NO     0x08
60 /** display a "Clear" button */
61 #define ESD_BTN_CLEAR  0x10
62 /** display a "Save" button */
63 #define ESD_BTN_SAVE   0x20
64 /** display a "Continue without Saving" button */
65 #define ESD_BTN_DONT_SAVE 0x40
66 /** display a "Quit without Saving" button */
67 #define ESD_BTN_QUIT_DONT_SAVE 0x80
68
69 /** Standard button combination "Ok" + "Cancel". */
70 #define ESD_BTNS_OK_CANCEL      (ESD_BTN_OK|ESD_BTN_CANCEL)
71 /** Standard button combination "Yes" + "No". */
72 #define ESD_BTNS_YES_NO         (ESD_BTN_YES|ESD_BTN_NO)
73 /** Standard button combination "Yes" + "No" + "Cancel". */
74 #define ESD_BTNS_YES_NO_CANCEL  (ESD_BTN_YES|ESD_BTN_NO|ESD_BTN_CANCEL)
75 /** Standard button combination "No" + "Cancel" + "Save". */
76 #define ESD_BTNS_SAVE_DONTSAVE (ESD_BTN_SAVE|ESD_BTN_DONT_SAVE)
77 #define ESD_BTNS_SAVE_DONTSAVE_CANCEL (ESD_BTN_DONT_SAVE|ESD_BTN_CANCEL|ESD_BTN_SAVE)
78 /** Standard button combination "Quit without saving" + "Cancel" + "Save". */
79 #define ESD_BTNS_SAVE_QUIT_DONTSAVE_CANCEL (ESD_BTN_QUIT_DONT_SAVE|ESD_BTN_CANCEL|ESD_BTN_SAVE)
80 /** Standard button combination "Quit without saving" + "Cancel". */
81 #define ESD_BTNS_QUIT_DONTSAVE_CANCEL (ESD_BTN_QUIT_DONT_SAVE|ESD_BTN_CANCEL)
82
83 /** Create and show a simple dialog.
84  *
85  * @param type type of dialog
86  * @param btn_mask the buttons to display
87  * @param msg_format printf like message format
88  * @param ... printf like parameters
89  * @return the newly created dialog
90  */
91 extern gpointer simple_dialog(ESD_TYPE_E type, gint btn_mask,
92     const gchar *msg_format, ...)
93     G_GNUC_PRINTF(3, 4);
94
95 /** Create and show a simple dialog using a va_list.
96  *
97  * @param type type of dialog
98  * @param btn_mask the buttons to display
99  * @param msg_format printf like message format
100  * @param ap parameters
101  * @return the newly created dialog
102  */
103 extern gpointer vsimple_dialog(ESD_TYPE_E type, gint btn_mask,
104    const gchar *msg_format, va_list ap);
105
106 /** Callback function type for simple_dialog_set_cb() */
107 typedef void (* simple_dialog_cb_t) (gpointer dialog, gint btn, gpointer data);
108
109 /** Set the callback function for the dialog, called when a button was pressed.
110  *
111  * @param dialog the dialog from simple_dialog()
112  * @param callback_fct the callback function to set
113  * @param data data to be passed to the callback function
114  */
115 extern void simple_dialog_set_cb(gpointer dialog, simple_dialog_cb_t callback_fct, gpointer data);
116
117 /** Close the dialog, useful for "no button" dialogs.
118  *
119  * @param dialog the dialog to close from simple_dialog()
120  */
121 extern void simple_dialog_close(gpointer dialog);
122
123 /** Add a check button to the dialog (e.g. "Don't show this message again")
124  *
125  * @param dialog the dialog from simple_dialog()
126  * @param text the text to display
127  */
128 extern void simple_dialog_check_set(gpointer dialog, const gchar *text);
129
130 /** Get the check buttons state.
131  *
132  * @param dialog the dialog from simple_dialog()
133  * @return current button state (TRUE is checked)
134  */
135 extern gboolean simple_dialog_check_get(gpointer dialog);
136
137 /** Surround the primary dialog message text by
138  *  simple_dialog_primary_start() and simple_dialog_primary_end().
139  *  To highlight the first sentence (will take effect on GTK2 only).
140  */
141 extern const char *simple_dialog_primary_start(void);
142 /** Surround the primary dialog message text by
143  *  simple_dialog_primary_start() and simple_dialog_primary_end().
144  *  To highlight the first sentence (will take effect on GTK2 only).
145  */
146 extern const char *simple_dialog_primary_end(void);
147
148 /** Escape the message text, if it probably contains Pango escape sequences.
149  *  For example html like tags starting with a <.
150  *
151  * @param msg the string to escape
152  * @return the escaped message text, must be freed with g_free() later
153  */
154 extern char *simple_dialog_format_message(const char *msg);
155
156 /**
157  * Display all queued messages.
158  * If a routine is called to display a dialog before there are any windows
159  * open, information to use to display the dialog is queued up.  This
160  * routine should be called once there are windows open, so that the queued
161  * up dialogs are displayed on top of those windows.
162  */
163 extern void display_queued_messages(void);
164
165 /*
166  * Alert box, with optional "don't show this message again" variable
167  * and checkbox, and optional secondary text.
168  */
169 extern void simple_message_box(ESD_TYPE_E type, gboolean *notagain,
170                                const char *secondary_msg,
171                                const char *msg_format, ...)
172 #if __GNUC__ >= 2
173     __attribute__((format(printf, 4, 5)))
174 #endif
175 ;
176
177 /*
178  * Error alert box, taking a format and a va_list argument.
179  */
180 extern void vsimple_error_message_box(const char *msg_format, va_list ap);
181
182 /*
183  * Error alert box, taking a format and a list of arguments.
184  */
185 extern void simple_error_message_box(const char *msg_format, ...);
186
187 #ifdef __cplusplus
188 }
189 #endif /* __cplusplus */
190
191 #endif /* __DIALOG_H__ */
192
193 /*
194  * Editor modelines
195  *
196  * Local Variables:
197  * c-basic-offset: 4
198  * tab-width: 8
199  * indent-tabs-mode: nil
200  * End:
201  *
202  * ex: set shiftwidth=4 tabstop=8 expandtab:
203  * :indentSize=4:tabSize=8:noTabs=true:
204  */