nexmon – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 /* simple_dialog.h
2 * Definitions for alert box routines with toolkit-independent APIs but
3 * toolkit-dependent implementations.
4 *
5 * Wireshark - Network traffic analyzer
6 * By Gerald Combs <gerald@wireshark.org>
7 * Copyright 1998 Gerald Combs
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version 2
12 * of the License, or (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 */
23  
24 #ifndef __SIMPLE_DIALOG_UI_H__
25 #define __SIMPLE_DIALOG_UI_H__
26  
27 #ifdef __cplusplus
28 extern "C" {
29 #endif /* __cplusplus */
30  
31 /** @file
32 * Simple dialog box.
33 * @ingroup dialog_group
34 */
35  
36  
37 /** Dialog types. */
38 typedef enum {
39 ESD_TYPE_INFO, /**< tells the user something they should know, but not requiring
40 any action; the only button should be "OK" */
41 ESD_TYPE_WARN, /**< tells the user about a problem; the only button should be "OK" */
42 ESD_TYPE_CONFIRMATION, /**< asks the user for confirmation; there should be more than
43 one button */
44 ESD_TYPE_ERROR, /**< tells the user about a serious problem; the only button should be "OK" */
45 ESD_TYPE_STOP /**< tells the user a stop action is in progress, there should be no button */
46 } ESD_TYPE_E;
47  
48 /** display no buttons at all */
49 #define ESD_BTN_NONE 0x00
50 /** display an "Ok" button */
51 #define ESD_BTN_OK 0x01
52 /** display a "Cancel" button */
53 #define ESD_BTN_CANCEL 0x02
54 /** display a "Yes" button */
55 #define ESD_BTN_YES 0x04
56 /** display a "No" button */
57 #define ESD_BTN_NO 0x08
58 /** display a "Clear" button */
59 #define ESD_BTN_CLEAR 0x10
60 /** display a "Save" button */
61 #define ESD_BTN_SAVE 0x20
62 /** display a "Continue without Saving" button */
63 #define ESD_BTN_DONT_SAVE 0x40
64 /** display a "Quit without Saving" button */
65 #define ESD_BTN_QUIT_DONT_SAVE 0x80
66  
67 /** Standard button combination "Ok" + "Cancel". */
68 #define ESD_BTNS_OK_CANCEL (ESD_BTN_OK|ESD_BTN_CANCEL)
69 /** Standard button combination "Yes" + "No". */
70 #define ESD_BTNS_YES_NO (ESD_BTN_YES|ESD_BTN_NO)
71 /** Standard button combination "Yes" + "No" + "Cancel". */
72 #define ESD_BTNS_YES_NO_CANCEL (ESD_BTN_YES|ESD_BTN_NO|ESD_BTN_CANCEL)
73 /** Standard button combination "No" + "Cancel" + "Save". */
74 #define ESD_BTNS_SAVE_DONTSAVE (ESD_BTN_SAVE|ESD_BTN_DONT_SAVE)
75 #define ESD_BTNS_SAVE_DONTSAVE_CANCEL (ESD_BTN_DONT_SAVE|ESD_BTN_CANCEL|ESD_BTN_SAVE)
76 /** Standard button combination "Quit without saving" + "Cancel" + "Save". */
77 #define ESD_BTNS_SAVE_QUIT_DONTSAVE_CANCEL (ESD_BTN_QUIT_DONT_SAVE|ESD_BTN_CANCEL|ESD_BTN_SAVE)
78 /** Standard button combination "Quit without saving" + "Cancel". */
79 #define ESD_BTNS_QUIT_DONTSAVE_CANCEL (ESD_BTN_QUIT_DONT_SAVE|ESD_BTN_CANCEL)
80  
81 /** Create and show a simple dialog.
82 *
83 * @param Type type of dialog, e.g. ESD_TYPE_WARN
84 * @param btn_mask The buttons to display, e.g. ESD_BTNS_OK_CANCEL
85 * @param msg_format Printf like message format. Text must be plain.
86 * @param ... Printf like parameters
87 * @return The newly created dialog
88 */
89 /*
90 * XXX This is a bit clunky. We typically pass in:
91 * - simple_dialog_primary_start
92 * - The primary message
93 * - simple_dialog_primary_end
94 * - Optionally, the secondary message.
95 *
96 * In the GTK+ UI primary_start and primary_end make up a <span> that adds
97 * text formatting. The whole string is then shoved into a GtkLabel.
98 *
99 * In the Qt UI we use primary_start and _end to split the primary and
100 * secondary messages. They are then added to a QMessageBox via setText and
101 * setInformativeText respectively. No formatting is applied.
102 *
103 * Callers are responsible for wrapping the primary message and formatting
104 * the message text.
105 *
106 * Explicitly passing in separate primary and secondary messages would let us
107 * get rid of primary_start and primary_end and reduce the amount of
108 * gymnastics we have to to in the Qt UI.
109 */
110 extern gpointer simple_dialog(ESD_TYPE_E type, gint btn_mask,
111 const gchar *msg_format, ...)
112 G_GNUC_PRINTF(3, 4);
113  
114 /** Surround the primary dialog message text by
115 * simple_dialog_primary_start() and simple_dialog_primary_end().
116 * To highlight the first sentence (will take effect on GTK2 only).
117 */
118 extern const char *simple_dialog_primary_start(void);
119 /** Surround the primary dialog message text by
120 * simple_dialog_primary_start() and simple_dialog_primary_end().
121 * To highlight the first sentence (will take effect on GTK2 only).
122 */
123 extern const char *simple_dialog_primary_end(void);
124  
125 /** Escape the message text, if it probably contains Pango escape sequences.
126 * For example html like tags starting with a <.
127 *
128 * @param msg the string to escape
129 * @return the escaped message text, must be freed with g_free() later
130 */
131 extern char *simple_dialog_format_message(const char *msg);
132  
133 /*
134 * Alert box, with optional "don't show this message again" variable
135 * and checkbox, and optional secondary text.
136 */
137 extern void simple_message_box(ESD_TYPE_E type, gboolean *notagain,
138 const char *secondary_msg,
139 const char *msg_format, ...) G_GNUC_PRINTF(4, 5);
140  
141 /*
142 * Error alert box, taking a format and a va_list argument.
143 */
144 extern void vsimple_error_message_box(const char *msg_format, va_list ap);
145  
146 /*
147 * Error alert box, taking a format and a list of arguments.
148 */
149 extern void simple_error_message_box(const char *msg_format, ...) G_GNUC_PRINTF(1, 2);
150  
151 #ifdef __cplusplus
152 }
153 #endif /* __cplusplus */
154  
155 #endif /* __SIMPLE_DIALOG_UI_H__ */
156  
157 /*
158 * Editor modelines
159 *
160 * Local Variables:
161 * c-basic-offset: 4
162 * tab-width: 8
163 * indent-tabs-mode: nil
164 * End:
165 *
166 * ex: set shiftwidth=4 tabstop=8 expandtab:
167 * :indentSize=4:tabSize=8:noTabs=true:
168 */