Merge branch 'DEV_quick_widget'

* DEV_quick_widget:
  Fixed segfault in editor options dialog.
  Fixed radiobutton label for Macintosh line break.
  Ticket #1562: simplfication API of QuickDialog.
This commit is contained in:
Andrew Borodin 2009-09-03 11:41:16 +04:00
commit bf7b330f34
13 changed files with 1027 additions and 1287 deletions

View File

@ -383,77 +383,76 @@ edit_save_file (WEdit *edit, const char *filename)
return 0;
}
void menu_save_mode_cmd (void)
void
menu_save_mode_cmd (void)
{
#define DLG_X 38
#define DLG_Y 10
static char *str_result;
static int save_mode_new;
static const char *str[] =
/* diaog sizes */
const int DLG_X = 38;
const int DLG_Y = 10;
char *str_result;
const char *str[] =
{
N_("Quick save "),
N_("Safe save "),
N_("Do backups -->")};
N_("Do backups -->")
};
static QuickWidget widgets[] =
QuickWidget widgets[] =
{
{quick_button, 18, DLG_X, 7, DLG_Y, N_("&Cancel"), 0,
B_CANCEL, 0, 0, NULL, NULL, NULL},
{quick_button, 6, DLG_X, 7, DLG_Y, N_("&OK"), 0,
B_ENTER, 0, 0, NULL, NULL, NULL},
{quick_input, 23, DLG_X, 5, DLG_Y, 0, 9,
0, 0, &str_result, "edit-backup-ext", NULL, NULL},
{quick_label, 22, DLG_X, 4, DLG_Y, N_("Extension:"), 0,
0, 0, 0, NULL, NULL, NULL},
{quick_radio, 4, DLG_X, 3, DLG_Y, "", 3,
0, &save_mode_new, (char **) str, NULL, NULL, NULL},
NULL_QuickWidget};
static QuickDialog dialog =
{DLG_X, DLG_Y, -1, -1, N_(" Edit Save Mode "), "[Edit Save Mode]",
widgets, 0};
static int i18n_flag = 0;
/* 0 */ QUICK_BUTTON (18, DLG_X, 7, DLG_Y, N_("&Cancel"), B_CANCEL, NULL),
/* 1 */ QUICK_BUTTON ( 6, DLG_X, 7, DLG_Y, N_("&OK"), B_ENTER, NULL),
/* 2 */ QUICK_INPUT (23, DLG_X, 5, DLG_Y, option_backup_ext, 9, 0, "edit-backup-ext", &str_result),
/* 3 */ QUICK_LABEL (22, DLG_X, 4, DLG_Y, N_("Extension:")),
/* 4 */ QUICK_RADIO ( 4, DLG_X, 3, DLG_Y, 3, str, &option_save_mode),
QUICK_END
};
if (!i18n_flag) {
size_t i;
size_t maxlen = 0;
int dlg_x;
size_t l1;
QuickDialog dialog =
{
DLG_X, DLG_Y, -1, -1, N_(" Edit Save Mode "),
"[Edit Save Mode]", widgets, FALSE
};
/* OK/Cancel buttons */
l1 = str_term_width1 (_(widgets[0].text)) + str_term_width1 (_(widgets[1].text)) + 5;
maxlen = max (maxlen, l1);
for (i = 0; i < 3; i++ ) {
str[i] = _(str[i]);
maxlen = max (maxlen, (size_t) str_term_width1 (str[i]) + 7);
}
i18n_flag = 1;
dlg_x = maxlen + str_term_width1 (_(widgets[3].text)) + 5 + 1;
widgets[2].hotkey_pos = str_term_width1 (_(widgets[3].text)); /* input field length */
dlg_x = min (COLS, dlg_x);
dialog.xlen = dlg_x;
i = (dlg_x - l1)/3;
widgets[1].relative_x = i;
widgets[0].relative_x = i + str_term_width1 (_(widgets[1].text)) + i + 4;
widgets[2].relative_x = widgets[3].relative_x = maxlen + 2;
for (i = 0; i < sizeof (widgets)/sizeof (widgets[0]); i++)
widgets[i].x_divisions = dlg_x;
}
size_t i;
size_t maxlen = 0;
int dlg_x;
size_t l1, w0, w1, w3;
assert (option_backup_ext != NULL);
widgets[2].text = option_backup_ext;
widgets[4].value = option_save_mode;
if (quick_dialog (&dialog) != B_ENTER)
return;
option_save_mode = save_mode_new;
g_free (option_backup_ext);
option_backup_ext = str_result;
str_result = NULL;
/* OK/Cancel buttons */
w0 = str_term_width1 (_(widgets[0].u.button.text)) + 2;
w1 = str_term_width1 (_(widgets[1].u.button.text)) + 4; /* default batton */
w3 = str_term_width1 (_(widgets[3].u.label.text));
maxlen = l1 = w0 + w1 + 6;
for (i = 0; i < 3; i++) {
#ifdef ENABLE_NLS
str[i] = _(str[i]);
#endif
maxlen = max (maxlen, (size_t) str_term_width1 (str[i]) + 7);
}
dlg_x = maxlen + w3 + 5 + 2;
widgets[2].u.input.len = w3; /* input field length */
dlg_x = min (COLS, dlg_x);
dialog.xlen = dlg_x;
widgets[0].relative_x = dlg_x * 2/3 - w0/2;
widgets[1].relative_x = dlg_x/3 - w1/2;
widgets[2].relative_x = widgets[3].relative_x = maxlen + 3;
for (i = 0; i < sizeof (widgets)/sizeof (widgets[0]); i++)
widgets[i].x_divisions = dlg_x;
if (quick_dialog (&dialog) != B_CANCEL) {
g_free (option_backup_ext);
option_backup_ext = str_result;
}
}
void
@ -477,42 +476,37 @@ edit_get_save_file_as (WEdit *edit)
#define DLG_WIDTH 64
#define DLG_HEIGHT 14
static LineBreaks cur_lb = LB_ASIS;
char *filename = edit->filename;
const char *lb_names[LB_NAMES] =
char *lb_names[LB_NAMES] =
{
N_("&Do not change"),
N_("&Unix format (LF)"),
N_("&Windows/DOS format (CR LF)"),
N_("&Macintosh format (LF)")
N_("&Macintosh format (CR)")
};
static LineBreaks cur_lb = LB_ASIS;
QuickWidget quick_widgets[] =
{
{quick_button, 6, 10, DLG_HEIGHT - 3, DLG_HEIGHT,
N_("&Cancel"), 0, B_CANCEL, NULL, NULL, NULL, NULL, NULL},
{quick_button, 2, 10, DLG_HEIGHT - 3, DLG_HEIGHT,
N_("&OK"), 0, B_ENTER, NULL, NULL, NULL, NULL, NULL},
{quick_radio, 5, DLG_WIDTH, DLG_HEIGHT - 8, DLG_HEIGHT, "",
LB_NAMES, cur_lb, (int *) &cur_lb, (char **) lb_names, NULL, NULL, NULL},
{quick_label, 3, DLG_WIDTH, DLG_HEIGHT - 9, DLG_HEIGHT,
N_("Change line breaks to:"), 0, 0, NULL, NULL, NULL, NULL, NULL},
{quick_input, 3, DLG_WIDTH, DLG_HEIGHT - 11, DLG_HEIGHT,
filename, 58, 0, 0, &filename, "save-file-as", NULL, NULL},
{quick_label, 2, DLG_WIDTH, DLG_HEIGHT - 12, DLG_HEIGHT,
N_(" Enter file name: "), 0, 0, NULL, NULL, NULL, NULL, NULL},
NULL_QuickWidget
QUICK_BUTTON (6, 10, DLG_HEIGHT - 3, DLG_HEIGHT, N_("&Cancel"), B_CANCEL, NULL),
QUICK_BUTTON (2, 10, DLG_HEIGHT - 3, DLG_HEIGHT, N_("&OK"), B_ENTER, NULL),
QUICK_RADIO (5, DLG_WIDTH, DLG_HEIGHT - 8, DLG_HEIGHT, LB_NAMES, (const char **) lb_names, &cur_lb),
QUICK_LABEL (3, DLG_WIDTH, DLG_HEIGHT - 9, DLG_HEIGHT, N_("Change line breaks to:")),
QUICK_INPUT (3, DLG_WIDTH, DLG_HEIGHT - 11, DLG_HEIGHT, filename, DLG_WIDTH - 6, 0, "save-as", &filename),
QUICK_LABEL (2, DLG_WIDTH, DLG_HEIGHT - 12, DLG_HEIGHT, N_(" Enter file name: ")),
QUICK_END
};
QuickDialog Quick_options =
{
DLG_WIDTH, DLG_HEIGHT, -1, -1, N_(" Save As "), "", quick_widgets, 0
DLG_WIDTH, DLG_HEIGHT, -1, -1,
N_(" Save As "), "[Save File As]",
quick_widgets, FALSE
};
if (quick_dialog (&Quick_options) != B_CANCEL)
{
if (quick_dialog (&Quick_options) != B_CANCEL) {
edit->lb = cur_lb;
return filename;
}
@ -2270,40 +2264,29 @@ void edit_mail_dialog (WEdit * edit)
static char *mail_subject_last = 0;
static char *mail_to_last = 0;
QuickDialog Quick_input =
{50, MAIL_DLG_HEIGHT, -1, 0, N_(" Mail "),
"[Input Line Keys]", 0, 0};
QuickWidget quick_widgets[] =
{
{quick_button, 6, 10, 9, MAIL_DLG_HEIGHT, N_("&Cancel"), 0, B_CANCEL, 0,
0, NULL, NULL, NULL},
{quick_button, 2, 10, 9, MAIL_DLG_HEIGHT, N_("&OK"), 0, B_ENTER, 0,
0, NULL, NULL, NULL},
{quick_input, 3, 50, 8, MAIL_DLG_HEIGHT, "", 44, 0, 0,
0, "mail-dlg-input", NULL, NULL},
{quick_label, 2, 50, 7, MAIL_DLG_HEIGHT, N_(" Copies to"), 0, 0, 0,
0, 0, NULL, NULL},
{quick_input, 3, 50, 6, MAIL_DLG_HEIGHT, "", 44, 0, 0,
0, "mail-dlg-input-2", NULL, NULL},
{quick_label, 2, 50, 5, MAIL_DLG_HEIGHT, N_(" Subject"), 0, 0, 0,
0, 0, NULL, NULL},
{quick_input, 3, 50, 4, MAIL_DLG_HEIGHT, "", 44, 0, 0,
0, "mail-dlg-input-3", NULL, NULL},
{quick_label, 2, 50, 3, MAIL_DLG_HEIGHT, N_(" To"), 0, 0, 0,
0, 0, NULL, NULL},
{quick_label, 2, 50, 2, MAIL_DLG_HEIGHT, N_(" mail -s <subject> -c <cc> <to>"), 0, 0, 0,
0, 0, NULL, NULL},
NULL_QuickWidget};
/* 0 */ QUICK_BUTTON (6, 10, 9, MAIL_DLG_HEIGHT, N_("&Cancel"), B_CANCEL, NULL),
/* 1 */ QUICK_BUTTON (2, 10, 9, MAIL_DLG_HEIGHT, N_("&OK"), B_ENTER, NULL),
/* 2 */ QUICK_INPUT (3, 50, 8, MAIL_DLG_HEIGHT, "", 44, 0, "mail-dlg-input", &tmail_cc),
/* 3 */ QUICK_LABEL (2, 50, 7, MAIL_DLG_HEIGHT, N_(" Copies to")),
/* 4 */ QUICK_INPUT (3, 50, 6, MAIL_DLG_HEIGHT, "", 44, 0, "mail-dlg-input-2", &tmail_subject),
/* 5 */ QUICK_LABEL (2, 50, 5, MAIL_DLG_HEIGHT, N_(" Subject")),
/* 6 */ QUICK_INPUT (3, 50, 4, MAIL_DLG_HEIGHT, "", 44, 0, "mail-dlg-input-3", &tmail_to),
/* 7 */ QUICK_LABEL (2, 50, 3, MAIL_DLG_HEIGHT, N_(" To")),
/* 8 */ QUICK_LABEL (2, 50, 2, MAIL_DLG_HEIGHT, N_(" mail -s <subject> -c <cc> <to>")),
QUICK_END
};
quick_widgets[2].str_result = &tmail_cc;
quick_widgets[2].text = mail_cc_last ? mail_cc_last : "";
quick_widgets[4].str_result = &tmail_subject;
quick_widgets[4].text = mail_subject_last ? mail_subject_last : "";
quick_widgets[6].str_result = &tmail_to;
quick_widgets[6].text = mail_to_last ? mail_to_last : "";
QuickDialog Quick_input =
{
50, MAIL_DLG_HEIGHT, -1, -1, N_(" Mail "),
"[Input Line Keys]", quick_widgets, FALSE
};
Quick_input.widgets = quick_widgets;
quick_widgets[2].u.input.text = mail_cc_last ? mail_cc_last : "";
quick_widgets[4].u.input.text = mail_subject_last ? mail_subject_last : "";
quick_widgets[6].u.input.text = mail_to_last ? mail_to_last : "";
if (quick_dialog (&Quick_input) != B_CANCEL) {
g_free (mail_cc_last);

View File

@ -70,7 +70,7 @@ editcmd_dialog_raw_key_query_cb (struct Dlg_head *h, dlg_msg_t msg, int parm)
{
switch (msg) {
case DLG_KEY:
h->running = 0;
dlg_stop (h);
h->ret_value = parm;
return MSG_HANDLED;
default:
@ -84,96 +84,49 @@ void
editcmd_dialog_replace_show (WEdit * edit, const char *search_default, const char *replace_default,
/*@out@ */ char **search_text, /*@out@ */ char **replace_text)
{
int treplace_backwards = edit->replace_backwards;
int tonly_in_selection = edit->only_in_selection;
int treplace_case = edit->replace_case;
int twhole_words = edit->whole_words;
int tall_codepages = edit->all_codepages;
mc_search_type_t ttype_of_search = edit->search_type;
int dialog_result;
gchar **list_of_types = mc_search_get_types_strings_array();
int REPLACE_DLG_HEIGHT = REPLACE_DLG_MIN_HEIGHT + g_strv_length (list_of_types) - REPLACE_DLG_HEIGHT_SUPPLY;
if (!*search_default)
if (*search_default == '\0')
search_default = INPUT_LAST_TEXT;
QuickWidget quick_widgets[] = {
{quick_button, 6, 10, 13, REPLACE_DLG_HEIGHT, N_("&Cancel"), 0, B_CANCEL,
0, 0, NULL, NULL, NULL},
{quick_button, 2, 10, 13, REPLACE_DLG_HEIGHT, N_("&OK"), 0, B_ENTER,
0, 0, NULL, NULL, NULL},
{
gchar **list_of_types = mc_search_get_types_strings_array();
int REPLACE_DLG_HEIGHT = REPLACE_DLG_MIN_HEIGHT + g_strv_length (list_of_types) - REPLACE_DLG_HEIGHT_SUPPLY;
QuickWidget quick_widgets[] =
{
/* 0 */ QUICK_BUTTON (6, 10, 13, REPLACE_DLG_HEIGHT, N_("&Cancel"), B_CANCEL, NULL),
/* 1 */ QUICK_BUTTON (2, 10, 13, REPLACE_DLG_HEIGHT, N_("&OK"), B_ENTER, NULL),
#ifdef HAVE_CHARSET
{quick_checkbox, 33, REPLACE_DLG_WIDTH, 11, REPLACE_DLG_HEIGHT, N_("&All charsets"), 0, 0,
&tall_codepages, 0, NULL, NULL, NULL},
/* 2 */ QUICK_CHECKBOX (33, REPLACE_DLG_WIDTH, 11, REPLACE_DLG_HEIGHT, N_("All charsets"), &edit->all_codepages),
#endif
/* 3 */ QUICK_CHECKBOX (33, REPLACE_DLG_WIDTH, 10, REPLACE_DLG_HEIGHT, N_("&Whole words"), &edit->whole_words),
/* 4 */ QUICK_CHECKBOX (33, REPLACE_DLG_WIDTH, 9, REPLACE_DLG_HEIGHT, N_("In se&lection"), &edit->only_in_selection),
/* 5 */ QUICK_CHECKBOX (33, REPLACE_DLG_WIDTH, 8, REPLACE_DLG_HEIGHT, N_("&Backwards"), &edit->replace_backwards),
/* 6 */ QUICK_CHECKBOX (33, REPLACE_DLG_WIDTH, 7, REPLACE_DLG_HEIGHT, N_("case &Sensitive"), &edit->replace_case),
/* 7 */ QUICK_RADIO (3, REPLACE_DLG_WIDTH, 7, REPLACE_DLG_HEIGHT,
g_strv_length (list_of_types), (const char **) list_of_types, &edit->search_type),
/* 8 */ QUICK_LABEL (2, REPLACE_DLG_WIDTH, 4, REPLACE_DLG_HEIGHT, N_(" Enter replacement string:")),
/* 9 */ QUICK_INPUT (3, REPLACE_DLG_WIDTH, 5, REPLACE_DLG_HEIGHT,
replace_default, REPLACE_DLG_WIDTH - 6, 0, "replace", replace_text),
/* 10 */ QUICK_LABEL (2, REPLACE_DLG_WIDTH, 2, REPLACE_DLG_HEIGHT, N_(" Enter search string:")),
/* 11 */ QUICK_INPUT (3, REPLACE_DLG_WIDTH, 3, REPLACE_DLG_HEIGHT,
search_default, REPLACE_DLG_WIDTH - 6, 0, MC_HISTORY_SHARED_SEARCH, search_text),
QUICK_END
};
{quick_checkbox, 33, REPLACE_DLG_WIDTH, 10, REPLACE_DLG_HEIGHT, N_("&Whole words"), 0, 0,
&twhole_words, 0, NULL, NULL, NULL},
QuickDialog Quick_input =
{
REPLACE_DLG_WIDTH, REPLACE_DLG_HEIGHT, -1, -1, N_(" Replace "),
"[Input Line Keys]", quick_widgets, FALSE
};
if (quick_dialog (&Quick_input) != B_CANCEL) {
edit->replace_mode = 0;
} else {
*replace_text = NULL;
*search_text = NULL;
}
{quick_checkbox, 33, REPLACE_DLG_WIDTH, 9, REPLACE_DLG_HEIGHT, N_("In se&lection"), 0, 0,
&tonly_in_selection, 0, NULL, NULL, NULL},
{quick_checkbox, 33, REPLACE_DLG_WIDTH, 8, REPLACE_DLG_HEIGHT, N_("&Backwards"), 0, 0,
&treplace_backwards, 0, NULL, NULL, NULL},
{quick_checkbox, 33, REPLACE_DLG_WIDTH, 7, REPLACE_DLG_HEIGHT, N_("case &Sensitive"), 0, 0,
&treplace_case, 0, NULL, NULL, NULL},
{quick_radio, 3, REPLACE_DLG_WIDTH, 7, REPLACE_DLG_HEIGHT, "", g_strv_length (list_of_types), ttype_of_search,
(void *) &ttype_of_search, const_cast (char **, list_of_types), NULL, NULL, NULL},
{quick_label, 2, REPLACE_DLG_WIDTH, 4, REPLACE_DLG_HEIGHT, N_(" Enter replacement string:"),
0, 0, 0, 0, 0, NULL, NULL},
{quick_input, 3, REPLACE_DLG_WIDTH, 5, REPLACE_DLG_HEIGHT, replace_default, 52, 0,
0, replace_text, "replace", NULL, NULL},
{quick_label, 2, REPLACE_DLG_WIDTH, 2, REPLACE_DLG_HEIGHT, N_(" Enter search string:"), 0,
0, 0, 0, 0, NULL, NULL},
{quick_input, 3, REPLACE_DLG_WIDTH, 3, REPLACE_DLG_HEIGHT, search_default, 52, 0,
0, search_text, MC_HISTORY_SHARED_SEARCH, NULL, NULL},
NULL_QuickWidget
};
QuickDialog Quick_input = {
REPLACE_DLG_WIDTH,
REPLACE_DLG_HEIGHT,
-1,
0,
N_(" Replace "),
"[Input Line Keys]",
quick_widgets,
0
};
dialog_result = quick_dialog (&Quick_input);
g_strfreev (list_of_types);
if (dialog_result != B_CANCEL) {
edit->search_type = ttype_of_search;
edit->replace_mode = 0;
edit->only_in_selection = tonly_in_selection;
edit->all_codepages = tall_codepages;
edit->replace_backwards = treplace_backwards;
edit->whole_words = twhole_words;
edit->replace_case = treplace_case;
return;
} else {
*replace_text = NULL;
*search_text = NULL;
return;
g_strfreev (list_of_types);
}
}
@ -182,68 +135,40 @@ editcmd_dialog_replace_show (WEdit * edit, const char *search_default, const cha
void
editcmd_dialog_search_show (WEdit * edit, char **search_text)
{
int tsearch_case = edit->replace_case;
int tsearch_backwards = edit->replace_backwards;
int tall_codepages = edit->all_codepages;
int twhole_words = edit->whole_words;
int tonly_in_selection = edit->only_in_selection;
mc_search_type_t ttype_of_search = edit->search_type;
gchar **list_of_types = mc_search_get_types_strings_array();
int SEARCH_DLG_HEIGHT = SEARCH_DLG_MIN_HEIGHT + g_strv_length (list_of_types) -
SEARCH_DLG_HEIGHT_SUPPLY;
if (!*search_text)
if (*search_text == '\0')
*search_text = INPUT_LAST_TEXT;
QuickWidget quick_widgets[] = {
{quick_button, 6, 10, 11, SEARCH_DLG_HEIGHT, N_("&Cancel"), 0, B_CANCEL, 0,
0, NULL, NULL, NULL},
{quick_button, 2, 10, 11, SEARCH_DLG_HEIGHT, N_("&OK"), 0, B_ENTER, 0,
0, NULL, NULL, NULL},
{
gchar **list_of_types = mc_search_get_types_strings_array();
int SEARCH_DLG_HEIGHT = SEARCH_DLG_MIN_HEIGHT + g_strv_length (list_of_types) - SEARCH_DLG_HEIGHT_SUPPLY;
QuickWidget quick_widgets[] =
{
/* 0 */ QUICK_BUTTON (6, 10, 11, SEARCH_DLG_HEIGHT, N_("&Cancel"), B_CANCEL, NULL),
/* 1 */ QUICK_BUTTON (2, 10, 11, SEARCH_DLG_HEIGHT, N_("&OK"), B_ENTER, NULL),
#ifdef HAVE_CHARSET
{quick_checkbox, 33, SEARCH_DLG_WIDTH, 9, SEARCH_DLG_HEIGHT, N_("&All charsets"), 0, 0,
&tall_codepages, 0, NULL, NULL, NULL},
/* 2 */ QUICK_CHECKBOX (33, SEARCH_DLG_WIDTH, 9, SEARCH_DLG_HEIGHT, N_("All charsets"), &edit->all_codepages),
#endif
/* 3 */ QUICK_CHECKBOX (33, SEARCH_DLG_WIDTH, 8, SEARCH_DLG_HEIGHT, N_("&Whole words"), &edit->whole_words),
/* 4 */ QUICK_CHECKBOX (33, SEARCH_DLG_WIDTH, 7, SEARCH_DLG_HEIGHT, N_("In se&lection"), &edit->only_in_selection),
/* 5 */ QUICK_CHECKBOX (33, SEARCH_DLG_WIDTH, 6, SEARCH_DLG_HEIGHT, N_("&Backwards"), &edit->replace_backwards),
/* 6 */ QUICK_CHECKBOX (33, SEARCH_DLG_WIDTH, 5, SEARCH_DLG_HEIGHT, N_("case &Sensitive"), &edit->replace_case),
/* 7 */ QUICK_RADIO ( 3, SEARCH_DLG_WIDTH, 5, SEARCH_DLG_HEIGHT,
g_strv_length (list_of_types), (const char **) list_of_types, &edit->search_type),
/* 8 */ QUICK_INPUT (3, SEARCH_DLG_WIDTH, 3, SEARCH_DLG_HEIGHT,
*search_text, SEARCH_DLG_WIDTH - 6, 0, MC_HISTORY_SHARED_SEARCH, search_text),
/* 9 */ QUICK_LABEL (2, SEARCH_DLG_WIDTH, 2, SEARCH_DLG_HEIGHT, N_(" Enter search string:")),
QUICK_END
};
{quick_checkbox, 33, SEARCH_DLG_WIDTH, 8, SEARCH_DLG_HEIGHT, N_("&Whole words"), 0, 0,
&twhole_words, 0, NULL, NULL, NULL},
QuickDialog Quick_input =
{
SEARCH_DLG_WIDTH, SEARCH_DLG_HEIGHT, -1, -1, N_("Search"),
"[Input Line Keys]", quick_widgets, FALSE
};
{quick_checkbox, 33, SEARCH_DLG_WIDTH, 7, SEARCH_DLG_HEIGHT, N_("In se&lection"), 0, 0,
&tonly_in_selection, 0, NULL, NULL, NULL},
{quick_checkbox, 33, SEARCH_DLG_WIDTH, 6, SEARCH_DLG_HEIGHT, N_("&Backwards"), 0, 0,
&tsearch_backwards, 0, NULL, NULL, NULL},
{quick_checkbox, 33, SEARCH_DLG_WIDTH, 5, SEARCH_DLG_HEIGHT, N_("case &Sensitive"), 0, 0,
&tsearch_case, 0, NULL, NULL, NULL},
{quick_radio, 3, SEARCH_DLG_WIDTH, 5, SEARCH_DLG_HEIGHT, 0, g_strv_length (list_of_types), ttype_of_search,
(void *) &ttype_of_search, const_cast (char **, list_of_types), NULL, NULL, NULL},
{quick_input, 3, SEARCH_DLG_WIDTH, 3, SEARCH_DLG_HEIGHT, *search_text, 52, 0, 0,
search_text, MC_HISTORY_SHARED_SEARCH, NULL, NULL},
{quick_label, 2, SEARCH_DLG_WIDTH, 2, SEARCH_DLG_HEIGHT, N_(" Enter search string:"), 0, 0,
0, 0, 0, NULL, NULL},
NULL_QuickWidget
};
QuickDialog Quick_input = { SEARCH_DLG_WIDTH, SEARCH_DLG_HEIGHT, -1, 0, N_("Search"),
"[Input Line Keys]", quick_widgets, 0
};
if (quick_dialog (&Quick_input) != B_CANCEL) {
edit->search_type = ttype_of_search;
edit->replace_backwards = tsearch_backwards;
edit->only_in_selection = tonly_in_selection;
edit->all_codepages = tall_codepages;
edit->whole_words = twhole_words;
edit->replace_case = tsearch_case;
} else {
*search_text = NULL;
if (quick_dialog (&Quick_input) == B_CANCEL)
*search_text = NULL;
}
}
@ -267,8 +192,7 @@ editcmd_dialog_raw_key_query (const char *heading, const char *query, int cancel
add_widget (raw_dlg, label_new (3 - cancel, 2, query));
if (cancel)
add_widget (raw_dlg, button_new (4, w / 2 - 5, B_CANCEL, NORMAL_BUTTON, _("Cancel"), 0));
run_dlg (raw_dlg);
w = raw_dlg->ret_value;
w = run_dlg (raw_dlg);
destroy_dlg (raw_dlg);
if (cancel) {
if (w == XCTRL ('g') || w == XCTRL ('c') || w == ESC_CHAR || w == B_CANCEL)
@ -329,11 +253,8 @@ editcmd_dialog_completion_show (WEdit * edit, int max_len, int word_len,
for (i = 0; i < num_compl; i++)
listbox_add_item (compl_list, LISTBOX_APPEND_AT_END, 0, (char *) compl[i].text, NULL);
/* pop up the dialog */
run_dlg (compl_dlg);
/* apply the choosen completion */
if (compl_dlg->ret_value == B_ENTER) {
/* pop up the dialog and apply the choosen completion */
if (run_dlg (compl_dlg) == B_ENTER) {
listbox_get_current (compl_list, &curr, NULL);
if (curr)
for (curr += word_len; *curr; curr++)
@ -470,27 +391,21 @@ editcmd_dialog_replace_prompt_show (WEdit * edit, char *from_text, char *to_text
char *repl_from, *repl_to;
char tmp [BUF_MEDIUM];
QuickWidget quick_widgets[] = {
{quick_button, 44, dlg_width, 6, dlg_height, N_("&Cancel"),
0, B_CANCEL, 0, 0, NULL, NULL, NULL},
{quick_button, 29, dlg_width, 6, dlg_height, N_("&Skip"),
0, B_SKIP_REPLACE, 0, 0, NULL, NULL, NULL},
{quick_button, 21, dlg_width, 6, dlg_height, N_("A&ll"),
0, B_REPLACE_ALL, 0, 0, NULL, NULL, NULL},
{quick_button, 4, dlg_width, 6, dlg_height, N_("&Replace"),
0, B_ENTER, 0, 0, NULL, NULL, NULL},
{quick_label, 3, dlg_width, 2, dlg_height, 0,
0, 0, 0, 0, 0, NULL, NULL},
{quick_label, 2, dlg_width, 3, dlg_height, 0,
0, 0, 0, 0, 0, NULL, NULL},
{quick_label, 3, dlg_width, 4, dlg_height, 0,
0, 0, 0, 0, 0, NULL, NULL},
NULL_QuickWidget
QuickWidget quick_widgets[] =
{
/* 0 */ QUICK_BUTTON (44, dlg_width, 6, dlg_height, N_("&Cancel"), B_CANCEL, NULL),
/* 1 */ QUICK_BUTTON (29, dlg_width, 6, dlg_height, N_("&Skip"), B_SKIP_REPLACE, NULL),
/* 2 */ QUICK_BUTTON (21, dlg_width, 6, dlg_height, N_("A&ll"), B_REPLACE_ALL, NULL),
/* 3 */ QUICK_BUTTON ( 4, dlg_width, 6, dlg_height, N_("&Replace"), B_ENTER, NULL),
/* 4 */ QUICK_LABEL ( 3, dlg_width, 2, dlg_height, NULL),
/* 5 */ QUICK_LABEL ( 2, dlg_width, 3, dlg_height, N_(" Replace with: ")),
/* 6 */ QUICK_LABEL ( 3, dlg_width, 4, dlg_height, NULL),
QUICK_END
};
#ifdef ENABLE_NLS
for (i = 0; i < 4; i++)
quick_widgets[i].text = _(quick_widgets[i].text);
quick_widgets[i].u.button.text = _(quick_widgets[i].u.button.text);
#endif
/* calculate button positions */
@ -498,9 +413,7 @@ editcmd_dialog_replace_prompt_show (WEdit * edit, char *from_text, char *to_text
for (i = 3; i > -1; i--) {
quick_widgets[i].relative_x = btn_pos;
btn_pos += str_term_width1 (quick_widgets[i].text) + 5;
btn_pos += str_term_width1 (quick_widgets[i].u.button.text) + 5;
if (i == 3) /* default button */
btn_pos += 2;
}
@ -517,9 +430,8 @@ editcmd_dialog_replace_prompt_show (WEdit * edit, char *from_text, char *to_text
g_snprintf (tmp, sizeof (tmp), " '%s'", to_text);
repl_to = g_strdup (str_fit_to_term (tmp, dlg_width - 7, J_LEFT));
quick_widgets[4].text = repl_from;
quick_widgets[5].text = _(" Replace with: ");
quick_widgets[6].text = repl_to;
quick_widgets[4].u.label.text = repl_from;
quick_widgets[6].u.label.text = repl_to;
if (xpos == -1)
xpos = (edit->num_widget_columns - dlg_width) / 2;
@ -529,22 +441,22 @@ editcmd_dialog_replace_prompt_show (WEdit * edit, char *from_text, char *to_text
{
QuickDialog Quick_input =
{dlg_width, dlg_height, 0, 0, N_ (" Confirm replace "),
"[Input Line Keys]", 0 /*quick_widgets */, 0 };
Quick_input.widgets = quick_widgets;
Quick_input.xpos = xpos;
{
dlg_width, dlg_height, 0, 0, N_ (" Confirm replace "),
"[Input Line Keys]", quick_widgets, FALSE
};
/* Sometimes menu can hide replaced text. I don't like it */
if ((edit->curs_row >= ypos - 1) && (edit->curs_row <= ypos + dlg_height - 1))
ypos -= dlg_height;
Quick_input.ypos = ypos;
Quick_input.xpos = xpos;
retval = quick_dialog (&Quick_input);
g_free (repl_from);
g_free (repl_to);
return retval;
}
}

View File

@ -42,15 +42,25 @@
#define OPT_DLG_W 72
static const char *key_emu_str[] =
{N_("Intuitive"), N_("Emacs"), N_("User-defined"), NULL};
{
N_("Intuitive"),
N_("Emacs"),
N_("User-defined"),
NULL
};
static const char *wrap_str[] =
{N_("None"), N_("Dynamic paragraphing"), N_("Type writer wrap"), NULL};
{
N_("None"),
N_("Dynamic paragraphing"),
N_("Type writer wrap"),
NULL
};
static void
i18n_translate_array (const char *array[])
{
while (*array!=NULL) {
while (*array != NULL) {
*array = _(*array);
array++;
}
@ -59,121 +69,71 @@ i18n_translate_array (const char *array[])
void
edit_options_dialog (void)
{
char wrap_length[32], tab_spacing[32], *p, *q;
char wrap_length[16], tab_spacing[16], *p, *q;
int wrap_mode = 0;
int old_syntax_hl;
int tedit_key_emulation = edit_key_emulation;
int toption_fill_tabs_with_spaces = option_fill_tabs_with_spaces;
int toption_save_position = option_save_position;
int tedit_confirm_save = edit_confirm_save;
int tedit_syntax_highlighting = option_syntax_highlighting;
int tedit_visible_tabs = visible_tabs;
int tedit_visible_tws = visible_tws;
int tedit_persistent_selections = option_persistent_selections;
int tedit_cursor_beyond_eol = option_cursor_beyond_eol;
int toption_return_does_auto_indent = option_return_does_auto_indent;
int toption_backspace_through_tabs = option_backspace_through_tabs;
int toption_fake_half_tabs = option_fake_half_tabs;
static int i18n_flag = 0;
QuickWidget quick_widgets[] = {
/* 0 */
{quick_button, 6, 10, OPT_DLG_H - 3, OPT_DLG_H, N_("&Cancel"), 0,
B_CANCEL, 0, 0, NULL, NULL, NULL},
/* 1 */
{quick_button, 2, 10, OPT_DLG_H - 3, OPT_DLG_H, N_("&OK"), 0,
B_ENTER, 0, 0, NULL, NULL, NULL},
/* 2 */
{quick_label, OPT_DLG_W / 2, OPT_DLG_W, OPT_DLG_H - 5, OPT_DLG_H,
N_("Word wrap line length: "), 0, 0, 0, 0, NULL, NULL, NULL},
/* 3 */
{quick_input, OPT_DLG_W / 2 + 24, OPT_DLG_W, OPT_DLG_H - 5,
OPT_DLG_H, "", OPT_DLG_W / 2 - 4 - 24, 0, 0, 0, "edit-word-wrap", NULL, NULL},
/* 4 */
{quick_label, OPT_DLG_W / 2, OPT_DLG_W, OPT_DLG_H - 6, OPT_DLG_H,
N_("Tab spacing: "), 0, 0, 0, 0, NULL, NULL, NULL},
/* 5 */
{quick_input, OPT_DLG_W / 2 + 24, OPT_DLG_W, OPT_DLG_H - 6,
OPT_DLG_H, "", OPT_DLG_W / 2 - 4 - 24, 0, 0, 0,
"edit-tab-spacing", NULL, NULL},
/* 6 */
{quick_checkbox, OPT_DLG_W / 2 + 1, OPT_DLG_W, OPT_DLG_H - 8,
OPT_DLG_H, N_("Cursor beyond end of line"), 8, 0, 0, 0, NULL, NULL, NULL},
/* 7 */
{quick_checkbox, OPT_DLG_W / 2 + 1, OPT_DLG_W, OPT_DLG_H - 9,
OPT_DLG_H, N_("Pers&istent selection"), 8, 0, 0, 0, NULL, NULL, NULL},
/* 8 */
{quick_checkbox, OPT_DLG_W / 2 + 1, OPT_DLG_W, OPT_DLG_H - 10,
OPT_DLG_H, N_("Synta&x highlighting"), 8, 0, 0, 0, NULL, NULL, NULL},
/* 9 */
{quick_checkbox, OPT_DLG_W / 2 + 1, OPT_DLG_W, OPT_DLG_H - 11,
OPT_DLG_H, N_("Visible tabs"), 8, 0, 0, 0, NULL, NULL, NULL},
/* 10 */
{quick_checkbox, OPT_DLG_W / 2 + 1, OPT_DLG_W, OPT_DLG_H - 12,
OPT_DLG_H, N_("Visible trailing spaces"), 8, 0, 0, 0, NULL, NULL, NULL},
/* 11 */
{quick_checkbox, OPT_DLG_W / 2 + 1, OPT_DLG_W, OPT_DLG_H - 13,
OPT_DLG_H, N_("Save file &position"), 0, 0, 0, 0, NULL, NULL, NULL},
/* 12 */
{quick_checkbox, OPT_DLG_W / 2 + 1, OPT_DLG_W, OPT_DLG_H - 14,
OPT_DLG_H, N_("Confir&m before saving"), 6, 0, 0, 0, NULL, NULL, NULL},
/* 13 */
{quick_checkbox, OPT_DLG_W / 2 + 1, OPT_DLG_W, OPT_DLG_H - 15,
OPT_DLG_H, N_("Fill tabs with &spaces"), 0, 0, 0, 0, NULL, NULL, NULL},
/* 14 */
{quick_checkbox, OPT_DLG_W / 2 + 1, OPT_DLG_W, OPT_DLG_H - 16,
OPT_DLG_H, N_("&Return does autoindent"), 0, 0, 0, 0, NULL, NULL, NULL},
/* 15 */
{quick_checkbox, OPT_DLG_W / 2 + 1, OPT_DLG_W, OPT_DLG_H - 17,
OPT_DLG_H, N_("&Backspace through tabs"), 0, 0, 0, 0, NULL, NULL, NULL},
/* 16 */
{quick_checkbox, OPT_DLG_W / 2 + 1, OPT_DLG_W, OPT_DLG_H - 18,
OPT_DLG_H, N_("&Fake half tabs"), 0, 0, 0, 0, NULL, NULL, NULL},
/* 17 */
{quick_radio, 5, OPT_DLG_W, OPT_DLG_H - 11, OPT_DLG_H, "", 3, 0, 0,
const_cast(char **, wrap_str), "wrapm", NULL, NULL},
/* 18 */
{quick_label, 4, OPT_DLG_W, OPT_DLG_H - 12, OPT_DLG_H,
N_("Wrap mode"), 0, 0, 0, 0, NULL, NULL, NULL},
/* 19 */
{quick_radio, 5, OPT_DLG_W, OPT_DLG_H - 17, OPT_DLG_H, "", 3, 0, 0,
const_cast(char **, key_emu_str), "keyemu", NULL, NULL},
/* 20 */
{quick_label, 4, OPT_DLG_W, OPT_DLG_H - 18, OPT_DLG_H,
N_("Key emulation"), 0, 0, 0, 0, NULL, NULL, NULL},
NULL_QuickWidget
QuickWidget quick_widgets[] =
{
/* 0 */ QUICK_BUTTON (6, 10, OPT_DLG_H - 3, OPT_DLG_H, N_("&Cancel"), B_CANCEL, NULL),
/* 1 */ QUICK_BUTTON (2, 10, OPT_DLG_H - 3, OPT_DLG_H, N_("&OK"), B_ENTER, NULL),
/* 2 */ QUICK_LABEL (OPT_DLG_W / 2, OPT_DLG_W, OPT_DLG_H - 6, OPT_DLG_H, N_("Word wrap line length: ")),
/* 3 */ QUICK_INPUT (OPT_DLG_W / 2 + 24, OPT_DLG_W, OPT_DLG_H - 6, OPT_DLG_H,
wrap_length, OPT_DLG_W / 2 - 4 - 24, 0, "edit-word-wrap", &p),
/* 4 */ QUICK_LABEL (OPT_DLG_W / 2, OPT_DLG_W, OPT_DLG_H - 7, OPT_DLG_H, N_("Tab spacing: ")),
/* 5 */ QUICK_INPUT (OPT_DLG_W / 2 + 24, OPT_DLG_W, OPT_DLG_H - 7, OPT_DLG_H,
tab_spacing, OPT_DLG_W / 2 - 4 - 24, 0, "edit-tab-spacing", &q),
/* 6 */ QUICK_CHECKBOX (OPT_DLG_W / 2 + 1, OPT_DLG_W, OPT_DLG_H - 8, OPT_DLG_H,
N_("Cursor beyond end of line"), &option_cursor_beyond_eol),
/* 7 */ QUICK_CHECKBOX (OPT_DLG_W / 2 + 1, OPT_DLG_W, OPT_DLG_H - 9, OPT_DLG_H,
N_("Pers&istent selection"), &option_persistent_selections),
/* 8 */ QUICK_CHECKBOX (OPT_DLG_W / 2 + 1, OPT_DLG_W, OPT_DLG_H - 10, OPT_DLG_H,
N_("Synta&x highlighting"), &option_syntax_highlighting),
/* 9 */ QUICK_CHECKBOX (OPT_DLG_W / 2 + 1, OPT_DLG_W, OPT_DLG_H - 11, OPT_DLG_H,
N_("Visible tabs"), &visible_tabs),
/* 10 */ QUICK_CHECKBOX (OPT_DLG_W / 2 + 1, OPT_DLG_W, OPT_DLG_H - 12, OPT_DLG_H,
N_("Visible trailing spaces"), &visible_tws),
/* 11 */ QUICK_CHECKBOX (OPT_DLG_W / 2 + 1, OPT_DLG_W, OPT_DLG_H - 13, OPT_DLG_H,
N_("Save file &position"), &option_save_position),
/* 12 */ QUICK_CHECKBOX (OPT_DLG_W / 2 + 1, OPT_DLG_W, OPT_DLG_H - 14, OPT_DLG_H,
N_("Confir&m before saving"), &edit_confirm_save),
/* 13 */ QUICK_CHECKBOX (OPT_DLG_W / 2 + 1, OPT_DLG_W, OPT_DLG_H - 15, OPT_DLG_H,
N_("Fill tabs with &spaces"), &option_fill_tabs_with_spaces),
/* 14 */ QUICK_CHECKBOX (OPT_DLG_W / 2 + 1, OPT_DLG_W, OPT_DLG_H - 16, OPT_DLG_H,
N_("&Return does autoindent"), &option_return_does_auto_indent),
/* 15 */ QUICK_CHECKBOX (OPT_DLG_W / 2 + 1, OPT_DLG_W, OPT_DLG_H - 17, OPT_DLG_H,
N_("&Backspace through tabs"), &option_backspace_through_tabs),
/* 16 */ QUICK_CHECKBOX (OPT_DLG_W / 2 + 1, OPT_DLG_W, OPT_DLG_H - 18, OPT_DLG_H,
N_("&Fake half tabs"), &option_fake_half_tabs),
/* 17 */ QUICK_RADIO (5, OPT_DLG_W, OPT_DLG_H - 11, OPT_DLG_H, 3, wrap_str, &wrap_mode),
/* 18 */ QUICK_LABEL (4, OPT_DLG_W, OPT_DLG_H - 12, OPT_DLG_H, N_("Wrap mode")),
/* 19 */ QUICK_RADIO (5, OPT_DLG_W, OPT_DLG_H - 17, OPT_DLG_H, 3, key_emu_str, &tedit_key_emulation),
/* 10 */ QUICK_LABEL (4, OPT_DLG_W, OPT_DLG_H - 18, OPT_DLG_H, N_("Key emulation")),
QUICK_END
};
QuickDialog Quick_options =
{ OPT_DLG_W, OPT_DLG_H, -1, 0, N_(" Editor options "), "", 0, 0 };
{
OPT_DLG_W, OPT_DLG_H, -1, -1, N_(" Editor options "),
"[Editor options]", quick_widgets, FALSE
};
#ifdef ENABLE_NLS
static gboolean i18n_flag = FALSE;
if (!i18n_flag) {
i18n_translate_array (key_emu_str);
i18n_translate_array (wrap_str);
i18n_flag = 1;
i18n_flag = TRUE;
}
#endif
g_snprintf (wrap_length, sizeof (wrap_length), "%d",
option_word_wrap_line_length);
g_snprintf (tab_spacing, sizeof (tab_spacing), "%d",
option_tab_spacing);
quick_widgets[3].text = wrap_length;
quick_widgets[3].str_result = &p;
quick_widgets[5].text = tab_spacing;
quick_widgets[5].str_result = &q;
quick_widgets[6].result = &tedit_cursor_beyond_eol;
quick_widgets[7].result = &tedit_persistent_selections;
quick_widgets[8].result = &tedit_syntax_highlighting;
quick_widgets[9].result = &tedit_visible_tabs;
quick_widgets[10].result = &tedit_visible_tws;
quick_widgets[11].result = &toption_save_position;
quick_widgets[12].result = &tedit_confirm_save;
quick_widgets[13].result = &toption_fill_tabs_with_spaces;
quick_widgets[14].result = &toption_return_does_auto_indent;
quick_widgets[15].result = &toption_backspace_through_tabs;
quick_widgets[16].result = &toption_fake_half_tabs;
if (option_auto_para_formatting)
wrap_mode = 1;
else if (option_typewriter_wrap)
@ -181,14 +141,6 @@ edit_options_dialog (void)
else
wrap_mode = 0;
quick_widgets[17].result = &wrap_mode;
quick_widgets[17].value = wrap_mode;
quick_widgets[19].result = &tedit_key_emulation;
quick_widgets[19].value = tedit_key_emulation;
Quick_options.widgets = quick_widgets;
if (quick_dialog (&Quick_options) == B_CANCEL)
return;
@ -205,18 +157,6 @@ edit_options_dialog (void)
g_free (q);
}
option_cursor_beyond_eol = tedit_cursor_beyond_eol;
option_persistent_selections = tedit_persistent_selections;
option_syntax_highlighting = tedit_syntax_highlighting;
visible_tabs = tedit_visible_tabs;
visible_tws = tedit_visible_tws;
edit_confirm_save = tedit_confirm_save;
option_save_position = toption_save_position;
option_fill_tabs_with_spaces = toption_fill_tabs_with_spaces;
option_return_does_auto_indent = toption_return_does_auto_indent;
option_backspace_through_tabs = toption_backspace_through_tabs;
option_fake_half_tabs = toption_fake_half_tabs;
if (wrap_mode == 1) {
option_auto_para_formatting = 1;
option_typewriter_wrap = 0;

View File

@ -143,7 +143,7 @@ display_init (int radio_sel, char *init_text, int _check_status,
char **_status)
{
static const char *display_title = N_("Listing mode");
static int i18n_displays_flag;
static gboolean i18n_displays_flag = FALSE;
const char *user_mini_status = _("user &Mini status");
const char *ok_button = _("&OK");
const char *cancel_button = _("&Cancel");
@ -158,27 +158,16 @@ display_init (int radio_sel, char *init_text, int _check_status,
display_title = _(display_title);
for (i = 0; i < LIST_TYPES; i++) {
#ifdef ENABLE_NLS
displays[i] = _(displays[i]);
if ((l = str_term_width1 (displays[i])) > maxlen)
maxlen = l;
#endif
maxlen = max (maxlen, str_term_width1 (displays[i]));
}
i = str_term_width1 (ok_button) + 5;
l = str_term_width1 (cancel_button) + 3;
l = max (i, l);
i = maxlen + l + 16;
if (i > DISPLAY_X)
DISPLAY_X = i;
i = str_term_width1 (user_mini_status) + 13;
if (i > DISPLAY_X)
DISPLAY_X = i;
i = str_term_width1 (display_title) + 10;
if (i > DISPLAY_X)
DISPLAY_X = i;
l = max (str_term_width1 (ok_button) + 5, str_term_width1 (cancel_button) + 3);
DISPLAY_X = max (DISPLAY_X, maxlen + l + 16);
DISPLAY_X = max (DISPLAY_X, str_term_width1 (user_mini_status) + 13);
DISPLAY_X = max (DISPLAY_X, str_term_width1 (display_title) + 10);
button_start = DISPLAY_X - l - 5;
/* get hotkey of user-defined format string */
@ -186,8 +175,9 @@ display_init (int radio_sel, char *init_text, int _check_status,
if (cp != NULL && *++cp != '\0')
user_hotkey = g_ascii_tolower ((gchar) cp[0]);
i18n_displays_flag = 1;
i18n_displays_flag = TRUE;
}
dd = create_dlg (0, 0, DISPLAY_Y, DISPLAY_X, dialog_colors,
display_callback, "[Listing Mode...]", display_title,
DLG_CENTER | DLG_REVERSE);
@ -278,8 +268,8 @@ static const char *sort_orders_names [SORT_TYPES];
sortfn *
sort_box (sortfn *sort_fn, int *reverse, int *case_sensitive, int *exec_first)
{
int i, r, l;
sortfn *result;
int i;
sortfn *result = NULL;
WCheck *c, *case_sense, *exec_ff;
const char *ok_button = _("&OK");
@ -293,41 +283,27 @@ sort_box (sortfn *sort_fn, int *reverse, int *case_sensitive, int *exec_first)
if (!i18n_sort_flag) {
int maxlen = 0;
int r, l;
for (i = SORT_TYPES - 1; i >= 0; i--) {
#ifdef ENABLE_NLS
sort_orders_names[i] = _(sort_orders[i].sort_name);
r = str_term_width1 (sort_orders_names[i]);
if (r > maxlen)
maxlen = r;
#endif
maxlen = max (maxlen, str_term_width1 (sort_orders_names[i]));
}
check_pos = maxlen + 9;
r = max (str_term_width1 (reverse_label), str_term_width1 (case_label)) + 4;
l = max (str_term_width1 (ok_button) + 2, str_term_width1 (cancel_button)) + 4;
r = str_term_width1 (reverse_label) + 4;
i = str_term_width1 (case_label) + 4;
if (i > r)
r = i;
l = str_term_width1 (ok_button) + 6;
i = str_term_width1 (cancel_button) + 4;
if (i > l)
l = i;
i = check_pos + max (r, l) + 2;
if (i > SORT_X)
SORT_X = i;
i = str_term_width1 (sort_title) + 6;
if (i > SORT_X)
SORT_X = i;
SORT_X = max (SORT_X, check_pos + max (r, l) + 2);
SORT_X = max (SORT_X, str_term_width1 (sort_title) + 6);
button_pos = SORT_X - l - 2;
i18n_sort_flag = 1;
}
result = 0;
for (i = 0; i < SORT_TYPES; i++)
if ((sortfn *) (sort_orders[i].sort_fn) == sort_fn) {
current_mode = i;
@ -356,184 +332,162 @@ sort_box (sortfn *sort_fn, int *reverse, int *case_sensitive, int *exec_first)
my_radio->sel = my_radio->pos = current_mode;
add_widget (dd, my_radio);
run_dlg (dd);
r = dd->ret_value;
if (r != B_CANCEL) {
if (run_dlg (dd) == B_CANCEL)
result = sort_fn;
else {
result = (sortfn *) sort_orders[my_radio->sel].sort_fn;
*reverse = c->state & C_BOOL;
*case_sensitive = case_sense->state & C_BOOL;
*exec_first = exec_ff->state & C_BOOL;
} else
result = sort_fn;
}
destroy_dlg (dd);
return result;
}
#define CONFY 11
#define CONFX 46
static int my_delete;
static int my_directory_hotlist_delete;
static int my_overwrite;
static int my_execute;
static int my_exit;
static QuickWidget conf_widgets [] = {
{ quick_button, 4, 6, 4, CONFY, N_("&Cancel"),
0, B_CANCEL, 0, 0, NULL , NULL, NULL},
{ quick_button, 4, 6, 3, CONFY, N_("&OK"),
0, B_ENTER, 0, 0, NULL , NULL, NULL},
{ quick_checkbox, 1, 13, 7, CONFY, N_(" confirm di&Rectory hotlist delete "),
11, 0, &my_directory_hotlist_delete, NULL, NULL , NULL, NULL},
{ quick_checkbox, 1, 13, 6, CONFY, N_(" confirm &Exit "),
9, 0, &my_exit, 0, NULL , NULL, NULL},
{ quick_checkbox, 1, 13, 5, CONFY, N_(" confirm e&Xecute "),
10, 0, &my_execute, 0, NULL , NULL, NULL},
{ quick_checkbox, 1, 13, 4, CONFY, N_(" confirm o&Verwrite "),
10, 0, &my_overwrite, 0, NULL , NULL, NULL},
{ quick_checkbox, 1, 13, 3, CONFY, N_(" confirm &Delete "),
9, 0, &my_delete, 0, NULL , NULL, NULL},
NULL_QuickWidget
};
static QuickDialog confirmation =
{ CONFX, CONFY, -1, -1, N_(" Confirmation "), "[Confirmation]",
conf_widgets, 0
};
void
confirm_box (void)
{
const int w_num = 7;
/* dialog sizes */
int dlg_width = 46;
int dlg_height = 12;
const char *title = _(" Confirmation ");
QuickWidget conf_widgets [] =
{
/* 0 */ QUICK_BUTTON (29, dlg_width, 9, dlg_height, N_("&Cancel"), B_CANCEL, NULL),
/* 1 */ QUICK_BUTTON (12, dlg_width, 9, dlg_height, N_("&OK"), B_ENTER, NULL),
/* 2 */ QUICK_CHECKBOX (3, dlg_width, 7, dlg_height, N_(" confirm di&Rectory hotlist delete "), &confirm_directory_hotlist_delete),
/* 3 */ QUICK_CHECKBOX (3, dlg_width, 6, dlg_height, N_(" confirm &Exit "), &confirm_exit),
/* 4 */ QUICK_CHECKBOX (3, dlg_width, 5, dlg_height, N_(" confirm e&Xecute "), &confirm_execute),
/* 5 */ QUICK_CHECKBOX (3, dlg_width, 4, dlg_height, N_(" confirm o&Verwrite "), &confirm_overwrite),
/* 6 */ QUICK_CHECKBOX (3, dlg_width, 3, dlg_height, N_(" confirm &Delete "), &confirm_delete),
QUICK_END
};
int i;
int maxlen = 0;
int cancel_len, ok_len, blen;
#ifdef ENABLE_NLS
static int i18n_flag = 0;
if (!i18n_flag)
{
register int i = sizeof(conf_widgets)/sizeof(QuickWidget) - 1;
int l1, maxlen = 0;
while (i--)
{
conf_widgets [i].text = _(conf_widgets [i].text);
l1 = str_term_width1 (conf_widgets [i].text) + 3;
if (l1 > maxlen)
maxlen = l1;
}
title = _(title);
/*
* If buttons start on 4/6, checkboxes (with some add'l space)
* must take not more than it.
*/
confirmation.xlen = (maxlen + 5) * 6 / 4;
/*
* And this for the case when buttons with some space to the right
* do not fit within 2/6
*/
l1 = str_term_width1 (conf_widgets [0].text) + 3;
i = str_term_width1 (conf_widgets [1].text) + 5;
if (i > l1)
l1 = i;
i = (l1 + 3) * 6 / 2;
if (i > confirmation.xlen)
confirmation.xlen = i;
confirmation.title = _(confirmation.title);
i18n_flag = confirmation.i18n = 1;
}
for (i = 0; i < 2; i++)
conf_widgets [i].u.button.text = _(conf_widgets [i].u.button.text);
for (i = 2; i < w_num; i++)
conf_widgets [i].u.checkbox.text = _(conf_widgets [i].u.checkbox.text);
#endif /* ENABLE_NLS */
my_delete = confirm_delete;
my_overwrite = confirm_overwrite;
my_execute = confirm_execute;
my_exit = confirm_exit;
my_directory_hotlist_delete = confirm_directory_hotlist_delete;
/* maximumr length of checkboxes */
for (i = 2; i < w_num; i++)
maxlen = max (maxlen, str_term_width1 (conf_widgets [i].u.checkbox.text) + 3);
if (quick_dialog (&confirmation) != B_CANCEL){
confirm_delete = my_delete;
confirm_overwrite = my_overwrite;
confirm_execute = my_execute;
confirm_exit = my_exit;
confirm_directory_hotlist_delete = my_directory_hotlist_delete;
/* length of buttons */
cancel_len = str_term_width1 (conf_widgets [0].u.button.text) + 2;
ok_len = str_term_width1 (conf_widgets [0].u.button.text) + 4; /* default button */
blen = cancel_len + ok_len + 2;
dlg_width = max (maxlen, blen) + 6;
dlg_width = max (dlg_width, str_term_width1 (title) + 4);
/* correct widget parameters */
for (i = 0; i < w_num; i++)
conf_widgets[i].x_divisions = dlg_width;
conf_widgets[0].relative_x = dlg_width * 2/3 - cancel_len/2;
conf_widgets[1].relative_x = dlg_width/3 - ok_len/2;
{
QuickDialog confirmation =
{
dlg_width, dlg_height, -1, -1, title,
"[Confirmation]", conf_widgets, 1
};
(void) quick_dialog (&confirmation);
}
}
#define DISPY 12
#define DISPX 46
#ifndef HAVE_CHARSET
static int new_mode;
static int new_meta;
static const char *display_bits_str [] =
{ N_("UTF-8 output"), N_("Full 8 bits output"), N_("ISO 8859-1"), N_("7 bits") };
static QuickWidget display_widgets [] = {
{ quick_button, DISPX/2+7, DISPX, 7, DISPY, N_("&Cancel"),
0, B_CANCEL, 0, 0, NULL , NULL, NULL},
{ quick_button, DISPX/2+7, DISPX, 8, DISPY, N_("&OK"),
0, B_ENTER, 0, 0, NULL , NULL, NULL},
{ quick_checkbox, 4, DISPX, 8, DISPY, N_("F&ull 8 bits input"),
0, 0, &new_meta, 0, NULL , NULL, NULL},
{ quick_radio, 4, DISPX, 3, DISPY, "", 4, 0,
&new_mode, const_cast(char **, display_bits_str), NULL , NULL, NULL},
NULL_QuickWidget
};
static QuickDialog display_bits =
{ DISPX, DISPY, -1, -1, N_(" Display bits "), "[Display bits]",
display_widgets, 0 };
void
display_bits_box (void)
display_bits_box (void) /* AB:FIXME: test dialog */
{
/* dialog sizes */
const int DISPY = 13;
const int DISPX = 46;
int new_meta = 0;
const char *display_bits_str [] =
{
N_("UTF-8 output"),
N_("Full 8 bits output"),
N_("ISO 8859-1"),
N_("7 bits")
};
QuickWidget display_widgets[] =
{
/* 0 */ QUICK_BUTTON (15, DISPX, DISPY - 3, DISPY, N_("&Cancel"), B_CANCEL, NULL),
/* 1 */ QUICK_BUTTON (29, DISPX, DISPY - 3, DISPY, N_("&OK"), B_ENTER, NULL),
/* 2 */ QUICK_CHECKBOX (3, DISPX, 8, DISPY, N_("F&ull 8 bits input"), &new_meta),
/* 3 */ QUICK_RADIO (3, DISPX, 3, DISPY, 4, display_bits_str, &current_mode),
QUICK_END
};
QuickDialog display_bits =
{
DISPX, DISPY, -1, -1, _(" Display bits "),
"[Display bits]", display_widgets, TRUE
};
int i;
int current_mode;
int l1, maxlen = 0;
int ok_len, cancel_len;
#ifdef ENABLE_NLS
static int i18n_flag = 0;
if (!i18n_flag)
{
register int i;
int l1, maxlen = 0;
for (i = 0; i < 3; i++)
{
display_widgets [i].text = _(display_widgets[i].text);
display_bits_str [i] = _(display_bits_str [i]);
l1 = str_term_width1 (display_bits_str [i]);
if (l1 > maxlen)
maxlen = l1;
}
l1 = str_term_width1 (display_widgets [2].text);
if (l1 > maxlen)
maxlen = l1;
static gboolean i18n_flag = FALSE;
display_bits.xlen = (maxlen + 5) * 6 / 4;
/* See above confirm_box */
l1 = str_term_width1 (display_widgets [0].text) + 3;
i = str_term_width1 (display_widgets [1].text) + 5;
if (i > l1)
l1 = i;
i = (l1 + 3) * 6 / 2;
if (i > display_bits.xlen)
display_bits.xlen = i;
display_bits.title = _(display_bits.title);
i18n_flag = display_bits.i18n = 1;
if (!i18n_flag) {
for (i = 0; i < 3; i++) {
display_bits_str[i] = _(display_bits_str [i]);
}
display_widgets[0].u.button.text = _(display_widgets[0].u.button.text);
display_widgets[1].u.button.text = _(display_widgets[1].u.button.text);
display_widgets[2].u.checkbox.text = _(display_widgets[2].u.checkbox.text);
i18n_flag = TRUE;
}
#endif /* ENABLE_NLS */
/* radiobuttons */
for (i = 0; i < 3; i++)
maxlen = max (maxlen, str_term_width1 (display_bits_str [i]));
/* buttons */
cancel_len = str_term_width1 (display_widgets [0].u.button.text) + 2;
ok_len = str_term_width1 (display_widgets [1].u.button.text) + 4; /* default button */
l1 = max (cancel_len, ok_len);
display_bits.xlen = max (maxlen, l1) + 20;
for (i = 0; i < 4; i++)
display_widgets[i].x_divisions = display_bits.xlen;
display_widgets[0].relative_x = display_bits.xlen * 2/3 - cancel_len/2;
display_widgets[1].relative_x = display_bits.xlen/3 - ok_len/2;
if (full_eight_bits)
current_mode = 0;
else if (eight_bit_clean)
@ -541,25 +495,22 @@ display_bits_box (void)
else
current_mode = 2;
display_widgets [3].value = current_mode;
new_meta = !use_8th_bit_as_meta;
if (quick_dialog (&display_bits) != B_ENTER)
return;
eight_bit_clean = new_mode < 3;
full_eight_bits = new_mode < 2;
#ifdef HAVE_SLANG
tty_display_8bit (full_eight_bits != 0);
if (quick_dialog (&display_bits) != B_CANCEL) {
eight_bit_clean = current_mode < 3;
full_eight_bits = current_mode < 2;
#ifndef HAVE_SLANG
meta (stdscr, eight_bit_clean);
#else
tty_display_8bit (eight_bit_clean != 0);
SLsmg_Display_Eight_Bit = full_eight_bits ? 128 : 160;
#endif
use_8th_bit_as_meta = !new_meta;
use_8th_bit_as_meta = !new_meta;
}
}
#else /* HAVE_CHARSET */
static int new_display_codepage;
static WLabel *cplabel;
@ -594,6 +545,10 @@ sel_charset_button (int action)
static Dlg_head *
init_disp_bits_box (void)
{
/* dialog sizes */
const int DISPY = 11;
const int DISPX = 46;
const char *cpname;
Dlg_head *dbits_dlg;
@ -625,7 +580,7 @@ init_disp_bits_box (void)
cpname = _("&Select");
add_widget (dbits_dlg,
button_new (4, DISPX - 8 - str_term_width1 (cpname), B_USER,
button_new (4, DISPX - 7 - str_term_width1 (cpname), B_USER,
NORMAL_BUTTON, cpname, sel_charset_button));
return dbits_dlg;
@ -690,7 +645,7 @@ tree_box (const char *current_dir)
{
WTree *mytree;
Dlg_head *dlg;
char *val;
char *val = NULL;
WButtonBar *bar;
(void) current_dir;
@ -703,191 +658,151 @@ tree_box (const char *current_dir)
add_widget (dlg, bar);
((Widget *) bar)->x = 0;
((Widget *) bar)->y = LINES - 1;
run_dlg (dlg);
if (dlg->ret_value == B_ENTER)
if (run_dlg (dlg) == B_ENTER)
val = g_strdup (tree_selected_name (mytree));
else
val = 0;
destroy_dlg (dlg);
return val;
}
#ifdef USE_VFS
#if defined(USE_NETCODE)
#define VFSY 17
#define VFS_WIDGETBASE 10
#else
#define VFSY 8
#define VFS_WIDGETBASE 0
#endif
#define VFSX 56
static char *ret_timeout;
#if defined(USE_NETCODE)
#ifdef USE_NETCODE
static char *ret_passwd;
static char *ret_directory_timeout;
static char *ret_ftp_proxy;
static int ret_use_netrc;
static int ret_ftpfs_use_passive_connections;
static int ret_ftpfs_use_passive_connections_over_proxy;
#endif
static QuickWidget confvfs_widgets [] = {
{ quick_button, 30, VFSX, VFSY - 3, VFSY, N_("&Cancel"),
0, B_CANCEL, 0, 0, NULL , NULL, NULL},
{ quick_button, 12, VFSX, VFSY - 3, VFSY, N_("&OK"),
0, B_ENTER, 0, 0, NULL , NULL, NULL},
#if defined(USE_NETCODE)
{ quick_checkbox, 4, VFSX, 12, VFSY, N_("Use passive mode over pro&xy"), 0, 0,
&ret_ftpfs_use_passive_connections_over_proxy, 0, NULL , NULL, NULL},
{ quick_checkbox, 4, VFSX, 11, VFSY, N_("Use &passive mode"), 0, 0,
&ret_ftpfs_use_passive_connections, 0, NULL , NULL, NULL},
{ quick_checkbox, 4, VFSX, 10, VFSY, N_("&Use ~/.netrc"), 0, 0,
&ret_use_netrc, 0, NULL , NULL, NULL},
{ quick_input, 4, VFSX, 9, VFSY, "", 48, 0, 0, &ret_ftp_proxy,
"input-ftp-proxy" , NULL, NULL},
{ quick_checkbox, 4, VFSX, 8, VFSY, N_("&Always use ftp proxy"), 0, 0,
&ftpfs_always_use_proxy, 0, NULL , NULL, NULL},
{ quick_label, 49, VFSX, 7, VFSY, N_("sec"),
0, 0, 0, 0, NULL , NULL, NULL},
{ quick_input, 38, VFSX, 7, VFSY, "", 10, 0, 0, &ret_directory_timeout,
"input-timeout" , NULL, NULL},
{ quick_label, 4, VFSX, 7, VFSY, N_("ftpfs directory cache timeout:"),
0, 0, 0, 0, NULL , NULL, NULL},
{ quick_input, 4, VFSX, 6, VFSY, "", 48, 0, 0, &ret_passwd,
"input-passwd" , NULL, NULL},
{ quick_label, 4, VFSX, 5, VFSY, N_("ftp anonymous password:"),
0, 0, 0, 0, NULL , NULL, NULL},
#endif
{ quick_label, 49, VFSX, 3, VFSY, "sec",
0, 0, 0, 0, NULL , NULL, NULL},
{ quick_input, 38, VFSX, 3, VFSY, "", 10, 0, 0, &ret_timeout,
"input-timo-vfs" , NULL, NULL},
{ quick_label, 4, VFSX, 3, VFSY, N_("Timeout for freeing VFSs:"),
0, 0, 0, 0, NULL , NULL, NULL},
NULL_QuickWidget
};
static QuickDialog confvfs_dlg =
{ VFSX, VFSY, -1, -1, N_(" Virtual File System Setting "),
"[Virtual FS]", confvfs_widgets, 0 };
void
configure_vfs (void)
{
char buffer2[BUF_TINY];
#if defined(USE_NETCODE)
char buffer3[BUF_TINY];
#define VFSX 56
ret_use_netrc = use_netrc;
ret_ftpfs_use_passive_connections = ftpfs_use_passive_connections;
ret_ftpfs_use_passive_connections_over_proxy = ftpfs_use_passive_connections_over_proxy;
g_snprintf(buffer3, sizeof (buffer3), "%i", ftpfs_directory_timeout);
confvfs_widgets[8].text = buffer3;
confvfs_widgets[10].text = ftpfs_anonymous_passwd;
confvfs_widgets[5].text = ftpfs_proxy_host;
#ifdef USE_NETCODE
#define VFSY 17
#else
#define VFSY 8
#endif
char buffer2 [BUF_TINY];
#ifdef USE_NETCODE
char buffer3 [BUF_TINY];
#endif
QuickWidget confvfs_widgets [] =
{
/* 0 */ QUICK_BUTTON (30, VFSX, VFSY - 3, VFSY, N_("&Cancel"), B_CANCEL, NULL),
/* 1 */ QUICK_BUTTON (12, VFSX, VFSY - 3, VFSY, N_("&OK"), B_ENTER, NULL),
#ifdef USE_NETCODE
/* 2 */ QUICK_CHECKBOX (4, VFSX, 12, VFSY, N_("Use passive mode over pro&xy"), &ftpfs_use_passive_connections_over_proxy),
/* 3 */ QUICK_CHECKBOX (4, VFSX, 11, VFSY, N_("Use &passive mode"), &ftpfs_use_passive_connections),
/* 4 */ QUICK_CHECKBOX (4, VFSX, 10, VFSY, N_("&Use ~/.netrc"), &use_netrc),
/* 5 */ QUICK_INPUT (4, VFSX, 9, VFSY, ftpfs_proxy_host, 48, 0, "input-ftp-proxy", &ret_ftp_proxy),
/* 6 */ QUICK_CHECKBOX (4, VFSX, 8, VFSY, N_("&Always use ftp proxy"), &ftpfs_always_use_proxy),
/* 7 */ QUICK_LABEL (49, VFSX, 7, VFSY, N_("sec")),
/* 8 */ QUICK_INPUT (38, VFSX, 7, VFSY, buffer3, 10, 0, "input-timeout", &ret_directory_timeout),
/* 9 */ QUICK_LABEL (4, VFSX, 7, VFSY, N_("ftpfs directory cache timeout:")),
/* 10 */ QUICK_INPUT (4, VFSX, 6, VFSY, ftpfs_anonymous_passwd, 48, 0, "input-passwd", &ret_passwd),
/* 11 */ QUICK_LABEL (4, VFSX, 5, VFSY, N_("ftp anonymous password:")),
#endif
/* 12 */ QUICK_LABEL (49, VFSX, 3, VFSY, N_("sec")),
/* 13 */ QUICK_INPUT (38, VFSX, 3, VFSY, buffer2, 10, 0, "input-timo-vfs", &ret_timeout),
/* 14 */ QUICK_LABEL (4, VFSX, 3, VFSY, N_("Timeout for freeing VFSs:")),
QUICK_END
};
QuickDialog confvfs_dlg =
{
VFSX, VFSY, -1, -1, N_(" Virtual File System Setting "),
"[Virtual FS]", confvfs_widgets, FALSE
};
#ifdef SE_NETCODE
g_snprintf (buffer3, sizeof (buffer3), "%i", ftpfs_directory_timeout);
#endif
g_snprintf (buffer2, sizeof (buffer2), "%i", vfs_timeout);
confvfs_widgets [3 + VFS_WIDGETBASE].text = buffer2;
if (quick_dialog (&confvfs_dlg) != B_CANCEL) {
vfs_timeout = atoi (ret_timeout);
g_free (ret_timeout);
if (vfs_timeout < 0 || vfs_timeout > 10000)
vfs_timeout = 10;
#if defined(USE_NETCODE)
#ifdef USE_NETCODE
g_free (ftpfs_anonymous_passwd);
ftpfs_anonymous_passwd = ret_passwd;
g_free (ftpfs_proxy_host);
ftpfs_proxy_host = ret_ftp_proxy;
ftpfs_directory_timeout = atoi(ret_directory_timeout);
use_netrc = ret_use_netrc;
ftpfs_use_passive_connections = ret_ftpfs_use_passive_connections;
ftpfs_use_passive_connections_over_proxy = ret_ftpfs_use_passive_connections_over_proxy;
g_free (ret_directory_timeout);
#endif
}
#undef VFSX
#undef VFSY
}
#endif /* USE_VFS */
#endif /* USE_VFS */
char *
cd_dialog (void)
{
QuickDialog Quick_input;
QuickWidget quick_widgets [] = {
{ quick_input, 6, 57, 2, 0, "", 50, 0, 0, 0, "input" , NULL, NULL},
{ quick_label, 3, 57, 2, 0, "", 0, 0, 0, 0, NULL , NULL, NULL},
NULL_QuickWidget
};
char *my_str;
const char *label = N_("cd");
const int ylen = 5;
const int xlen = 57;
int len;
Quick_input.xlen = 57;
Quick_input.title = _("Quick cd");
Quick_input.help = "[Quick cd]";
quick_widgets [0].value = 2; /* want cd like completion */
quick_widgets [1].text = _("cd");
quick_widgets [1].y_divisions =
quick_widgets [0].y_divisions = Quick_input.ylen = 5;
#ifdef ENABLE_NLS
label = _(label);
#endif
len = str_term_width1 (quick_widgets [1].text);
len = str_term_width1 (label);
quick_widgets [0].relative_x =
quick_widgets [1].relative_x + len + 1;
{
char *my_str;
Quick_input.xlen = len + quick_widgets [0].hotkey_pos + 7;
quick_widgets [0].x_divisions =
quick_widgets [1].x_divisions = Quick_input.xlen;
QuickWidget quick_widgets [] =
{
/* 0 */ QUICK_INPUT (4 + len, xlen, 2, ylen, "", xlen - 7 - len, 2, "input" , &my_str),
/* 1 */ QUICK_LABEL (3, xlen, 2, ylen, label),
QUICK_END
};
Quick_input.i18n = 1;
Quick_input.xpos = 2;
Quick_input.ypos = LINES - 2 - Quick_input.ylen;
quick_widgets [0].str_result = &my_str;
Quick_input.widgets = quick_widgets;
if (quick_dialog (&Quick_input) != B_CANCEL){
return my_str;
} else
return 0;
QuickDialog Quick_input =
{
xlen, ylen, 2, LINES - 2 - ylen, _("Quick cd"),
"[Quick cd]", quick_widgets, TRUE
};
return (quick_dialog (&Quick_input) != B_CANCEL) ? my_str : NULL;
}
}
void
symlink_dialog (const char *existing, const char *new, char **ret_existing,
char **ret_new)
{
QuickDialog Quick_input;
QuickWidget quick_widgets[] = {
{quick_button, 50, 80, 6, 8, N_("&Cancel"), 0, B_CANCEL, 0, 0,
NULL, NULL, NULL},
{quick_button, 16, 80, 6, 8, N_("&OK"), 0, B_ENTER, 0, 0, NULL, NULL, NULL},
{quick_input, 4, 80, 5, 8, "", 58, 0, 0, 0, "input-1", NULL, NULL},
{quick_label, 4, 80, 4, 8, N_("Symbolic link filename:"), 0, 0, 0,
0, NULL, NULL, NULL},
{quick_input, 4, 80, 3, 8, "", 58, 0, 0, 0, "input-2", NULL, NULL},
{quick_label, 4, 80, 2, 8,
N_("Existing filename (filename symlink will point to):"), 0, 0,
0, 0, NULL, NULL, NULL},
NULL_QuickWidget
QuickWidget quick_widgets[] =
{
/* 0 */ QUICK_BUTTON (50, 80, 6, 8, N_("&Cancel"), B_CANCEL, NULL),
/* 1 */ QUICK_BUTTON (16, 80, 6, 8, N_("&OK"), B_ENTER, NULL),
/* 2 */ QUICK_INPUT (4, 80, 5, 8, new, 58, 0, "input-1", ret_new),
/* 3 */ QUICK_LABEL (4, 80, 4, 8, N_("Symbolic link filename:")),
/* 4 */ QUICK_INPUT (4, 80, 3, 8, existing, 58, 0, "input-2", ret_existing),
/* 5 */ QUICK_LABEL (4, 80, 2, 8, N_("Existing filename (filename symlink will point to):")),
QUICK_END
};
Quick_input.xlen = 64;
Quick_input.ylen = 12;
Quick_input.title = N_("Symbolic link");
Quick_input.help = "[File Menu]";
Quick_input.i18n = 0;
quick_widgets[2].text = new;
quick_widgets[4].text = existing;
Quick_input.xpos = -1;
quick_widgets[2].str_result = ret_new;
quick_widgets[4].str_result = ret_existing;
QuickDialog Quick_input =
{
64, 12, -1, -1, N_("Symbolic link"),
"[File Menu]", quick_widgets, FALSE
};
Quick_input.widgets = quick_widgets;
if (quick_dialog (&Quick_input) == B_CANCEL) {
*ret_new = NULL;
*ret_existing = NULL;
@ -914,7 +829,7 @@ jobs_fill_listbox (void)
state_str [0] = _("Running ");
state_str [1] = _("Stopped");
}
while (tl){
char *s;
@ -924,7 +839,7 @@ jobs_fill_listbox (void)
tl = tl->next;
}
}
static int
task_cb (int action)
{

View File

@ -522,16 +522,19 @@ select_unselect_cmd (const char *title, const char *history_name, gboolean do_se
mc_search_t *search;
int i;
QuickWidget quick_widgets[] = {
{ quick_checkbox, 3, DX, DY - 3, DY, N_("&Using shell patterns"), 0, 0, &shell_patterns, NULL, NULL },
{ quick_checkbox, DX/2 + 1, DX, DY - 4, DY, N_("&Case sensitive"), 0, 0, &case_sens, NULL, NULL },
{ quick_checkbox, 3, DX, DY - 4, DY, N_("&Files only"), 0, 0, &files_only, NULL, NULL },
{ quick_input, 3, DX, DY - 5, DY, INPUT_LAST_TEXT, DX - 6, 0, NULL, &reg_exp, history_name },
NULL_QuickWidget
QuickWidget quick_widgets[] =
{
QUICK_CHECKBOX (3, DX, DY - 3, DY, N_("&Using shell patterns"), &shell_patterns),
QUICK_CHECKBOX (DX/2 + 1, DX, DY - 4, DY, N_("&Case sensitive"), &case_sens),
QUICK_CHECKBOX (3, DX, DY - 4, DY, N_("&Files only"), &files_only),
QUICK_INPUT (3, DX, DY - 5, DY, INPUT_LAST_TEXT, DX - 6, 0, history_name, &reg_exp),
QUICK_END
};
QuickDialog quick_dlg = {
DX, DY, -1, -1, title, "[Select/Unselect Files]", quick_widgets, 0
QuickDialog quick_dlg =
{
DX, DY, -1, -1, title,
"[Select/Unselect Files]", quick_widgets, FALSE
};
if (quick_dialog (&quick_dlg) == B_CANCEL)

View File

@ -1674,8 +1674,6 @@ panel_operate_generate_prompt (const WPanel *panel, const int operation,
#ifdef ENABLE_NLS
static int i18n_flag = 0;
if (!i18n_flag) {
fmd_init_i18n (FALSE); /* to get proper fmd_xlen */
for (i = sizeof (op_names1) / sizeof (op_names1[0]); i--;)
op_names1[i] = _(op_names1[i]);
@ -1741,7 +1739,6 @@ panel_operate_generate_prompt (const WPanel *panel, const int operation,
i = str_term_width1 (cmd_buf) + 6 - fmd_xlen;
if (i > 0) {
fmd_xlen += i;
fmd_init_i18n (TRUE); /* to recalculate positions of child widgets */
}
}
}

View File

@ -777,162 +777,125 @@ file_progress_real_query_replace (FileOpContext *ctx,
}
}
#define FMDY 13
#define FMD_XLEN 64
extern int fmd_xlen;
static QuickWidget fmd_widgets[] = {
#define FMCB0 FMDC
#define FMCB12 0
#define FMCB11 1
/* follow symlinks and preserve Attributes must be the first */
{quick_checkbox, 3, 64, 8, FMDY, N_("preserve &Attributes"), 9, 0,
0 /* &op_preserve */ , 0, NULL, NULL, NULL},
{quick_checkbox, 3, 64, 7, FMDY, N_("follow &Links"), 7, 0,
0 /* &file_mask_op_follow_links */ , 0, NULL, NULL, NULL},
{quick_label, 3, 64, 5, FMDY, N_("to:"), 0, 0, 0, 0, NULL, NULL, NULL},
{quick_checkbox, 37, 64, 4, FMDY, N_("&Using shell patterns"), 0, 0,
0 /* &source_easy_patterns */ , 0, NULL, NULL, NULL},
{quick_input, 3, 64, 3, FMDY, "", 58,
0, 0, 0, "input-def", NULL, NULL},
#define FMDI1 4
#define FMDI2 5
#define FMDC 3
{quick_input, 3, 64, 6, FMDY, "", 58, 0,
0, 0, "input2", NULL, NULL},
#define FMDI0 6
{quick_label, 3, 64, 2, FMDY, "", 0, 0, 0, 0, NULL, NULL, NULL},
#define FMBRGT 7
{quick_button, 42, 64, 9, FMDY, N_("&Cancel"), 0, B_CANCEL, 0, 0,
NULL, NULL, NULL},
#undef SKIP
#ifdef WITH_BACKGROUND
# define SKIP 5
# define FMCB21 11
# define FMCB22 10
# define FMBLFT 9
# define FMBMID 8
{quick_button, 25, 64, 9, FMDY, N_("&Background"), 0, B_USER, 0, 0,
NULL, NULL, NULL},
#else /* WITH_BACKGROUND */
# define SKIP 4
# define FMCB21 10
# define FMCB22 9
# define FMBLFT 8
# undef FMBMID
#endif
{quick_button, 14, 64, 9, FMDY, N_("&OK"), 0, B_ENTER, 0, 0, NULL, NULL, NULL},
{quick_checkbox, 42, 64, 8, FMDY, N_("&Stable Symlinks"), 0, 0,
0 /* &file_mask_stable_symlinks */ , 0, NULL, NULL, NULL},
{quick_checkbox, 31, 64, 7, FMDY, N_("&Dive into subdir if exists"), 0,
0, 0 /* &dive_into_subdirs */ , 0, NULL, NULL, NULL},
NULL_QuickWidget
};
static int
static gboolean
is_wildcarded (char *p)
{
for (; *p; p++) {
if (*p == '*')
return 1;
else if (*p == '\\' && p[1] >= '1' && p[1] <= '9')
return 1;
return TRUE;
if (*p == '\\' && p[1] >= '1' && p[1] <= '9')
return TRUE;
}
return 0;
}
void
fmd_init_i18n (int force)
{
#ifdef ENABLE_NLS
static int initialized = FALSE;
register int i;
int len;
if (initialized && !force)
return;
for (i = sizeof (op_names) / sizeof (op_names[0]); i--;)
op_names[i] = _(op_names[i]);
i = sizeof (fmd_widgets) / sizeof (fmd_widgets[0]) - 1;
while (i--)
if (fmd_widgets[i].text[0] != '\0')
fmd_widgets[i].text = _(fmd_widgets[i].text);
len = str_term_width1 (fmd_widgets[FMCB11].text)
+ str_term_width1 (fmd_widgets[FMCB21].text) + 15;
fmd_xlen = max (fmd_xlen, len);
len = str_term_width1 (fmd_widgets[FMCB12].text)
+ str_term_width1 (fmd_widgets[FMCB22].text) + 15;
fmd_xlen = max (fmd_xlen, len);
len = str_term_width1 (fmd_widgets[FMBRGT].text)
+ str_term_width1 (fmd_widgets[FMBLFT].text) + 11;
#ifdef FMBMID
len+= str_term_width1 (fmd_widgets[FMBMID].text) + 6;
#endif
fmd_xlen = max (fmd_xlen, len + 4);
len = (fmd_xlen - (len + 6)) / 2;
i = fmd_widgets[FMBLFT].relative_x = len + 3;
i+= str_term_width1 (fmd_widgets[FMBLFT].text) + 8;
#ifdef FMBMID
fmd_widgets[FMBMID].relative_x = i;
i+= str_term_width1 (fmd_widgets[FMBMID].text) + 6;
#endif
fmd_widgets[FMBRGT].relative_x = i;
#define chkbox_xpos(i) \
fmd_widgets [i].relative_x = fmd_xlen - str_term_width1 (fmd_widgets [i].text) - 6
chkbox_xpos (FMCB0);
chkbox_xpos (FMCB21);
chkbox_xpos (FMCB22);
if (fmd_xlen != FMD_XLEN) {
i = sizeof (fmd_widgets) / sizeof (fmd_widgets[0]) - 1;
while (i--)
fmd_widgets[i].x_divisions = fmd_xlen;
fmd_widgets[FMDI1].hotkey_pos =
fmd_widgets[FMDI2].hotkey_pos = fmd_xlen - 6;
}
#undef chkbox_xpos
initialized = TRUE;
#endif /* !ENABLE_NLS */
return FALSE;
}
char *
file_mask_dialog (FileOpContext *ctx, FileOperation operation, const char *text,
const char *def_text, int only_one, int *do_background)
{
const int FMDY = 13;
const int FMDX = 64;
int fmd_xlen = 0;
int source_easy_patterns = easy_patterns;
size_t i, len;
char *source_mask, *orig_mask, *dest_dir, *tmp;
char *def_text_secure;
struct stat buf;
int val;
QuickDialog Quick_input;
#ifdef ENABLE_NLS
static gboolean i18n = FALSE;
#endif /* !ENABLE_NLS */
QuickWidget fmd_widgets[] =
{
/* 0 */ QUICK_BUTTON (42, 64, 10, FMDY, N_("&Cancel"), B_CANCEL, NULL),
#ifdef WITH_BACKGROUND
/* 1 */ QUICK_BUTTON (25, 64, 10, FMDY, N_("&Background"), B_USER, NULL),
#define OFFSET 0
#else
#define OFFSET 1
#endif /* WITH_BACKGROUND */
/* 2 - OFFSET */ QUICK_BUTTON (14, FMDX, 10, FMDY, N_("&OK"), B_ENTER, NULL),
/* 3 - OFFSET */ QUICK_CHECKBOX (42, FMDX, 8, FMDY, N_("&Stable Symlinks"), &ctx->stable_symlinks),
/* 4 - OFFSET */ QUICK_CHECKBOX (31, FMDX, 7, FMDY, N_("&Dive into subdir if exists"), &ctx->dive_into_subdirs),
/* 5 - OFFSET */ QUICK_CHECKBOX (3, FMDX, 8, FMDY, N_("preserve &Attributes"), &ctx->op_preserve),
/* 6 - OFFSET */ QUICK_CHECKBOX (3, FMDX, 7, FMDY, N_("follow &Links"), &ctx->follow_links),
/* 7 - OFFSET */ QUICK_INPUT (3, FMDX, 6, FMDY, "", 58, 0, "input2", &dest_dir),
/* 8 - OFFSET */ QUICK_LABEL (3, FMDX, 5, FMDY, N_("to:")),
/* 9 - OFFSET */ QUICK_CHECKBOX (37, FMDX, 4, FMDY, N_("&Using shell patterns"), &source_easy_patterns),
/* 10 - OFFSET */ QUICK_INPUT (3, FMDX, 3, FMDY, easy_patterns ? "*" : "^\\(.*\\)$", 58, 0, "input-def", &source_mask),
/* 11 - OFFSET */ QUICK_LABEL (3, FMDX, 2, FMDY, text),
QUICK_END
};
g_return_val_if_fail (ctx != NULL, NULL);
fmd_init_i18n (FALSE);
#ifdef ENABLE_NLS
if (!i18n) {
for (i = sizeof (op_names) / sizeof (op_names[0]); i--;)
op_names[i] = _(op_names[i]);
i18n = TRUE;
}
/* buttons */
for (i = 0; i <= 2 - OFFSET; i++)
fmd_widgets[i].u.button.text = _(fmd_widgets[i].u.button.text);
/* checkboxes */
for (i = 3 - OFFSET; i <= 9 - OFFSET; i++)
if (i != 7 - OFFSET)
fmd_widgets[i].u.checkbox.text = _(fmd_widgets[i].u.checkbox.text);
#endif /* !ENABLE_NLS */
len = str_term_width1 (fmd_widgets[6 - OFFSET].u.checkbox.text)
+ str_term_width1 (fmd_widgets[4 - OFFSET].u.checkbox.text) + 15;
fmd_xlen = max (fmd_xlen, len);
len = str_term_width1 (fmd_widgets[5 - OFFSET].u.checkbox.text)
+ str_term_width1 (fmd_widgets[3 - OFFSET].u.checkbox.text) + 15;
fmd_xlen = max (fmd_xlen, len);
/* buttons */
len = str_term_width1 (fmd_widgets[2 - OFFSET].u.button.text)
+ str_term_width1 (fmd_widgets[0].u.button.text) + 11;
#ifdef WITH_BACKGROUND
len += str_term_width1 (fmd_widgets[1].u.button.text) + 6;
#endif
fmd_xlen = max (fmd_xlen, len + 4);
len = (fmd_xlen - (len + 6)) / 2;
i = len + 3;
fmd_widgets[2 - OFFSET].relative_x = i;
i += str_term_width1 (fmd_widgets[2 - OFFSET].u.button.text) + 8;
#ifdef WITH_BACKGROUND
fmd_widgets[1].relative_x = i;
i += str_term_width1 (fmd_widgets[1].u.button.text) + 6;
#endif
fmd_widgets[0].relative_x = i;
#define chkbox_xpos(i) \
fmd_widgets [i].relative_x = fmd_xlen - str_term_width1 (fmd_widgets [i].u.checkbox.text) - 6
chkbox_xpos (3 - OFFSET);
chkbox_xpos (4 - OFFSET);
chkbox_xpos (9 - OFFSET);
#undef chkbox_xpos
if (fmd_xlen != FMDX) {
i = sizeof (fmd_widgets) / sizeof (fmd_widgets[0]) - 1;
while (i--)
fmd_widgets[i].x_divisions = fmd_xlen;
/* inputs */
fmd_widgets[ 7 - OFFSET].u.input.len =
fmd_widgets[10 - OFFSET].u.input.len = fmd_xlen - 6;
}
/* unselect checkbox if target filesystem don't support attributes */
ctx->op_preserve = filegui__check_attrs_on_fs(def_text);
/* Set up the result pointers */
fmd_widgets[FMCB12].result = &ctx->op_preserve;
fmd_widgets[FMCB11].result = &ctx->follow_links;
fmd_widgets[FMCB22].result = &ctx->stable_symlinks;
fmd_widgets[FMCB21].result = &ctx->dive_into_subdirs;
ctx->op_preserve = filegui__check_attrs_on_fs (def_text);
/* filter out a possible password from def_text */
tmp = strip_password (g_strdup (def_text), 1);
@ -942,104 +905,101 @@ file_mask_dialog (FileOpContext *ctx, FileOperation operation, const char *text,
def_text_secure = strutils_regex_escape (tmp);
g_free (tmp);
/* Create the dialog */
/* destination */
fmd_widgets[7 - OFFSET].u.input.text = def_text_secure;
ctx->stable_symlinks = 0;
fmd_widgets[FMDC].result = &source_easy_patterns;
fmd_widgets[FMDI1].text = easy_patterns ? "*" : "^\\(.*\\)$";
Quick_input.xlen = fmd_xlen;
Quick_input.xpos = -1;
Quick_input.title = op_names[operation];
Quick_input.help = "[Mask Copy/Rename]";
Quick_input.ylen = FMDY;
Quick_input.i18n = 1;
Quick_input.widgets = fmd_widgets;
fmd_widgets[FMDI0].text = text;
fmd_widgets[FMDI2].text = def_text_secure;
fmd_widgets[FMDI2].str_result = &dest_dir;
fmd_widgets[FMDI1].str_result = &source_mask;
*do_background = 0;
ask_file_mask:
val = quick_dialog_skip (&Quick_input, SKIP);
{
struct stat buf;
if (val == B_CANCEL) {
g_free (def_text_secure);
return NULL;
}
QuickDialog Quick_input =
{
fmd_xlen, FMDY, -1, -1, op_names [operation],
"[Mask Copy/Rename]", fmd_widgets, TRUE
};
if (ctx->follow_links)
ctx->stat_func = mc_stat;
else
ctx->stat_func = mc_lstat;
ask_file_mask:
val = quick_dialog_skip (&Quick_input, 4);
if (ctx->op_preserve) {
ctx->preserve = 1;
ctx->umask_kill = 0777777;
ctx->preserve_uidgid = (geteuid () == 0) ? 1 : 0;
} else {
int i;
ctx->preserve = ctx->preserve_uidgid = 0;
i = umask (0);
umask (i);
ctx->umask_kill = i ^ 0777777;
}
if (val == B_CANCEL) {
g_free (def_text_secure);
return NULL;
}
if (ctx->follow_links)
ctx->stat_func = mc_stat;
else
ctx->stat_func = mc_lstat;
if (ctx->op_preserve) {
ctx->preserve = 1;
ctx->umask_kill = 0777777;
ctx->preserve_uidgid = (geteuid () == 0) ? 1 : 0;
} else {
int i;
ctx->preserve = ctx->preserve_uidgid = 0;
i = umask (0);
umask (i);
ctx->umask_kill = i ^ 0777777;
}
if (!dest_dir || !*dest_dir) {
g_free (def_text_secure);
g_free (source_mask);
return dest_dir;
}
ctx->search_handle = mc_search_new(source_mask,-1);
if (ctx->search_handle == NULL) {
message (D_ERROR, MSG_ERROR, _("Invalid source pattern `%s'"),
source_mask);
g_free (dest_dir);
g_free (source_mask);
goto ask_file_mask;
}
if (!dest_dir || !*dest_dir) {
g_free (def_text_secure);
g_free (source_mask);
return dest_dir;
ctx->search_handle->is_case_sentitive = TRUE;
if (source_easy_patterns)
ctx->search_handle->search_type = MC_SEARCH_T_GLOB;
else
ctx->search_handle->search_type = MC_SEARCH_T_REGEX;
tmp = dest_dir;
dest_dir = tilde_expand (tmp);
g_free (tmp);
ctx->dest_mask = strrchr (dest_dir, PATH_SEP);
if (ctx->dest_mask == NULL)
ctx->dest_mask = dest_dir;
else
ctx->dest_mask++;
orig_mask = ctx->dest_mask;
if (!*ctx->dest_mask
|| (!ctx->dive_into_subdirs && !is_wildcarded (ctx->dest_mask)
&& (!only_one
|| (!mc_stat (dest_dir, &buf) && S_ISDIR (buf.st_mode))))
|| (ctx->dive_into_subdirs
&& ((!only_one && !is_wildcarded (ctx->dest_mask))
|| (only_one && !mc_stat (dest_dir, &buf)
&& S_ISDIR (buf.st_mode)))))
ctx->dest_mask = g_strdup ("\\0");
else {
ctx->dest_mask = g_strdup (ctx->dest_mask);
*orig_mask = '\0';
}
if (!*dest_dir) {
g_free (dest_dir);
dest_dir = g_strdup ("./");
}
if (val == B_USER)
*do_background = 1;
}
ctx->search_handle = mc_search_new(source_mask,-1);
if (ctx->search_handle == NULL) {
message (D_ERROR, MSG_ERROR, _("Invalid source pattern `%s'"),
source_mask);
g_free (dest_dir);
g_free (source_mask);
goto ask_file_mask;
}
g_free (def_text_secure);
g_free (source_mask);
ctx->search_handle->is_case_sentitive = TRUE;
if (source_easy_patterns)
ctx->search_handle->search_type = MC_SEARCH_T_GLOB;
else
ctx->search_handle->search_type = MC_SEARCH_T_REGEX;
tmp = dest_dir;
dest_dir = tilde_expand (tmp);
g_free (tmp);
ctx->dest_mask = strrchr (dest_dir, PATH_SEP);
if (ctx->dest_mask == NULL)
ctx->dest_mask = dest_dir;
else
ctx->dest_mask++;
orig_mask = ctx->dest_mask;
if (!*ctx->dest_mask
|| (!ctx->dive_into_subdirs && !is_wildcarded (ctx->dest_mask)
&& (!only_one
|| (!mc_stat (dest_dir, &buf) && S_ISDIR (buf.st_mode))))
|| (ctx->dive_into_subdirs
&& ((!only_one && !is_wildcarded (ctx->dest_mask))
|| (only_one && !mc_stat (dest_dir, &buf)
&& S_ISDIR (buf.st_mode)))))
ctx->dest_mask = g_strdup ("\\0");
else {
ctx->dest_mask = g_strdup (ctx->dest_mask);
*orig_mask = '\0';
}
if (!*dest_dir) {
g_free (dest_dir);
dest_dir = g_strdup ("./");
}
if (val == B_USER)
*do_background = 1;
return dest_dir;
}

View File

@ -8,7 +8,6 @@
#include "fileopctx.h"
void fmd_init_i18n (int force);
char *file_mask_dialog (FileOpContext *ctx, FileOperation operation,
const char *text, const char *def_text, int only_one,
int *do_background);

View File

@ -839,22 +839,21 @@ add2hotlist (char *label, char *directory, enum HotListType type, int pos)
* internationalized label lengths and total buttonbar length...assume
* 64 is longer anyway.
*/
static void add_widgets_i18n(QuickWidget* qw, int len)
static void
add_widgets_i18n (QuickWidget* qw, int len)
{
int i, l[3], space, cur_x;
int i, l[3], space, cur_x;
for (i = 0; i < 3; i++)
{
qw [i].text = _(qw [i].text);
l[i] = str_term_width1 (qw [i].text) + 3;
}
space = (len - 4 - l[0] - l[1] - l[2]) / 4;
for (i = 0; i < 3; i++) {
qw [i].u.button.text = _(qw [i].u.button.text);
l[i] = str_term_width1 (qw [i].u.button.text) + 3;
}
space = (len - 4 - l[0] - l[1] - l[2]) / 4;
for (cur_x = 2 + space, i = 3; i--; cur_x += l[i] + space)
{
qw [i].relative_x = cur_x;
qw [i].x_divisions = len;
}
for (cur_x = 2 + space, i = 3; i--; cur_x += l[i] + space) {
qw [i].relative_x = cur_x;
qw [i].x_divisions = len;
}
}
#endif /* ENABLE_NLS */
@ -866,75 +865,63 @@ add_new_entry_input (const char *header, const char *text1, const char *text2,
#define RELATIVE_Y_LABEL_PTH 3
#define RELATIVE_Y_INPUT_PTH 4
QuickDialog Quick_input;
static QuickWidget quick_widgets [] = {
{ quick_button, 55, 80, RELATIVE_Y_BUTTONS, 0, N_("&Cancel"), 0, B_CANCEL,
0, 0, NULL , NULL, NULL},
{ quick_button, 30, 80, RELATIVE_Y_BUTTONS, 0, N_("&Insert"), 0, B_INSERT,
0, 0, NULL , NULL, NULL},
{ quick_button, 10, 80, RELATIVE_Y_BUTTONS, 0, N_("&Append"), 0, B_APPEND,
0, 0, NULL , NULL, NULL},
{ quick_input, 4, 80, RELATIVE_Y_INPUT_PTH, 0, "",58, 0,
0, 0, "input-pth" , NULL, NULL},
{ quick_label, RELATIVE_Y_LABEL_PTH, 80, 3, 0, 0, 0, 0,
0, 0, NULL , NULL, NULL},
{ quick_input, 4, 80, 3, 0, "", 58, 0,
0, 0, "input-lbl" , NULL, NULL},
{ quick_label, 3, 80, 2, 0, 0, 0, 0,
0, 0, NULL , NULL, NULL},
NULL_QuickWidget };
QuickWidget quick_widgets [] =
{
/* 0 */ QUICK_BUTTON (55, 80, RELATIVE_Y_BUTTONS, 0, N_("&Cancel"), B_CANCEL, NULL),
/* 1 */ QUICK_BUTTON (30, 80, RELATIVE_Y_BUTTONS, 0, N_("&Insert"), B_INSERT, NULL),
/* 2 */ QUICK_BUTTON (10, 80, RELATIVE_Y_BUTTONS, 0, N_("&Append"), B_APPEND, NULL),
/* 3 */ QUICK_INPUT (4, 80, RELATIVE_Y_INPUT_PTH, 0, *r2, 58, 0, "input-pth", r2),
/* 4 */ QUICK_LABEL (RELATIVE_Y_LABEL_PTH, 80, 3, 0, text2),
/* 5 */ QUICK_INPUT (4, 80, 3, 0, *r1, 58, 0, "input-lbl", r1),
/* 6 */ QUICK_LABEL (3, 80, 2, 0, text1),
QUICK_END
};
int len;
int i;
int lines1, lines2;
int cols1, cols2;
#ifdef ENABLE_NLS
static int i18n_flag = 0;
static gboolean i18n_flag = FALSE;
#endif /* ENABLE_NLS */
msglen(text1, &lines1, &cols1);
msglen(text2, &lines2, &cols2);
len = max (str_term_width1 (header), cols1);
len = max (len, cols2) + 4;
len = max (len, 64);
len = max (max (len, cols2) + 4, 64);
#ifdef ENABLE_NLS
if (!i18n_flag)
{
add_widgets_i18n(quick_widgets, len);
i18n_flag = 1;
}
if (!i18n_flag) {
add_widgets_i18n (quick_widgets, len);
i18n_flag = TRUE;
}
#endif /* ENABLE_NLS */
Quick_input.xlen = len;
Quick_input.xpos = -1;
Quick_input.title = header;
Quick_input.help = help;
Quick_input.i18n = 0;
quick_widgets [6].text = text1;
quick_widgets [4].text = text2;
quick_widgets [5].text = *r1;
quick_widgets [3].text = *r2;
{
QuickDialog Quick_input =
{
len, lines1 + lines2 + 7, -1, -1, header,
help, quick_widgets, FALSE
};
for (i = 0; i < 7; i++)
quick_widgets [i].y_divisions = lines1+lines2+7;
Quick_input.ylen = lines1 + lines2 + 7;
for (i = 0; i < 7; i++)
quick_widgets [i].y_divisions = Quick_input.ylen;
quick_widgets [0].relative_y = RELATIVE_Y_BUTTONS + (lines1 + lines2);
quick_widgets [1].relative_y = RELATIVE_Y_BUTTONS + (lines1 + lines2);
quick_widgets [2].relative_y = RELATIVE_Y_BUTTONS + (lines1 + lines2);
quick_widgets [3].relative_y = RELATIVE_Y_INPUT_PTH + (lines1);
quick_widgets [4].relative_y = RELATIVE_Y_LABEL_PTH + (lines1);
quick_widgets [0].relative_y = RELATIVE_Y_BUTTONS + (lines1 + lines2);
quick_widgets [1].relative_y = RELATIVE_Y_BUTTONS + (lines1 + lines2);
quick_widgets [2].relative_y = RELATIVE_Y_BUTTONS + (lines1 + lines2);
quick_widgets [3].relative_y = RELATIVE_Y_INPUT_PTH + (lines1);
quick_widgets [4].relative_y = RELATIVE_Y_LABEL_PTH + (lines1);
quick_widgets [5].str_result = r1;
quick_widgets [3].str_result = r2;
Quick_input.widgets = quick_widgets;
if ((i = quick_dialog (&Quick_input)) != B_CANCEL){
return i;
} else
return 0;
i = quick_dialog (&Quick_input);
}
return (i != B_CANCEL) ? i : 0;
#undef RELATIVE_Y_BUTTONS
#undef RELATIVE_Y_LABEL_PTH
#undef RELATIVE_Y_INPUT_PTH
}
static void add_new_entry_cmd (void)
@ -968,62 +955,55 @@ static void add_new_entry_cmd (void)
static int
add_new_group_input (const char *header, const char *label, char **result)
{
int ret;
QuickDialog Quick_input;
static QuickWidget quick_widgets [] = {
{ quick_button, 55, 80, 1, 0, N_("&Cancel"), 0, B_CANCEL, 0, 0,
NULL , NULL, NULL},
{ quick_button, 30, 80, 1, 0, N_("&Insert"), 0, B_INSERT, 0, 0,
NULL , NULL, NULL},
{ quick_button, 10, 80, 1, 0, N_("&Append"), 0, B_APPEND, 0, 0,
NULL , NULL, NULL},
{ quick_input, 4, 80, 0, 0, "", 58, 0, 0, 0, "input" , NULL, NULL},
{ quick_label, 3, 80, 2, 0, 0, 0, 0, 0, 0, NULL , NULL, NULL},
NULL_QuickWidget };
int relative_y[] = {1, 1, 1, 0, 2}; /* the relative_x component from the
quick_widgets variable above */
QuickWidget quick_widgets [] =
{
/* 0 */ QUICK_BUTTON (55, 80, 1, 0, N_("&Cancel"), B_CANCEL, NULL),
/* 1 */ QUICK_BUTTON (30, 80, 1, 0, N_("&Insert"), B_INSERT, NULL),
/* 2 */ QUICK_BUTTON (10, 80, 1, 0, N_("&Append"), B_APPEND, NULL),
/* 3 */ QUICK_INPUT (4, 80, 0, 0, "", 58, 0, "input" , result),
/* 4 */ QUICK_LABEL (3, 80, 2, 0, label),
QUICK_END
};
int len;
int i;
int lines, cols;
int ret;
#ifdef ENABLE_NLS
static int i18n_flag = 0;
static gboolean i18n_flag = FALSE;
#endif /* ENABLE_NLS */
msglen (label, &lines, &cols);
len = max (str_term_width1 (header), cols) + 4;
len = max (len, 64);
len = max (max (str_term_width1 (header), cols) + 4, 64);
#ifdef ENABLE_NLS
if (!i18n_flag)
{
add_widgets_i18n(quick_widgets, len);
i18n_flag = 1;
}
if (!i18n_flag) {
add_widgets_i18n (quick_widgets, len);
i18n_flag = TRUE;
}
#endif /* ENABLE_NLS */
Quick_input.xlen = len;
Quick_input.xpos = -1;
Quick_input.title = header;
Quick_input.help = "[Hotlist]";
Quick_input.i18n = 0;
quick_widgets [4].text = label;
{
QuickDialog Quick_input =
{
len, lines + 6, -1, -1, header,
"[Hotlist]", quick_widgets, FALSE
};
for (i = 0; i < 5; i++)
quick_widgets [i].y_divisions = lines+6;
Quick_input.ylen = lines + 6;
int relative_y[] = {1, 1, 1, 0, 2}; /* the relative_x component from the
quick_widgets variable above */
for (i = 0; i < 4; i++)
quick_widgets [i].relative_y = relative_y[i] + 2 + lines;
for (i = 0; i < 5; i++)
quick_widgets[i].y_divisions = Quick_input.ylen;
quick_widgets [3].str_result = result;
quick_widgets [3].text = "";
Quick_input.widgets = quick_widgets;
if ((ret = quick_dialog (&Quick_input)) != B_CANCEL){
return ret;
} else
return 0;
for (i = 0; i < 4; i++)
quick_widgets[i].relative_y = relative_y[i] + 2 + lines;
ret = quick_dialog (&Quick_input);
}
return (ret != B_CANCEL) ? ret : 0;
}
static void add_new_group_cmd (void)

View File

@ -1270,27 +1270,23 @@ static void check_codeset()
if ( !skip_check_codeset ) {
QuickWidget ecs_widgets [] = {
{ quick_button, 4, 6, 13, CONFY, N_("&Skip"),
0, B_EXIT, 0, 0, NULL , NULL, NULL},
{ quick_button, 1, 11, 13, CONFY, N_("&Fix it"),
0, B_ENTER, 0, 0, NULL , NULL, NULL},
{ quick_checkbox, 1, 13, 11, CONFY, N_("don't ask again"),
11, 0, &skip_check_codeset, NULL, NULL , NULL, NULL},
{ quick_label, 2, 30, 3, CONFY, N_("Chosen display charset (Settings->Display bits)\n"
"or source codeset (in mcedit ctrl-t) \n"
"does not match one set via locale. \n"
"Set correct codeset manually or press <<Fix it>> \n"
"to set locale default.\n\n"
"Or set \'don't ask again\' and press <<Skip>>"),
0, 0, 0, 0, NULL , NULL, NULL},
NULL_QuickWidget
QUICK_BUTTON (4, 6, 13, CONFY, N_("&Skip"), B_EXIT, NULL),
QUICK_BUTTON (1, 11, 13, CONFY, N_("&Fix it"), B_ENTER, NULL),
QUICK_CHECKBOX (1, 13, 11, CONFY, N_("don't ask again"), &skip_check_codeset),
QUICK_LABEL (2, 30, 3, CONFY, N_("Chosen display charset (Settings->Display bits)\n"
"or source codeset (in mcedit ctrl-t) \n"
"does not match one set via locale. \n"
"Set correct codeset manually or press <<Fix it>> \n"
"to set locale default.\n\n"
"Or set \'don't ask again\' and press <<Skip>>")),
QUICK_END
};
QuickDialog ecs =
{ CONFX, CONFY, -1, -1, N_(" Confirmation "), "[Confirmation]",
ecs_widgets, 0
};
QuickDialog ecs =
{
CONFX, CONFY, -1, -1, N_(" Confirmation "),
"[Confirmation]", ecs_widgets, FALSE
};
_system_codepage = str_detect_termencoding();

View File

@ -60,96 +60,61 @@
gboolean
mcview_dialog_search (mcview_t * view)
{
enum {
SEARCH_DLG_MIN_HEIGHT = 11,
SEARCH_DLG_HEIGHT_SUPPLY = 3,
SEARCH_DLG_WIDTH = 58
};
int SEARCH_DLG_MIN_HEIGHT = 12;
int SEARCH_DLG_HEIGHT_SUPPLY = 3;
int SEARCH_DLG_WIDTH = 58;
char *exp = NULL;
#ifdef HAVE_CHARSET
GString *tmp;
#endif
int ttype_of_search = (int) view->search_type;
int tall_codepages = (int) view->search_all_codepages;
int tsearch_case = (int) view->search_case;
int twhole_words = (int) view->whole_words;
int tsearch_backwards = (int) view->search_backwards;
int qd_result;
gchar **list_of_types = mc_search_get_types_strings_array ();
int SEARCH_DLG_HEIGHT =
SEARCH_DLG_MIN_HEIGHT + g_strv_length (list_of_types) - SEARCH_DLG_HEIGHT_SUPPLY;
SEARCH_DLG_MIN_HEIGHT + g_strv_length (list_of_types) - SEARCH_DLG_HEIGHT_SUPPLY;
QuickWidget quick_widgets[] = {
{quick_button, 6, 10, SEARCH_DLG_HEIGHT - 3, SEARCH_DLG_HEIGHT, N_("&Cancel"), 0,
B_CANCEL, 0, 0, NULL, NULL, NULL},
{quick_button, 2, 10, SEARCH_DLG_HEIGHT - 3, SEARCH_DLG_HEIGHT, N_("&OK"), 0, B_ENTER,
0, 0, NULL, NULL, NULL},
QUICK_BUTTON (6, 10, SEARCH_DLG_HEIGHT - 3, SEARCH_DLG_HEIGHT, N_("&Cancel"), B_CANCEL, NULL),
QUICK_BUTTON (2, 10, SEARCH_DLG_HEIGHT - 3, SEARCH_DLG_HEIGHT, N_("&OK"), B_ENTER, NULL),
#ifdef HAVE_CHARSET
{quick_checkbox, SEARCH_DLG_WIDTH / 2 + 3, SEARCH_DLG_WIDTH, 7, SEARCH_DLG_HEIGHT,
N_("All charsets"), 0, 0,
&tall_codepages, 0, NULL, NULL, NULL},
QUICK_CHECKBOX (SEARCH_DLG_WIDTH / 2 + 3, SEARCH_DLG_WIDTH, 8, SEARCH_DLG_HEIGHT,
N_("All charsets"), &view->search_all_codepages),
#endif
{quick_checkbox, SEARCH_DLG_WIDTH / 2 + 3, SEARCH_DLG_WIDTH, 6, SEARCH_DLG_HEIGHT,
N_("&Whole words"), 0, 0, &twhole_words, 0, NULL, NULL, NULL},
{quick_checkbox, SEARCH_DLG_WIDTH / 2 + 3, SEARCH_DLG_WIDTH, 5, SEARCH_DLG_HEIGHT,
N_("&Backwards"), 0, 0, &tsearch_backwards, 0, NULL, NULL, NULL},
{quick_checkbox, SEARCH_DLG_WIDTH / 2 + 3, SEARCH_DLG_WIDTH, 4, SEARCH_DLG_HEIGHT,
N_("case &Sensitive"), 0, 0,
&tsearch_case, 0, NULL, NULL, NULL},
{quick_radio, 3, SEARCH_DLG_WIDTH, 4, SEARCH_DLG_HEIGHT, 0, g_strv_length (list_of_types),
ttype_of_search,
(void *) &ttype_of_search, const_cast (char **, list_of_types), NULL, NULL, NULL},
{quick_input, 3, SEARCH_DLG_WIDTH, 3, SEARCH_DLG_HEIGHT, INPUT_LAST_TEXT, 52, 0,
0, &exp, MC_HISTORY_SHARED_SEARCH, NULL, NULL},
{quick_label, 2, SEARCH_DLG_WIDTH, 2, SEARCH_DLG_HEIGHT,
N_(" Enter search string:"), 0, 0, 0, 0, 0, NULL, NULL},
NULL_QuickWidget
QUICK_CHECKBOX (SEARCH_DLG_WIDTH / 2 + 3, SEARCH_DLG_WIDTH, 7, SEARCH_DLG_HEIGHT,
N_("&Whole words"), &view->whole_words),
QUICK_CHECKBOX (SEARCH_DLG_WIDTH / 2 + 3, SEARCH_DLG_WIDTH, 6, SEARCH_DLG_HEIGHT,
N_("&Backwards"), &view->search_backwards),
QUICK_CHECKBOX (SEARCH_DLG_WIDTH / 2 + 3, SEARCH_DLG_WIDTH, 5, SEARCH_DLG_HEIGHT,
N_("case &Sensitive"), &view->search_case),
QUICK_RADIO (3, SEARCH_DLG_WIDTH, 5, SEARCH_DLG_HEIGHT,
g_strv_length (list_of_types), (const char **) list_of_types, &view->search_type),
QUICK_INPUT (3, SEARCH_DLG_WIDTH, 3, SEARCH_DLG_HEIGHT,
INPUT_LAST_TEXT, SEARCH_DLG_WIDTH - 6, 0, MC_HISTORY_SHARED_SEARCH, &exp),
QUICK_LABEL (2, SEARCH_DLG_WIDTH, 2, SEARCH_DLG_HEIGHT, N_(" Enter search string:")),
QUICK_END
};
QuickDialog Quick_input = {
SEARCH_DLG_WIDTH, SEARCH_DLG_HEIGHT, -1, 0, N_("Search"),
"[Input Line Keys]", quick_widgets, 0
QuickDialog Quick_input =
{
SEARCH_DLG_WIDTH, SEARCH_DLG_HEIGHT, -1, -1,
N_("Search"), "[Input Line Keys]",
quick_widgets, FALSE
};
qd_result = quick_dialog (&Quick_input);
g_strfreev (list_of_types);
if (qd_result == B_CANCEL) {
if ((qd_result == B_CANCEL) ||(exp == NULL) || (exp[0] == '\0')) {
g_free (exp);
return FALSE;
}
view->search_backwards = tsearch_backwards;
view->search_type = (mc_search_type_t) ttype_of_search;
view->search_all_codepages = (gboolean) tall_codepages;
view->search_case = (gboolean) tsearch_case;
view->whole_words = (gboolean) twhole_words;
if (exp == NULL || exp[0] == '\0') {
g_free (exp);
return FALSE;
}
#ifdef HAVE_CHARSET
tmp = str_convert_to_input (exp);
{
GString *tmp = str_convert_to_input (exp);
if (tmp) {
g_free (exp);
exp = g_string_free (tmp, FALSE);
if (tmp) {
g_free (exp);
exp = g_string_free (tmp, FALSE);
}
}
#endif

View File

@ -331,121 +331,114 @@ message (int flags, const char *title, const char *text, ...)
/* {{{ Quick dialog routines */
#define I18N(x) (do_int && *x ? (x = _(x)): x)
int
quick_dialog_skip (QuickDialog *qd, int nskip)
{
#define I18N(x) (!qd->i18n && x && *x ? (x = _(x)): x)
Dlg_head *dd;
WRadio *r;
int xpos;
int ypos;
int return_val;
WInput *input;
QuickWidget *qw;
int do_int;
WInput *in;
WRadio *r;
int return_val;
if (!qd->i18n) {
qd->i18n = 1;
do_int = 1;
if (*qd->title)
qd->title = _(qd->title);
} else
do_int = 0;
(void) I18N (qd->title);
if (qd->xpos == -1)
dd = create_dlg (0, 0, qd->ylen, qd->xlen, dialog_colors, NULL,
qd->help, qd->title,
DLG_CENTER | DLG_TRYUP | DLG_REVERSE);
if ((qd->xpos == -1) || (qd->ypos == -1))
dd = create_dlg (0, 0, qd->ylen, qd->xlen,
dialog_colors, NULL, qd->help, qd->title,
DLG_CENTER | DLG_TRYUP | DLG_REVERSE);
else
dd = create_dlg (qd->ypos, qd->xpos, qd->ylen, qd->xlen,
dialog_colors, NULL, qd->help, qd->title,
DLG_REVERSE);
dialog_colors, NULL, qd->help, qd->title,
DLG_REVERSE);
for (qw = qd->widgets; qw->widget_type != quick_end; qw++) {
int xpos;
int ypos;
for (qw = qd->widgets; qw->widget_type; qw++) {
xpos = (qd->xlen * qw->relative_x) / qw->x_divisions;
ypos = (qd->ylen * qw->relative_y) / qw->y_divisions;
switch (qw->widget_type) {
case quick_checkbox:
qw->widget = (Widget *)check_new (ypos, xpos, *qw->result, I18N (qw->text));
break;
case quick_radio:
r = radio_new (ypos, xpos, qw->hotkey_pos, const_cast(const char **, qw->str_result));
r->pos = r->sel = qw->value;
qw->widget = (Widget *)r;
qw->widget = (Widget *) check_new (ypos, xpos, *qw->u.checkbox.state, I18N (qw->u.checkbox.text));
break;
case quick_button:
qw->widget = (Widget *)
button_new (ypos, xpos, qw->value,
(qw->value ==
B_ENTER) ? DEFPUSH_BUTTON : NORMAL_BUTTON,
I18N (qw->text), (bcback) qw->cb);
qw->widget = (Widget *) button_new (ypos, xpos, qw->u.button.action,
(qw->u.button.action == B_ENTER) ? DEFPUSH_BUTTON : NORMAL_BUTTON,
I18N (qw->u.button.text), qw->u.button.callback);
break;
/* We use the hotkey pos as the field length */
case quick_input:
input =
input_new (ypos, xpos, INPUT_COLOR, qw->hotkey_pos,
qw->text, qw->histname, INPUT_COMPLETE_DEFAULT);
input->is_password = qw->value == 1;
input->point = 0;
if (qw->value & 2)
input->completion_flags |= INPUT_COMPLETE_CD;
qw->widget = (Widget *)input;
in = input_new (ypos, xpos, INPUT_COLOR, qw->u.input.len,
qw->u.input.text, qw->u.input.histname, INPUT_COMPLETE_DEFAULT);
in->is_password = (qw->u.input.flags == 1);
in->point = 0;
if ((qw->u.input.flags & 2) != 0)
in->completion_flags |= INPUT_COMPLETE_CD;
qw->widget = (Widget *) in;
*qw->u.input.result = NULL;
break;
case quick_label:
qw->widget = (Widget *)label_new (ypos, xpos, I18N (qw->text));
qw->widget = (Widget *) label_new (ypos, xpos, I18N (qw->u.label.text));
break;
case quick_radio:
r = radio_new (ypos, xpos, qw->u.radio.count, qw->u.radio.items);
r->pos = r->sel = *qw->u.radio.value;
qw->widget = (Widget *) r;
break;
default:
qw->widget = 0;
qw->widget = NULL;
fprintf (stderr, "QuickWidget: unknown widget type\n");
break;
}
add_widget (dd, qw->widget);
}
while (nskip--)
while (nskip-- != 0)
dd->current = dd->current->next;
run_dlg (dd);
return_val = run_dlg (dd);
/* Get the data if we found something interesting */
if (dd->ret_value != B_CANCEL) {
for (qw = qd->widgets; qw->widget_type; qw++) {
Widget *w = qw->widget;
if (return_val != B_CANCEL) {
for (qw = qd->widgets; qw->widget_type != quick_end; qw++) {
switch (qw->widget_type) {
case quick_checkbox:
*qw->result = ((WCheck *) w)->state & C_BOOL;
break;
case quick_radio:
*qw->result = ((WRadio *) w)->sel;
*qw->u.checkbox.state = ((WCheck *) qw->widget)->state & C_BOOL;
break;
case quick_input:
if (qw->value & 2)
*qw->str_result =
tilde_expand (((WInput *) w)->buffer);
if ((qw->u.input.flags & 2) != 0)
*qw->u.input.result = tilde_expand (((WInput *) qw->widget)->buffer);
else
*qw->str_result = g_strdup (((WInput *) w)->buffer);
*qw->u.input.result = g_strdup (((WInput *) qw->widget)->buffer);
break;
case quick_radio:
*qw->u.radio.value = ((WRadio *) qw->widget)->sel;
break;
default:
break;
}
}
}
return_val = dd->ret_value;
destroy_dlg (dd);
return return_val;
#undef I18N
}
int quick_dialog (QuickDialog *qd)
int
quick_dialog (QuickDialog *qd)
{
return quick_dialog_skip (qd, 0);
}
@ -454,8 +447,6 @@ int quick_dialog (QuickDialog *qd)
/* {{{ Input routines */
#define INPUT_INDEX 2
/*
* Show dialog, not background safe.
*
@ -471,82 +462,74 @@ static char *
fg_input_dialog_help (const char *header, const char *text, const char *help,
const char *history_name, const char *def_text)
{
QuickDialog Quick_input;
char *my_str;
QuickWidget quick_widgets[] = {
{quick_button, 6, 10, 1, 0, N_("&Cancel"), 0, B_CANCEL, 0, 0,
NULL, NULL, NULL},
{quick_button, 3, 10, 1, 0, N_("&OK"), 0, B_ENTER, 0, 0, NULL, NULL, NULL},
{quick_input, 4, 80, 0, 0, "", 58, 0, 0, 0, NULL, NULL, NULL},
{quick_label, 4, 80, 2, 0, "", 0, 0, 0, 0, NULL, NULL, NULL},
NULL_QuickWidget
/* 0 */ QUICK_BUTTON (6, 10, 1, 0, N_("&Cancel"), B_CANCEL, NULL),
/* 1 */ QUICK_BUTTON (3, 10, 1, 0, N_("&OK"), B_ENTER, NULL),
/* 2 */ QUICK_INPUT (4, 80, 0, 0, def_text, 58, 0, NULL, &my_str),
/* 3 */ QUICK_LABEL (4, 80, 2, 0, ""),
QUICK_END
};
char histname [64] = "inp|";
int lines, cols;
int len;
int i;
int lines, cols;
int ret;
char *my_str;
char histname[64] = "inp|";
char *p_text;
int ret;
if (history_name != NULL && *history_name != '\0') {
g_strlcpy (histname + 3, history_name, 61);
quick_widgets[2].histname = histname;
g_strlcpy (histname + 3, history_name, sizeof (histname) - 3);
quick_widgets[2].u.input.histname = histname;
}
msglen (text, &lines, &cols);
len = max (str_term_width1 (header), cols) + 4;
len = max (len, 64);
len = max (max (str_term_width1 (header), cols) + 4, 64);
/* The special value of def_text is used to identify password boxes
and hide characters with "*". Don't save passwords in history! */
if (def_text == INPUT_PASSWORD) {
quick_widgets[INPUT_INDEX].value = 1;
histname[3] = 0;
quick_widgets[2].u.input.flags = 1;
histname[3] = '\0';
def_text = "";
} else {
quick_widgets[INPUT_INDEX].value = 0;
}
#ifdef ENABLE_NLS
/*
/*
* An attempt to place buttons symmetrically, based on actual i18n
* length of the string. It looks nicer with i18n (IMO) - alex
*/
quick_widgets[0].text = _(quick_widgets[0].text);
quick_widgets[1].text = _(quick_widgets[1].text);
quick_widgets[0].u.button.text = _(quick_widgets[0].u.button.text);
quick_widgets[1].u.button.text = _(quick_widgets[1].u.button.text);
quick_widgets[0].relative_x = len / 2 + 4;
quick_widgets[1].relative_x =
len / 2 - (str_term_width1 (quick_widgets[1].text) + 9);
len / 2 - (str_term_width1 (quick_widgets[1].u.button.text) + 9);
quick_widgets[0].x_divisions = quick_widgets[1].x_divisions = len;
#endif /* ENABLE_NLS */
Quick_input.xlen = len;
Quick_input.xpos = -1;
Quick_input.title = header;
Quick_input.help = help;
Quick_input.i18n = 1; /* The dialog is already translated. */
p_text = g_strstrip (g_strdup (text));
quick_widgets[INPUT_INDEX + 1].text = p_text;
quick_widgets[INPUT_INDEX].text = def_text;
quick_widgets[3].u.label.text = p_text;
for (i = 0; i < 4; i++)
quick_widgets[i].y_divisions = lines + 6;
Quick_input.ylen = lines + 6;
{
QuickDialog Quick_input =
{
len, lines + 6, -1, -1, header,
help, quick_widgets, TRUE
};
for (i = 0; i < 3; i++)
quick_widgets[i].relative_y += 2 + lines;
for (i = 0; i < 4; i++)
quick_widgets[i].y_divisions = Quick_input.ylen;
quick_widgets[INPUT_INDEX].str_result = &my_str;
for (i = 0; i < 3; i++)
quick_widgets[i].relative_y += 2 + lines;
ret = quick_dialog (&Quick_input);
}
Quick_input.widgets = quick_widgets;
ret = quick_dialog (&Quick_input);
g_free (p_text);
if (ret != B_CANCEL) {
return my_str;
} else
return 0;
return (ret != B_CANCEL) ? my_str : NULL;
}
/*

View File

@ -6,6 +6,8 @@
#ifndef MC_WTOOLS_H
#define MC_WTOOLS_H
#include "global.h"
#include "dialog.h"
#include "widget.h"
typedef struct {
@ -23,32 +25,137 @@ Listbox *create_listbox_window (int cols, int lines, const char *title, const ch
int run_listbox (Listbox *l);
/* Quick Widgets */
enum {
quick_end, quick_checkbox,
quick_button, quick_input,
quick_label, quick_radio
} /* quick_t */;
typedef enum {
quick_end = 0,
quick_checkbox = 1,
quick_button = 2,
quick_input = 3,
quick_label = 4,
quick_radio = 5
} quick_t;
/* The widget is placed on relative_?/divisions_? of the parent widget */
typedef struct {
int widget_type;
quick_t widget_type;
int relative_x;
int x_divisions;
int relative_y;
int y_divisions;
const char *text; /* Text */
int hotkey_pos; /* the hotkey position */
int value; /* Buttons only: value of button */
int *result; /* Checkbutton: where to store result */
char **str_result; /* Input lines: destination */
const char *histname; /* Name of the section for saving history */
bcback cb; /* Callback for quick_button */
Widget *widget;
/* widget parameters */
union {
struct {
const char *text;
int *state; /* in/out */
} checkbox;
struct {
const char *text;
int action;
bcback callback;
} button;
struct {
const char *text;
int len;
int flags; /* 1 -- is_password, 2 -- INPUT_COMPLETE_CD */
const char *histname;
char **result;
} input;
struct {
const char *text;
} label;
struct {
int count;
const char **items;
int *value; /* in/out */
} radio;
} u;
} QuickWidget;
#define NULL_QuickWidget { 0, 0, 0, 0, 0, NULL, 0, 0, NULL, NULL, NULL, NULL, NULL }
#define QUICK_CHECKBOX(x, xdiv, y, ydiv, txt, st) \
{ \
.widget_type = quick_checkbox, \
.relative_x = x, \
.x_divisions = xdiv, \
.relative_y = y, \
.y_divisions = ydiv, \
.widget = NULL, \
.u.checkbox.text = txt, \
.u.checkbox.state = st \
}
#define QUICK_BUTTON(x, xdiv, y, ydiv, txt, act, cb) \
{ \
.widget_type = quick_button, \
.relative_x = x, \
.x_divisions = xdiv, \
.relative_y = y, \
.y_divisions = ydiv, \
.widget = NULL, \
.u.button.text = txt, \
.u.button.action = act, \
.u.button.callback = cb \
}
#define QUICK_INPUT(x, xdiv, y, ydiv, txt, len_, flags_, hname, res) \
{ \
.widget_type = quick_input, \
.relative_x = x, \
.x_divisions = xdiv, \
.relative_y = y, \
.y_divisions = ydiv, \
.widget = NULL, \
.u.input.text = txt, \
.u.input.len = len_, \
.u.input.flags = flags_, \
.u.input.histname = hname, \
.u.input.result = res \
}
#define QUICK_LABEL(x, xdiv, y, ydiv, txt) \
{ \
.widget_type = quick_label, \
.relative_x = x, \
.x_divisions = xdiv, \
.relative_y = y, \
.y_divisions = ydiv, \
.widget = NULL, \
.u.label.text = txt \
}
#define QUICK_RADIO(x, xdiv, y, ydiv, cnt, items_, val) \
{ \
.widget_type = quick_radio, \
.relative_x = x, \
.x_divisions = xdiv, \
.relative_y = y, \
.y_divisions = ydiv, \
.widget = NULL, \
.u.radio.count = cnt, \
.u.radio.items = items_, \
.u.radio.value = val, \
}
#define QUICK_END \
{ \
.widget_type = quick_end, \
.relative_x = 0, \
.x_divisions = 0, \
.relative_y = 0, \
.y_divisions = 0, \
.widget = NULL, \
.u.input.text = NULL, \
.u.input.len = 0, \
.u.input.flags = 0, \
.u.input.histname = NULL, \
.u.input.result = NULL \
}
typedef struct {
int xlen, ylen;
@ -56,7 +163,7 @@ typedef struct {
const char *title;
const char *help;
QuickWidget *widgets;
int i18n; /* If true, internationalization has happened */
gboolean i18n; /* If true, internationalization has happened */
} QuickDialog;
int quick_dialog (QuickDialog *qd);