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 operaions 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,
  66                     const char *history_name, const char *def_text,
  67                     input_complete_t completion_flags);
  68 char *input_dialog_help (const char *header, const char *text, const char *help,
  69                          const char *history_name, const char *def_text, gboolean strip_password,
  70                          input_complete_t completion_flags);
  71 char *input_expand_dialog (const char *header, const char *text, const char *history_name,
  72                            const char *def_text, input_complete_t completion_flags);
  73 
  74 int query_dialog (const char *header, const char *text, int flags, int count, ...);
  75 void query_set_sel (int new_sel);
  76 
  77 /* Create message box but don't dismiss it yet, not background safe */
  78 /* *INDENT-OFF* */
  79 WDialog *create_message (int flags, const char *title, const char *text, ...)
  80         G_GNUC_PRINTF (3, 4);
  81 
  82 /* Show message box, background safe */
  83 void message (int flags, const char *title, const char *text, ...) G_GNUC_PRINTF (3, 4);
  84 /* *INDENT-ON* */
  85 
  86 gboolean mc_error_message (GError ** mcerror, int *code);
  87 
  88 status_msg_t *status_msg_create (const char *title, double delay, status_msg_cb init_cb,
  89                                  status_msg_update_cb update_cb, status_msg_cb deinit_cb);
  90 void status_msg_destroy (status_msg_t * sm);
  91 void status_msg_init (status_msg_t * sm, const char *title, double delay, status_msg_cb init_cb,
  92                       status_msg_update_cb update_cb, status_msg_cb deinit_cb);
  93 void status_msg_deinit (status_msg_t * sm);
  94 int status_msg_common_update (status_msg_t * sm);
  95 
  96 void simple_status_msg_init_cb (status_msg_t * sm);
  97 
  98 /*** inline functions ****************************************************************************/
  99 
 100 #endif /* MC__WTOOLS_H */

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