Added functions to convert GError messages (which are in UTF-8 charset)
[midnight-commander.git] / src / wtools.h
blobd3d2f9b8a6335051350afe30e1947f312254540c
1 #ifndef MC_WTOOLS_H
2 #define MC_WTOOLS_H
4 #include "widget.h"
6 typedef struct {
7 struct Dlg_head *dlg;
8 struct WListbox *list;
9 } Listbox;
11 /* Listbox utility functions */
12 Listbox *create_listbox_window_delta (int delta_x, int delta_y, int cols, int lines, const char *title, const char *help);
14 Listbox *create_listbox_window (int cols, int lines, const char *title, const char *help);
15 #define LISTBOX_APPEND_TEXT(l,h,t,d) \
16 listbox_add_item (l->list, LISTBOX_APPEND_AT_END, h, t, d)
18 int run_listbox (Listbox *l);
20 /* Quick Widgets */
21 enum {
22 quick_end, quick_checkbox,
23 quick_button, quick_input,
24 quick_label, quick_radio
25 } /* quick_t */;
27 /* The widget is placed on relative_?/divisions_? of the parent widget */
29 typedef struct {
30 int widget_type;
31 int relative_x;
32 int x_divisions;
33 int relative_y;
34 int y_divisions;
36 const char *text; /* Text */
37 int hotkey_pos; /* the hotkey position */
38 int value; /* Buttons only: value of button */
39 int *result; /* Checkbutton: where to store result */
40 char **str_result; /* Input lines: destination */
41 const char *histname; /* Name of the section for saving history */
42 bcback cb; /* Callback for quick_button */
44 Widget *widget;
45 } QuickWidget;
46 #define NULL_QuickWidget { 0, 0, 0, 0, 0, NULL, 0, 0, NULL, NULL, NULL, NULL, NULL }
48 typedef struct {
49 int xlen, ylen;
50 int xpos, ypos; /* if -1, then center the dialog */
51 const char *title;
52 const char *help;
53 QuickWidget *widgets;
54 int i18n; /* If true, internationalization has happened */
55 } QuickDialog;
57 int quick_dialog (QuickDialog *qd);
58 int quick_dialog_skip (QuickDialog *qd, int nskip);
60 /* The input dialogs */
62 /* Pass this as def_text to request a password */
63 #define INPUT_PASSWORD ((char *) -1)
65 char *input_dialog (const char *header, const char *text,
66 const char *history_name, const char *def_text);
67 char *input_dialog_help (const char *header, const char *text, const char *help,
68 const char *history_name, const char *def_text);
69 char *input_expand_dialog (const char *header, const char *text,
70 const char *history_name, const char *def_text);
72 void query_set_sel (int new_sel);
74 /* Create message box but don't dismiss it yet, not background safe */
75 struct Dlg_head *create_message (int flags, const char *title,
76 const char *text, ...)
77 __attribute__ ((format (__printf__, 3, 4)));
79 /* Show message box, background safe */
80 void message (int flags, const char *title, const char *text, ...)
81 __attribute__ ((format (__printf__, 3, 4)));
84 /* Use this as header for message() - it expands to "Error" */
85 #define MSG_ERROR ((char *) -1)
87 int query_dialog (const char *header, const char *text, int flags, int count, ...);
89 /* flags for message() and query_dialog() */
90 enum {
91 D_NORMAL = 0,
92 D_ERROR = 1
93 } /* dialog options */;
95 #endif