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 #include "lib/timer.h"
   9 
  10 /*** typedefs(not structures) and defined constants **********************************************/
  11 
  12 /* Pass this as def_text to request a password */
  13 #define INPUT_PASSWORD ((char *) -1)
  14 
  15 /* Use this as header for message() - it expands to "Error" */
  16 #define MSG_ERROR ((char *) -1)
  17 
  18 typedef struct status_msg_t status_msg_t;
  19 #define STATUS_MSG(x) ((status_msg_t *)(x))
  20 
  21 typedef struct simple_status_msg_t simple_status_msg_t;
  22 #define SIMPLE_STATUS_MSG(x) ((simple_status_msg_t *)(x))
  23 
  24 typedef void (*status_msg_cb) (status_msg_t * sm);
  25 typedef int (*status_msg_update_cb) (status_msg_t * sm);
  26 
  27 /*** enums ***************************************************************************************/
  28 
  29 /* flags for message() and query_dialog() */
  30 enum
  31 {
  32     D_NORMAL = 0,
  33     D_ERROR = (1 << 0),
  34     D_CENTER = (1 << 1)
  35 } /* dialog options */ ;
  36 
  37 /*** structures declarations (and typedefs of structures)*****************************************/
  38 
  39 /* Base class for status message of long-time operations.
  40    Useful to show progress of long-time operaions and interrupt it. */
  41 
  42 struct status_msg_t
  43 {
  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() */
  48 
  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 */
  52 };
  53 
  54 /* Simple status message with label and 'Abort' button */
  55 struct simple_status_msg_t
  56 {
  57     status_msg_t status_msg;    /* base class */
  58 
  59     WLabel *label;
  60 };
  61 
  62 /*** global variables defined in .c file *********************************************************/
  63 
  64 /*** declarations of public functions ************************************************************/
  65 
  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);
  75 
  76 int query_dialog (const char *header, const char *text, int flags, int count, ...);
  77 void query_set_sel (int new_sel);
  78 
  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);
  83 
  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* */
  87 
  88 gboolean mc_error_message (GError ** mcerror, int *code);
  89 
  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);
  97 
  98 void simple_status_msg_init_cb (status_msg_t * sm);
  99 
 100 /*** inline functions ****************************************************************************/
 101 
 102 #endif /* MC__WTOOLS_H */

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