Fix more "no previous declaration" warnings
[obnox/wireshark/wip.git] / 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  * Ethereal - Network traffic analyzer
8  * By Gerald Combs <gerald@ethereal.com>
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., 59 Temple Place - Suite 330, Boston, MA  02111-1307, 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_E;
48
49 /** display an "Ok" button */
50 #define ESD_BTN_OK     0x01 
51 /** display a "Cancel" button */
52 #define ESD_BTN_CANCEL 0x02 
53 /** display a "Yes" button */
54 #define ESD_BTN_YES    0x04 
55 /** display a "No" button */
56 #define ESD_BTN_NO     0x08 
57 /** display a "Clear" button */
58 #define ESD_BTN_CLEAR  0x10
59 /** display a "Save" button */
60 #define ESD_BTN_SAVE   0x20
61 /** display a "Continue without Saving" button */
62 #define ESD_BTN_DONT_SAVE 0x40 
63
64 /** Standard button combination "Ok" + "Cancel". */
65 #define ESD_BTNS_OK_CANCEL      (ESD_BTN_OK|ESD_BTN_CANCEL)
66 /** Standard button combination "Yes" + "No". */
67 #define ESD_BTNS_YES_NO         (ESD_BTN_YES|ESD_BTN_NO)
68 /** Standard button combination "Yes" + "No" + "Cancel". */
69 #define ESD_BTNS_YES_NO_CANCEL  (ESD_BTN_YES|ESD_BTN_NO|ESD_BTN_CANCEL)
70 /** Standard button combination "No" + "Cancel" + "Save". */
71 #define ESD_BTNS_SAVE_DONTSAVE_CANCEL (ESD_BTN_DONT_SAVE|ESD_BTN_CANCEL|ESD_BTN_SAVE)
72
73 #if __GNUC__ >= 2
74 /** Create and show a simple dialog.
75  *
76  * @param type type of dialog
77  * @param btn_mask the buttons to display
78  * @param msg_format printf like message format
79  * @param ... printf like parameters
80  * @return the newly created dialog
81  */
82 extern gpointer simple_dialog(ESD_TYPE_E type, gint btn_mask,
83     const gchar *msg_format, ...)
84     __attribute__((format (printf, 3, 4)));
85 /** Create and show a simple dialog using a va_list.
86  *
87  * @param type type of dialog
88  * @param btn_mask the buttons to display
89  * @param msg_format printf like message format
90  * @param ap parameters
91  * @return the newly created dialog
92  */
93 extern gpointer vsimple_dialog(ESD_TYPE_E type, gint btn_mask,
94    const gchar *msg_format, va_list ap);
95 #else
96 /** Create and show a simple dialog.
97  *
98  * @param type type of dialog
99  * @param btn_mask the buttons to display
100  * @param msg_format printf like message format
101  * @param ... printf like parameters
102  * @return the newly created dialog
103  */
104 extern gpointer simple_dialog(ESD_TYPE_E type, gint btn_mask,
105     const gchar *msg_format, ...);
106 /** Create and show a simple dialog using a va_list.
107  *
108  * @param type type of dialog
109  * @param btn_mask the buttons to display
110  * @param msg_format printf like message format
111  * @param ap parameters
112  * @return the newly created dialog
113  */
114 extern gpointer vsimple_dialog(ESD_TYPE_E type, gint btn_mask,
115     const gchar *msg_format, va_list ap);
116 #endif
117
118 /** Callback function type for simple_dialog_set_cb() */
119 typedef void (* simple_dialog_cb_t) (gpointer dialog, gint btn, gpointer data);
120
121 /** Set the callback function for the dialog, called when a button was pressed.
122  *
123  * @param dialog the dialog from simple_dialog()
124  * @param callback_fct the callback function to set
125  * @param data data to be passed to the callback function
126  */
127 extern void simple_dialog_set_cb(gpointer dialog, simple_dialog_cb_t callback_fct, gpointer data);
128
129 /** Add a check button to the dialog (e.g. "Don't show this message again")
130  * 
131  * @param dialog the dialog from simple_dialog()
132  * @param text the text to display 
133  */
134 extern void simple_dialog_check_set(gpointer dialog, gchar *text);
135
136 /** Get the check buttons state.
137  * 
138  * @param dialog the dialog from simple_dialog()
139  * @return current button state (TRUE is checked)
140  */
141 extern gboolean simple_dialog_check_get(gpointer dialog);
142
143 /** Surround the primary dialog message text by 
144  *  simple_dialog_primary_start() and simple_dialog_primary_end().
145  *  To highlight the first sentence (will take effect on GTK2 only).
146  */
147 extern char *simple_dialog_primary_start(void);
148 /** Surround the primary dialog message text by 
149  *  simple_dialog_primary_start() and simple_dialog_primary_end().
150  *  To highlight the first sentence (will take effect on GTK2 only).
151  */
152 extern char *simple_dialog_primary_end(void);
153
154 /** Escape the message text, if it probably contains Pango escape sequences.
155  *  For example html like tags starting with a <.
156  *
157  * @param msg the string to escape
158  * @return the escaped message text, must be freed with g_free() later
159  */
160 extern char *simple_dialog_format_message(const char *msg);
161
162 /**
163  * Display all queued messages.
164  * If a routine is called to display a dialog before there are any windows
165  * open, information to use to display the dialog is queued up.  This
166  * routine should be called once there are windows open, so that the queued
167  * up dialogs are displayed on top of those windows.
168  */
169 extern void display_queued_messages(void);
170
171 #ifdef __cplusplus
172 }
173 #endif /* __cplusplus */
174
175 #endif /* __DIALOG_H__ */