*
* Definitions for alert box routines with toolkit-independent APIs but
* toolkit-dependent implementations.
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <gerald@wireshark.org>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#ifndef __SIMPLE_DIALOG_UI_H__
#define __SIMPLE_DIALOG_UI_H__
#include <glib.h>
#include <stdbool.h>
#ifdef __cplusplus
extern "C" {
#endif
* Simple dialog box.
* @ingroup dialog_group
*/
typedef enum {
ESD_TYPE_INFO,
any action; the only button should be "OK" */
ESD_TYPE_WARN,
ESD_TYPE_CONFIRMATION,
one button */
ESD_TYPE_ERROR,
ESD_TYPE_STOP
} ESD_TYPE_E;
#define ESD_BTN_NONE 0x00
#define ESD_BTN_OK 0x01
#define ESD_BTN_CANCEL 0x02
#define ESD_BTN_YES 0x04
#define ESD_BTN_NO 0x08
#define ESD_BTN_CLEAR 0x10
#define ESD_BTN_SAVE 0x20
#define ESD_BTN_DONT_SAVE 0x40
#define ESD_BTN_QUIT_DONT_SAVE 0x80
#define ESD_BTNS_OK_CANCEL (ESD_BTN_OK|ESD_BTN_CANCEL)
#define ESD_BTNS_YES_NO (ESD_BTN_YES|ESD_BTN_NO)
#define ESD_BTNS_YES_NO_CANCEL (ESD_BTN_YES|ESD_BTN_NO|ESD_BTN_CANCEL)
#define ESD_BTNS_SAVE_DONTSAVE (ESD_BTN_SAVE|ESD_BTN_DONT_SAVE)
#define ESD_BTNS_SAVE_DONTSAVE_CANCEL (ESD_BTN_DONT_SAVE|ESD_BTN_CANCEL|ESD_BTN_SAVE)
#define ESD_BTNS_SAVE_QUIT_DONTSAVE_CANCEL (ESD_BTN_QUIT_DONT_SAVE|ESD_BTN_CANCEL|ESD_BTN_SAVE)
#define ESD_BTNS_QUIT_DONTSAVE_CANCEL (ESD_BTN_QUIT_DONT_SAVE|ESD_BTN_CANCEL)
*
* @param type type of dialog, e.g. ESD_TYPE_WARN
* @param btn_mask The buttons to display, e.g. ESD_BTNS_OK_CANCEL
* @param msg_format Printf like message format. Text must be plain.
* @param ... Printf like parameters
* @return The newly created dialog
*/
* XXX This is a bit clunky. We typically pass in:
* - simple_dialog_primary_start
* - The primary message
* - simple_dialog_primary_end
* - Optionally, the secondary message.
*
* In the Qt UI we use primary_start and _end to split the primary and
* secondary messages. They are then added to a QMessageBox via setText and
* setInformativeText respectively. No formatting is applied.
*
* Callers are responsible for wrapping the primary message and formatting
* the message text.
*
* Explicitly passing in separate primary and secondary messages would let us
* get rid of primary_start and primary_end and reduce the amount of
* gymnastics we have to do in the Qt UI.
*/
extern void *simple_dialog(ESD_TYPE_E type, int btn_mask,
const char *msg_format, ...)
G_GNUC_PRINTF(3, 4);
extern void *simple_dialog_async(ESD_TYPE_E type, int btn_mask,
const char *msg_format, ...)
G_GNUC_PRINTF(3, 4);
* simple_dialog_primary_start() and simple_dialog_primary_end().
*/
extern const char *simple_dialog_primary_start(void);
* simple_dialog_primary_start() and simple_dialog_primary_end().
*/
extern const char *simple_dialog_primary_end(void);
* For example html like tags starting with a <.
*
* @param msg the string to escape
* @return the escaped message text, must be freed with g_free() later
*/
extern char *simple_dialog_format_message(const char *msg);
* Alert box, with optional "don't show this message again" variable
* and checkbox, and optional secondary text.
*/
extern void simple_message_box(ESD_TYPE_E type, bool *notagain,
const char *secondary_msg,
const char *msg_format, ...) G_GNUC_PRINTF(4, 5);
* Error alert box, taking a format and a va_list argument.
*/
extern void vsimple_error_message_box(const char *msg_format, va_list ap);
* Error alert box, taking a format and a list of arguments.
*/
extern void simple_error_message_box(const char *msg_format, ...) G_GNUC_PRINTF(1, 2);
* Warning alert box, taking a format and a va_list argument.
*/
extern void vsimple_warning_message_box(const char *msg_format, va_list ap);
#ifdef __cplusplus
}
#endif
#endif