root/lib/widget/wtools.h

/* [previous][next][first][last][top][bottom][index][help]  */

INCLUDED FROM


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

/* [previous][next][first][last][top][bottom][index][help]  */