2 * Definitions for alert box routines with toolkit-independent APIs but
3 * toolkit-dependent implementations.
7 * Wireshark - Network traffic analyzer
8 * By Gerald Combs <gerald@wireshark.org>
9 * Copyright 1998 Gerald Combs
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.
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.
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
31 #endif /* __cplusplus */
35 * @ingroup dialog_group
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
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 */
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
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_CANCEL (ESD_BTN_DONT_SAVE|ESD_BTN_CANCEL|ESD_BTN_SAVE)
77 /** Standard button combination "Quit without saving" + "Cancel" + "Save". */
78 #define ESD_BTNS_SAVE_QUIT_DONTSAVE_CANCEL (ESD_BTN_QUIT_DONT_SAVE|ESD_BTN_CANCEL|ESD_BTN_SAVE)
81 /** Create and show a simple dialog.
83 * @param type type of dialog
84 * @param btn_mask the buttons to display
85 * @param msg_format printf like message format
86 * @param ... printf like parameters
87 * @return the newly created dialog
89 extern gpointer simple_dialog(ESD_TYPE_E type, gint btn_mask,
90 const gchar *msg_format, ...)
91 __attribute__((format (printf, 3, 4)));
92 /** Create and show a simple dialog using a va_list.
94 * @param type type of dialog
95 * @param btn_mask the buttons to display
96 * @param msg_format printf like message format
97 * @param ap parameters
98 * @return the newly created dialog
100 extern gpointer vsimple_dialog(ESD_TYPE_E type, gint btn_mask,
101 const gchar *msg_format, va_list ap);
103 /** Create and show a simple dialog.
105 * @param type type of dialog
106 * @param btn_mask the buttons to display
107 * @param msg_format printf like message format
108 * @param ... printf like parameters
109 * @return the newly created dialog
111 extern gpointer simple_dialog(ESD_TYPE_E type, gint btn_mask,
112 const gchar *msg_format, ...);
113 /** Create and show a simple dialog using a va_list.
115 * @param type type of dialog
116 * @param btn_mask the buttons to display
117 * @param msg_format printf like message format
118 * @param ap parameters
119 * @return the newly created dialog
121 extern gpointer vsimple_dialog(ESD_TYPE_E type, gint btn_mask,
122 const gchar *msg_format, va_list ap);
125 /** Callback function type for simple_dialog_set_cb() */
126 typedef void (* simple_dialog_cb_t) (gpointer dialog, gint btn, gpointer data);
128 /** Set the callback function for the dialog, called when a button was pressed.
130 * @param dialog the dialog from simple_dialog()
131 * @param callback_fct the callback function to set
132 * @param data data to be passed to the callback function
134 extern void simple_dialog_set_cb(gpointer dialog, simple_dialog_cb_t callback_fct, gpointer data);
136 /** Close the dialog, useful for "no button" dialogs.
138 * @param dialog the dialog to close from simple_dialog()
140 extern void simple_dialog_close(gpointer dialog);
142 /** Add a check button to the dialog (e.g. "Don't show this message again")
144 * @param dialog the dialog from simple_dialog()
145 * @param text the text to display
147 extern void simple_dialog_check_set(gpointer dialog, gchar *text);
149 /** Get the check buttons state.
151 * @param dialog the dialog from simple_dialog()
152 * @return current button state (TRUE is checked)
154 extern gboolean simple_dialog_check_get(gpointer dialog);
156 /** Surround the primary dialog message text by
157 * simple_dialog_primary_start() and simple_dialog_primary_end().
158 * To highlight the first sentence (will take effect on GTK2 only).
160 extern char *simple_dialog_primary_start(void);
161 /** Surround the primary dialog message text by
162 * simple_dialog_primary_start() and simple_dialog_primary_end().
163 * To highlight the first sentence (will take effect on GTK2 only).
165 extern char *simple_dialog_primary_end(void);
167 /** Escape the message text, if it probably contains Pango escape sequences.
168 * For example html like tags starting with a <.
170 * @param msg the string to escape
171 * @return the escaped message text, must be freed with g_free() later
173 extern char *simple_dialog_format_message(const char *msg);
176 * Display all queued messages.
177 * If a routine is called to display a dialog before there are any windows
178 * open, information to use to display the dialog is queued up. This
179 * routine should be called once there are windows open, so that the queued
180 * up dialogs are displayed on top of those windows.
182 extern void display_queued_messages(void);
186 #endif /* __cplusplus */
188 #endif /* __DIALOG_H__ */