configure.c: fix AX_GCC_FUNC_ATTRIBUTE detection on custom CFLAGS
[midnight-commander.git] / lib / widget / wtools.h
blob3dbaef15fd8050b0dbd4a9dcb33199bae6581152
1 /** \file wtools.h
2 * \brief Header: widget based utility functions
3 */
5 #ifndef MC__WTOOLS_H
6 #define MC__WTOOLS_H
8 #include "lib/timer.h"
10 /*** typedefs(not structures) and defined constants **********************************************/
12 /* Pass this as def_text to request a password */
13 #define INPUT_PASSWORD ((char *) -1)
15 /* Use this as header for message() - it expands to "Error" */
16 #define MSG_ERROR ((char *) -1)
18 typedef struct status_msg_t status_msg_t;
19 #define STATUS_MSG(x) ((status_msg_t *)(x))
21 typedef struct simple_status_msg_t simple_status_msg_t;
22 #define SIMPLE_STATUS_MSG(x) ((simple_status_msg_t *)(x))
24 typedef void (*status_msg_cb) (status_msg_t * sm);
25 typedef int (*status_msg_update_cb) (status_msg_t * sm);
27 /*** enums ***************************************************************************************/
29 /* flags for message() and query_dialog() */
30 enum
32 D_NORMAL = 0,
33 D_ERROR = (1 << 0),
34 D_CENTER = (1 << 1)
35 } /* dialog options */ ;
37 /*** structures declarations (and typedefs of structures)*****************************************/
39 /* Base class for status message of long-time operations.
40 Useful to show progress of long-time operaions and interrupt it. */
42 struct status_msg_t
44 WDialog *dlg; /* pointer to status message dialog */
45 guint64 start; /* start time in microseconds */
46 guint64 delay; /* delay before raise the 'dlg' in microseconds */
47 gboolean block; /* how to get event using tty_get_event() */
49 status_msg_cb init; /* callback to init derived classes */
50 status_msg_update_cb update; /* callback to update dlg */
51 status_msg_cb deinit; /* callback to deinit derived classes */
54 /* Simple status message with label and 'Abort' button */
55 struct simple_status_msg_t
57 status_msg_t status_msg; /* base class */
59 WLabel *label;
62 /*** global variables defined in .c file *********************************************************/
64 /*** declarations of public functions ************************************************************/
66 /* The input dialogs */
67 char *input_dialog (const char *header, const char *text,
68 const char *history_name, const char *def_text,
69 input_complete_t completion_flags);
70 char *input_dialog_help (const char *header, const char *text, const char *help,
71 const char *history_name, const char *def_text, gboolean strip_password,
72 input_complete_t completion_flags);
73 char *input_expand_dialog (const char *header, const char *text, const char *history_name,
74 const char *def_text, input_complete_t completion_flags);
76 int query_dialog (const char *header, const char *text, int flags, int count, ...);
77 void query_set_sel (int new_sel);
79 /* Create message box but don't dismiss it yet, not background safe */
80 /* *INDENT-OFF* */
81 WDialog *create_message (int flags, const char *title, const char *text, ...)
82 G_GNUC_PRINTF (3, 4);
84 /* Show message box, background safe */
85 void message (int flags, const char *title, const char *text, ...) G_GNUC_PRINTF (3, 4);
86 /* *INDENT-ON* */
88 gboolean mc_error_message (GError ** mcerror, int *code);
90 status_msg_t *status_msg_create (const char *title, double delay, status_msg_cb init_cb,
91 status_msg_update_cb update_cb, status_msg_cb deinit_cb);
92 void status_msg_destroy (status_msg_t * sm);
93 void status_msg_init (status_msg_t * sm, const char *title, double delay, status_msg_cb init_cb,
94 status_msg_update_cb update_cb, status_msg_cb deinit_cb);
95 void status_msg_deinit (status_msg_t * sm);
96 int status_msg_common_update (status_msg_t * sm);
98 void simple_status_msg_init_cb (status_msg_t * sm);
100 /*** inline functions ****************************************************************************/
102 #endif /* MC__WTOOLS_H */