mirror of
https://github.com/MidnightCommander/mc
synced 2024-12-22 20:36:50 +03:00
* option.c: Make "Configure options" dialog more flexible,
readjust layout. Remove "advanced chown" option - it's unused.
This commit is contained in:
parent
5ae7ee9ae2
commit
c740e77171
@ -1,3 +1,8 @@
|
||||
2002-09-13 Pavel Roskin <proski@gnu.org>
|
||||
|
||||
* option.c: Make "Configure options" dialog more flexible,
|
||||
readjust layout. Remove "advanced chown" option - it's unused.
|
||||
|
||||
2002-09-13 Andrew V. Samoilov <sav@bcs.zp.ua>
|
||||
|
||||
* main.c (process_args) [WITH_SMBFS]: Call smbfs_set_debugf()
|
||||
|
188
src/option.c
188
src/option.c
@ -42,15 +42,6 @@
|
||||
#include "file.h"
|
||||
#include "layout.h" /* For nice_rotating_dash */
|
||||
#include "option.h"
|
||||
#define PX 4
|
||||
#define PY 2
|
||||
|
||||
#define RX 4
|
||||
#define RY 12
|
||||
|
||||
#define BY 17
|
||||
#define OY 2
|
||||
|
||||
static Dlg_head *conf_dlg;
|
||||
|
||||
static int r_but;
|
||||
@ -59,7 +50,7 @@ static int r_but;
|
||||
|
||||
extern int use_internal_edit;
|
||||
|
||||
static int OX = 33, first_width = 27, second_width = 27;
|
||||
static int first_width, second_width;
|
||||
static char *title1, *title2, *title3;
|
||||
|
||||
static struct {
|
||||
@ -69,9 +60,9 @@ static struct {
|
||||
WCheck *widget;
|
||||
char *tk;
|
||||
} check_options [] = {
|
||||
/* other options */
|
||||
{N_("safe de&Lete"), &know_not_what_am_i_doing, TOGGLE_VARIABLE,0, "safe-del" },
|
||||
{N_("cd follows lin&Ks"), &cd_symlinks, TOGGLE_VARIABLE, 0, "cd-follow" },
|
||||
{N_("advanced cho&Wn"), &advanced_chfns, TOGGLE_VARIABLE, 0, "achown" },
|
||||
{N_("l&Ynx-like motion"), &navigate_with_arrows,TOGGLE_VARIABLE, 0, "lynx" },
|
||||
{N_("rotatin&G dash"), &nice_rotating_dash,TOGGLE_VARIABLE, 0, "rotating" },
|
||||
{N_("co&Mplete: show all"),&show_all_if_ambiguous,TOGGLE_VARIABLE, 0, "completion" },
|
||||
@ -82,6 +73,7 @@ static struct {
|
||||
{N_("shell &Patterns"), &easy_patterns, TOGGLE_VARIABLE, 0, "shell-patt" },
|
||||
{N_("Compute &Totals"), &file_op_compute_totals, TOGGLE_VARIABLE, 0, "compute-totals" },
|
||||
{N_("&Verbose operation"), &verbose, TOGGLE_VARIABLE, 0, "verbose" },
|
||||
/* panel options */
|
||||
{N_("&Fast dir reload"), &fast_reload, toggle_fast_reload, 0, "fast-reload" },
|
||||
{N_("mi&X all files"), &mix_all_files, toggle_mix_all_files, 0, "mix-files" },
|
||||
{N_("&Drop down menus"), &drop_menus, TOGGLE_VARIABLE, 0, "drop-menus" },
|
||||
@ -91,6 +83,10 @@ static struct {
|
||||
{ 0, 0, 0, 0 }
|
||||
};
|
||||
|
||||
/* Make sure this corresponds to the check_options structure */
|
||||
#define OTHER_OPTIONS 12
|
||||
#define PANEL_OPTIONS 6
|
||||
|
||||
static WRadio *pause_radio;
|
||||
|
||||
static char *pause_options [3] = {
|
||||
@ -98,6 +94,23 @@ static char *pause_options [3] = {
|
||||
N_("on dumb &Terminals"),
|
||||
N_("alwa&Ys") };
|
||||
|
||||
#define PAUSE_OPTIONS (sizeof(pause_options) / sizeof(char *))
|
||||
|
||||
/* Heights of the panes */
|
||||
#define PY 3
|
||||
#define OY PY
|
||||
/* Align bottoms of "pause after run" and "other options" */
|
||||
#define RY (OTHER_OPTIONS - PAUSE_OPTIONS + OY)
|
||||
#define DLG_Y (OTHER_OPTIONS + 9)
|
||||
#define BY (DLG_Y - 3)
|
||||
|
||||
/* Horizontal dimensions */
|
||||
#define X_MARGIN 3
|
||||
#define X_PANE_GAP 1
|
||||
#define PX X_MARGIN
|
||||
#define RX X_MARGIN
|
||||
#define OX (first_width + X_MARGIN + X_PANE_GAP)
|
||||
|
||||
static int configure_callback (struct Dlg_head *h, int Id, int Msg)
|
||||
{
|
||||
switch (Msg) {
|
||||
@ -105,9 +118,9 @@ static int configure_callback (struct Dlg_head *h, int Id, int Msg)
|
||||
common_dialog_repaint (h);
|
||||
|
||||
attrset (COLOR_NORMAL);
|
||||
draw_box (h, PY, PX, 8, first_width);
|
||||
draw_box (h, RY, RX, 5, first_width);
|
||||
draw_box (h, OY, OX, 15, second_width);
|
||||
draw_box (h, PY, PX, PANEL_OPTIONS + 2, first_width);
|
||||
draw_box (h, RY, RX, PAUSE_OPTIONS + 2, first_width);
|
||||
draw_box (h, OY, OX, OTHER_OPTIONS + 2, second_width);
|
||||
|
||||
attrset (COLOR_HOT_NORMAL);
|
||||
dlg_move (h, OY, OX+1);
|
||||
@ -125,101 +138,102 @@ static int configure_callback (struct Dlg_head *h, int Id, int Msg)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void init_configure (void)
|
||||
/* Create the "Configure options" dialog */
|
||||
static void
|
||||
init_configure (void)
|
||||
{
|
||||
int i;
|
||||
static int i18n_config_flag = 0;
|
||||
static int b1, b2, b3;
|
||||
char* ok_button = _("&Ok");
|
||||
char* cancel_button = _("&Cancel");
|
||||
char* save_button = _("&Save");
|
||||
static int i18n_config_flag = 0;
|
||||
static int b1, b2, b3;
|
||||
char *ok_button = _("&Ok");
|
||||
char *cancel_button = _("&Cancel");
|
||||
char *save_button = _("&Save");
|
||||
|
||||
if (!i18n_config_flag)
|
||||
{
|
||||
register int l1;
|
||||
if (!i18n_config_flag) {
|
||||
register int l1;
|
||||
|
||||
/* Similar code is in layout.c (init_layout()) */
|
||||
/* Similar code is in layout.c (init_layout()) */
|
||||
|
||||
title1 = _(" Panel options ");
|
||||
title2 = _(" Pause after run... ");
|
||||
title3 = _(" Other options ");
|
||||
title1 = _(" Panel options ");
|
||||
title2 = _(" Pause after run... ");
|
||||
title3 = _(" Other options ");
|
||||
|
||||
first_width = strlen (title1) + 1;
|
||||
for (i = 13; i < 19; i++)
|
||||
{
|
||||
check_options[i].text = _(check_options[i].text);
|
||||
l1 = strlen (check_options[i].text) + 7;
|
||||
if (l1 > first_width)
|
||||
first_width = l1;
|
||||
}
|
||||
first_width = strlen (title1) + 1;
|
||||
second_width = strlen (title3) + 1;
|
||||
|
||||
i = sizeof(pause_options)/sizeof(char*);
|
||||
while (i--)
|
||||
{
|
||||
pause_options [i] = _(pause_options [i]);
|
||||
l1 = strlen (pause_options [i]) + 7;
|
||||
if (l1 > first_width)
|
||||
first_width = l1;
|
||||
}
|
||||
|
||||
l1 = strlen (title2) + 1;
|
||||
for (i = 0; check_options[i].text; i++) {
|
||||
check_options[i].text = _(check_options[i].text);
|
||||
l1 = strlen (check_options[i].text) + 7;
|
||||
if (i >= OTHER_OPTIONS) {
|
||||
if (l1 > first_width)
|
||||
first_width = l1;
|
||||
|
||||
OX = first_width + 5;
|
||||
|
||||
second_width = strlen (title3) + 1;
|
||||
for (i = 0; i < 13; i++)
|
||||
{
|
||||
check_options[i].text = _(check_options[i].text);
|
||||
l1 = strlen (check_options[i].text) + 7;
|
||||
if (l1 > second_width)
|
||||
second_width = l1;
|
||||
}
|
||||
|
||||
l1 = 11 + strlen (ok_button)
|
||||
+ strlen (save_button)
|
||||
+ strlen (cancel_button);
|
||||
|
||||
i = (first_width + second_width - l1) / 4;
|
||||
b1 = 5 + i;
|
||||
b2 = b1 + strlen(ok_button) + i + 6;
|
||||
b3 = b2 + strlen(save_button) + i + 4;
|
||||
|
||||
i18n_config_flag = 1;
|
||||
first_width = l1;
|
||||
} else {
|
||||
if (l1 > second_width)
|
||||
second_width = l1;
|
||||
}
|
||||
}
|
||||
|
||||
conf_dlg = create_dlg (0, 0, 20, first_width + second_width + 9,
|
||||
dialog_colors, configure_callback, "[Configuration]",
|
||||
_("Configure options"), DLG_CENTER);
|
||||
i = sizeof (pause_options) / sizeof (char *);
|
||||
while (i--) {
|
||||
pause_options[i] = _(pause_options[i]);
|
||||
l1 = strlen (pause_options[i]) + 7;
|
||||
if (l1 > first_width)
|
||||
first_width = l1;
|
||||
}
|
||||
|
||||
l1 = strlen (title2) + 1;
|
||||
if (l1 > first_width)
|
||||
first_width = l1;
|
||||
|
||||
l1 = 11 + strlen (ok_button)
|
||||
+ strlen (save_button)
|
||||
+ strlen (cancel_button);
|
||||
|
||||
i = (first_width + second_width - l1) / 4;
|
||||
b1 = 5 + i;
|
||||
b2 = b1 + strlen (ok_button) + i + 6;
|
||||
b3 = b2 + strlen (save_button) + i + 4;
|
||||
|
||||
i18n_config_flag = 1;
|
||||
}
|
||||
|
||||
conf_dlg =
|
||||
create_dlg (0, 0, DLG_Y,
|
||||
first_width + second_width + 2 * X_MARGIN + X_PANE_GAP,
|
||||
dialog_colors, configure_callback, "[Configuration]",
|
||||
_("Configure options"), DLG_CENTER);
|
||||
|
||||
add_widget (conf_dlg,
|
||||
button_new (BY, b3, B_CANCEL, NORMAL_BUTTON,
|
||||
cancel_button, 0, 0, "button-cancel"));
|
||||
button_new (BY, b3, B_CANCEL, NORMAL_BUTTON,
|
||||
cancel_button, 0, 0, "button-cancel"));
|
||||
|
||||
add_widget (conf_dlg,
|
||||
button_new (BY, b2, B_EXIT, NORMAL_BUTTON,
|
||||
save_button, 0, 0, "button-save"));
|
||||
|
||||
button_new (BY, b2, B_EXIT, NORMAL_BUTTON,
|
||||
save_button, 0, 0, "button-save"));
|
||||
|
||||
add_widget (conf_dlg,
|
||||
button_new (BY, b1, B_ENTER, DEFPUSH_BUTTON,
|
||||
ok_button, 0, 0, "button-ok"));
|
||||
button_new (BY, b1, B_ENTER, DEFPUSH_BUTTON,
|
||||
ok_button, 0, 0, "button-ok"));
|
||||
|
||||
#define XTRACT(i) *check_options[i].variable, check_options[i].text, check_options [i].tk
|
||||
|
||||
/* Add all the checkboxes */
|
||||
for (i = 0; i < 13; i++){
|
||||
check_options [i].widget = check_new (OY + (13-i), OX+2, XTRACT(i));
|
||||
add_widget (conf_dlg, check_options [i].widget);
|
||||
/* Add checkboxes for "other options" */
|
||||
for (i = 0; i < OTHER_OPTIONS; i++) {
|
||||
check_options[i].widget =
|
||||
check_new (OY + (OTHER_OPTIONS - i), OX + 2, XTRACT (i));
|
||||
add_widget (conf_dlg, check_options[i].widget);
|
||||
}
|
||||
|
||||
pause_radio = radio_new (RY+1, RX+2, 3, pause_options, 1, "pause-radio");
|
||||
pause_radio =
|
||||
radio_new (RY + 1, RX + 2, 3, pause_options, 1, "pause-radio");
|
||||
pause_radio->sel = pause_after_run;
|
||||
add_widget (conf_dlg, pause_radio);
|
||||
for (i = 0; i < 6; i++){
|
||||
check_options [i+13].widget = check_new (PY + (6-i), PX+2,
|
||||
XTRACT(i+13));
|
||||
add_widget (conf_dlg, check_options [i+13].widget);
|
||||
|
||||
/* Add checkboxes for "panel options" */
|
||||
for (i = 0; i < PANEL_OPTIONS; i++) {
|
||||
check_options[i + OTHER_OPTIONS].widget =
|
||||
check_new (PY + (6 - i), PX + 2, XTRACT (i + OTHER_OPTIONS));
|
||||
add_widget (conf_dlg, check_options[i + OTHER_OPTIONS].widget);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user