2 * Definitions for alert box routines with toolkit-independent APIs but
3 * toolkit-dependent implementations.
5 * Wireshark - Network traffic analyzer
6 * By Gerald Combs <gerald@wireshark.org>
7 * Copyright 1998 Gerald Combs
9 * SPDX-License-Identifier: GPL-2.0-or-later
12 #ifndef __SIMPLE_DIALOG_UI_H__
13 #define __SIMPLE_DIALOG_UI_H__
17 #endif /* __cplusplus */
21 * @ingroup dialog_group
27 ESD_TYPE_INFO, /**< tells the user something they should know, but not requiring
28 any action; the only button should be "OK" */
29 ESD_TYPE_WARN, /**< tells the user about a problem; the only button should be "OK" */
30 ESD_TYPE_CONFIRMATION, /**< asks the user for confirmation; there should be more than
32 ESD_TYPE_ERROR, /**< tells the user about a serious problem; the only button should be "OK" */
33 ESD_TYPE_STOP /**< tells the user a stop action is in progress, there should be no button */
36 /** display no buttons at all */
37 #define ESD_BTN_NONE 0x00
38 /** display an "Ok" button */
39 #define ESD_BTN_OK 0x01
40 /** display a "Cancel" button */
41 #define ESD_BTN_CANCEL 0x02
42 /** display a "Yes" button */
43 #define ESD_BTN_YES 0x04
44 /** display a "No" button */
45 #define ESD_BTN_NO 0x08
46 /** display a "Clear" button */
47 #define ESD_BTN_CLEAR 0x10
48 /** display a "Save" button */
49 #define ESD_BTN_SAVE 0x20
50 /** display a "Continue without Saving" button */
51 #define ESD_BTN_DONT_SAVE 0x40
52 /** display a "Quit without Saving" button */
53 #define ESD_BTN_QUIT_DONT_SAVE 0x80
55 /** Standard button combination "Ok" + "Cancel". */
56 #define ESD_BTNS_OK_CANCEL (ESD_BTN_OK|ESD_BTN_CANCEL)
57 /** Standard button combination "Yes" + "No". */
58 #define ESD_BTNS_YES_NO (ESD_BTN_YES|ESD_BTN_NO)
59 /** Standard button combination "Yes" + "No" + "Cancel". */
60 #define ESD_BTNS_YES_NO_CANCEL (ESD_BTN_YES|ESD_BTN_NO|ESD_BTN_CANCEL)
61 /** Standard button combination "No" + "Cancel" + "Save". */
62 #define ESD_BTNS_SAVE_DONTSAVE (ESD_BTN_SAVE|ESD_BTN_DONT_SAVE)
63 #define ESD_BTNS_SAVE_DONTSAVE_CANCEL (ESD_BTN_DONT_SAVE|ESD_BTN_CANCEL|ESD_BTN_SAVE)
64 /** Standard button combination "Quit without saving" + "Cancel" + "Save". */
65 #define ESD_BTNS_SAVE_QUIT_DONTSAVE_CANCEL (ESD_BTN_QUIT_DONT_SAVE|ESD_BTN_CANCEL|ESD_BTN_SAVE)
66 /** Standard button combination "Quit without saving" + "Cancel". */
67 #define ESD_BTNS_QUIT_DONTSAVE_CANCEL (ESD_BTN_QUIT_DONT_SAVE|ESD_BTN_CANCEL)
69 /** Create and show a simple dialog.
71 * @param type type of dialog, e.g. ESD_TYPE_WARN
72 * @param btn_mask The buttons to display, e.g. ESD_BTNS_OK_CANCEL
73 * @param msg_format Printf like message format. Text must be plain.
74 * @param ... Printf like parameters
75 * @return The newly created dialog
78 * XXX This is a bit clunky. We typically pass in:
79 * - simple_dialog_primary_start
80 * - The primary message
81 * - simple_dialog_primary_end
82 * - Optionally, the secondary message.
84 * In the Qt UI we use primary_start and _end to split the primary and
85 * secondary messages. They are then added to a QMessageBox via setText and
86 * setInformativeText respectively. No formatting is applied.
88 * Callers are responsible for wrapping the primary message and formatting
91 * Explicitly passing in separate primary and secondary messages would let us
92 * get rid of primary_start and primary_end and reduce the amount of
93 * gymnastics we have to to in the Qt UI.
95 extern gpointer simple_dialog(ESD_TYPE_E type, gint btn_mask,
96 const gchar *msg_format, ...)
99 /** Surround the primary dialog message text by
100 * simple_dialog_primary_start() and simple_dialog_primary_end().
102 extern const char *simple_dialog_primary_start(void);
103 /** Surround the primary dialog message text by
104 * simple_dialog_primary_start() and simple_dialog_primary_end().
106 extern const char *simple_dialog_primary_end(void);
108 /** Escape the message text, if it probably contains Pango escape sequences.
109 * For example html like tags starting with a <.
111 * @param msg the string to escape
112 * @return the escaped message text, must be freed with g_free() later
114 extern char *simple_dialog_format_message(const char *msg);
117 * Alert box, with optional "don't show this message again" variable
118 * and checkbox, and optional secondary text.
120 extern void simple_message_box(ESD_TYPE_E type, gboolean *notagain,
121 const char *secondary_msg,
122 const char *msg_format, ...) G_GNUC_PRINTF(4, 5);
125 * Error alert box, taking a format and a va_list argument.
127 extern void vsimple_error_message_box(const char *msg_format, va_list ap);
130 * Error alert box, taking a format and a list of arguments.
132 extern void simple_error_message_box(const char *msg_format, ...) G_GNUC_PRINTF(1, 2);
135 * Warning alert box, taking a format and a va_list argument.
137 extern void vsimple_warning_message_box(const char *msg_format, va_list ap);
141 #endif /* __cplusplus */
143 #endif /* __SIMPLE_DIALOG_UI_H__ */
151 * indent-tabs-mode: nil
154 * ex: set shiftwidth=4 tabstop=8 expandtab:
155 * :indentSize=4:tabSize=8:noTabs=true: