1998-02-27 07:54:42 +03:00
|
|
|
/* Configure box module for the Midnight Commander
|
|
|
|
Copyright (C) 1994 Radek Doulik
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
2000-08-23 02:50:00 +04:00
|
|
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
1998-02-27 07:54:42 +03:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
/* Needed for the extern declarations of integer parameters */
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#ifdef HAVE_UNISTD_H
|
|
|
|
# include <unistd.h>
|
|
|
|
#endif
|
2001-09-03 09:07:40 +04:00
|
|
|
|
1999-09-20 03:09:07 +04:00
|
|
|
#include "global.h"
|
1998-02-27 07:54:42 +03:00
|
|
|
#include "tty.h"
|
|
|
|
#include "win.h"
|
|
|
|
#include "color.h"
|
|
|
|
#include "dlg.h"
|
|
|
|
#include "widget.h"
|
|
|
|
#include "setup.h" /* For save_setup() */
|
|
|
|
#include "dialog.h" /* For do_refresh() */
|
|
|
|
#include "main.h"
|
|
|
|
#include "profile.h" /* For sync_profiles */
|
|
|
|
|
|
|
|
#include "panel.h" /* Needed for the externs */
|
2002-12-08 07:16:30 +03:00
|
|
|
#include "file.h" /* safe_delete */
|
1998-02-27 07:54:42 +03:00
|
|
|
#include "layout.h" /* For nice_rotating_dash */
|
1998-12-03 00:27:27 +03:00
|
|
|
#include "option.h"
|
1998-02-27 07:54:42 +03:00
|
|
|
static Dlg_head *conf_dlg;
|
|
|
|
|
|
|
|
#define TOGGLE_VARIABLE 0
|
|
|
|
|
2002-09-13 20:29:32 +04:00
|
|
|
static int first_width, second_width;
|
1998-04-07 23:08:31 +04:00
|
|
|
|
1998-02-27 07:54:42 +03:00
|
|
|
static struct {
|
|
|
|
char *text;
|
|
|
|
int *variable;
|
|
|
|
void (*toggle_function)(void);
|
|
|
|
WCheck *widget;
|
|
|
|
} check_options [] = {
|
2002-09-13 20:29:32 +04:00
|
|
|
/* other options */
|
2003-09-01 05:34:17 +04:00
|
|
|
{N_("safe de&Lete"), &safe_delete, TOGGLE_VARIABLE, 0 },
|
|
|
|
{N_("cd follows lin&Ks"), &cd_symlinks, TOGGLE_VARIABLE, 0 },
|
|
|
|
{N_("L&ynx-like motion"), &navigate_with_arrows,TOGGLE_VARIABLE, 0 },
|
|
|
|
{N_("rotatin&G dash"), &nice_rotating_dash,TOGGLE_VARIABLE, 0 },
|
|
|
|
{N_("co&Mplete: show all"),&show_all_if_ambiguous,TOGGLE_VARIABLE, 0 },
|
|
|
|
{N_("&Use internal view"), &use_internal_view, TOGGLE_VARIABLE, 0 },
|
|
|
|
{N_("use internal ed&It"), &use_internal_edit, TOGGLE_VARIABLE, 0 },
|
|
|
|
{N_("auto m&Enus"), &auto_menu, TOGGLE_VARIABLE, 0 },
|
|
|
|
{N_("&Auto save setup"), &auto_save_setup, TOGGLE_VARIABLE, 0 },
|
|
|
|
{N_("shell &Patterns"), &easy_patterns, TOGGLE_VARIABLE, 0 },
|
|
|
|
{N_("Compute &Totals"), &file_op_compute_totals, TOGGLE_VARIABLE, 0 },
|
|
|
|
{N_("&Verbose operation"), &verbose, TOGGLE_VARIABLE, 0 },
|
2002-09-13 20:29:32 +04:00
|
|
|
/* panel options */
|
2003-09-01 05:34:17 +04:00
|
|
|
{N_("&Fast dir reload"), &fast_reload, toggle_fast_reload, 0 },
|
|
|
|
{N_("mi&X all files"), &mix_all_files, toggle_mix_all_files, 0 },
|
|
|
|
{N_("&Drop down menus"), &drop_menus, TOGGLE_VARIABLE, 0 },
|
|
|
|
{N_("ma&Rk moves down"), &mark_moves_down, TOGGLE_VARIABLE, 0 },
|
|
|
|
{N_("show &Hidden files"), &show_dot_files, toggle_show_hidden, 0 },
|
|
|
|
{N_("show &Backup files"), &show_backups, toggle_show_backup, 0 },
|
1998-02-27 07:54:42 +03:00
|
|
|
{ 0, 0, 0, 0 }
|
|
|
|
};
|
|
|
|
|
2002-09-13 20:29:32 +04:00
|
|
|
/* Make sure this corresponds to the check_options structure */
|
|
|
|
#define OTHER_OPTIONS 12
|
|
|
|
#define PANEL_OPTIONS 6
|
|
|
|
|
1998-02-27 07:54:42 +03:00
|
|
|
static WRadio *pause_radio;
|
|
|
|
|
|
|
|
static char *pause_options [3] = {
|
Fri Apr 3 05:23:20 1998 Alex Tkachenko <alex@bcs.zp.ua>
* configure.in: ALL_LINGUAS test added, to allow specify list
of languages to be installed by setting env variable before
configure. If it is empty, it defaults to full list.
* src/menu.h menu_entry.{hot_pos, is_dupped} dropped
* src/menu.c: consistency fixes: pull-down menu items are now
accessible either with arrow keys or with hotkeys, denoted with &
(and highlighted). (key combinations, placed to the right of items
intended to be used from outside the menus). Freeing menu entries
removed as it no longer needed
* src/main.c, edit/editmenu.c: menubar init code is changed to conform
above fixes.
* edit/edit.h: use of "Cancel" in error_dialogs replaced with
"Dismiss", to avoid collisions in translation of "Cancel" in other
places with this case.
* src/boxes.c: select_format() and it's support removed, as it is
obsoleted by input line history feature. display_init()/display_callback
fixed to suite i18n changes. sort_box() - alike.
* src/option.c: pause_options added &'s and gettext calls to expand
statically assigned values.
* src/widget.c: (radio_callback) hotkey recognition is changed to
&-notation, rather than simple uppercase.
* src/dlg.c: (dlg_try_hotkey) plain symbol comparison replaced with
call to isalpha(), this fixes errorneous exit from input line, when
button hotkey is 8-bit NLS char.
1998-04-04 00:00:00 +04:00
|
|
|
N_("&Never"),
|
|
|
|
N_("on dumb &Terminals"),
|
2002-10-22 02:26:39 +04:00
|
|
|
N_("Alwa&ys") };
|
1998-02-27 07:54:42 +03:00
|
|
|
|
2002-09-13 20:29:32 +04:00
|
|
|
#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)
|
|
|
|
|
|
|
|
/* Create the "Configure options" dialog */
|
|
|
|
static void
|
|
|
|
init_configure (void)
|
1998-02-27 07:54:42 +03:00
|
|
|
{
|
|
|
|
int i;
|
2002-09-13 20:29:32 +04:00
|
|
|
static int i18n_config_flag = 0;
|
|
|
|
static int b1, b2, b3;
|
2002-10-22 02:26:39 +04:00
|
|
|
char *ok_button = _("&OK");
|
2002-09-13 20:29:32 +04:00
|
|
|
char *cancel_button = _("&Cancel");
|
|
|
|
char *save_button = _("&Save");
|
2003-09-08 02:53:41 +04:00
|
|
|
static char *title1, *title2, *title3;
|
2002-09-13 20:29:32 +04:00
|
|
|
|
|
|
|
if (!i18n_config_flag) {
|
|
|
|
register int l1;
|
|
|
|
|
|
|
|
/* Similar code is in layout.c (init_layout()) */
|
|
|
|
|
|
|
|
title1 = _(" Panel options ");
|
|
|
|
title2 = _(" Pause after run... ");
|
|
|
|
title3 = _(" Other options ");
|
|
|
|
|
|
|
|
first_width = strlen (title1) + 1;
|
|
|
|
second_width = strlen (title3) + 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) {
|
1998-04-07 23:08:31 +04:00
|
|
|
if (l1 > first_width)
|
2002-09-13 20:29:32 +04:00
|
|
|
first_width = l1;
|
|
|
|
} else {
|
|
|
|
if (l1 > second_width)
|
|
|
|
second_width = l1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
Fri Apr 3 05:23:20 1998 Alex Tkachenko <alex@bcs.zp.ua>
* configure.in: ALL_LINGUAS test added, to allow specify list
of languages to be installed by setting env variable before
configure. If it is empty, it defaults to full list.
* src/menu.h menu_entry.{hot_pos, is_dupped} dropped
* src/menu.c: consistency fixes: pull-down menu items are now
accessible either with arrow keys or with hotkeys, denoted with &
(and highlighted). (key combinations, placed to the right of items
intended to be used from outside the menus). Freeing menu entries
removed as it no longer needed
* src/main.c, edit/editmenu.c: menubar init code is changed to conform
above fixes.
* edit/edit.h: use of "Cancel" in error_dialogs replaced with
"Dismiss", to avoid collisions in translation of "Cancel" in other
places with this case.
* src/boxes.c: select_format() and it's support removed, as it is
obsoleted by input line history feature. display_init()/display_callback
fixed to suite i18n changes. sort_box() - alike.
* src/option.c: pause_options added &'s and gettext calls to expand
statically assigned values.
* src/widget.c: (radio_callback) hotkey recognition is changed to
&-notation, rather than simple uppercase.
* src/dlg.c: (dlg_try_hotkey) plain symbol comparison replaced with
call to isalpha(), this fixes errorneous exit from input line, when
button hotkey is 8-bit NLS char.
1998-04-04 00:00:00 +04:00
|
|
|
}
|
1998-02-27 07:54:42 +03:00
|
|
|
|
2002-09-13 20:29:32 +04:00
|
|
|
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,
|
2003-09-08 02:42:22 +04:00
|
|
|
dialog_colors, NULL, "[Configuration]",
|
2002-09-13 20:29:32 +04:00
|
|
|
_("Configure options"), DLG_CENTER);
|
1998-02-27 07:54:42 +03:00
|
|
|
|
2003-09-08 02:42:22 +04:00
|
|
|
add_widget (conf_dlg,
|
|
|
|
groupbox_new (PX, PY, first_width, PANEL_OPTIONS + 2, title1));
|
|
|
|
|
|
|
|
add_widget (conf_dlg,
|
|
|
|
groupbox_new (RX, RY, first_width, PAUSE_OPTIONS + 2, title2));
|
|
|
|
|
|
|
|
add_widget (conf_dlg,
|
|
|
|
groupbox_new (OX, OY, second_width, OTHER_OPTIONS + 2, title3));
|
|
|
|
|
2001-04-07 01:48:11 +04:00
|
|
|
add_widget (conf_dlg,
|
2002-09-13 20:29:32 +04:00
|
|
|
button_new (BY, b3, B_CANCEL, NORMAL_BUTTON,
|
2003-09-01 06:07:02 +04:00
|
|
|
cancel_button, 0));
|
1998-02-27 07:54:42 +03:00
|
|
|
|
2001-04-07 01:48:11 +04:00
|
|
|
add_widget (conf_dlg,
|
2002-09-13 20:29:32 +04:00
|
|
|
button_new (BY, b2, B_EXIT, NORMAL_BUTTON,
|
2003-09-01 06:07:02 +04:00
|
|
|
save_button, 0));
|
2002-09-13 20:29:32 +04:00
|
|
|
|
2001-04-07 01:48:11 +04:00
|
|
|
add_widget (conf_dlg,
|
2002-09-13 20:29:32 +04:00
|
|
|
button_new (BY, b1, B_ENTER, DEFPUSH_BUTTON,
|
2003-09-01 06:07:02 +04:00
|
|
|
ok_button, 0));
|
1998-02-27 07:54:42 +03:00
|
|
|
|
2003-09-01 04:18:37 +04:00
|
|
|
#define XTRACT(i) *check_options[i].variable, check_options[i].text
|
1998-02-27 07:54:42 +03:00
|
|
|
|
2002-09-13 20:29:32 +04:00
|
|
|
/* 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);
|
1998-02-27 07:54:42 +03:00
|
|
|
}
|
|
|
|
|
2002-09-13 20:29:32 +04:00
|
|
|
pause_radio =
|
2003-09-01 04:18:37 +04:00
|
|
|
radio_new (RY + 1, RX + 2, 3, pause_options, 1);
|
1998-02-27 07:54:42 +03:00
|
|
|
pause_radio->sel = pause_after_run;
|
2001-04-07 01:48:11 +04:00
|
|
|
add_widget (conf_dlg, pause_radio);
|
2002-09-13 20:29:32 +04:00
|
|
|
|
|
|
|
/* Add checkboxes for "panel options" */
|
|
|
|
for (i = 0; i < PANEL_OPTIONS; i++) {
|
|
|
|
check_options[i + OTHER_OPTIONS].widget =
|
2003-02-19 13:50:24 +03:00
|
|
|
check_new (PY + (PANEL_OPTIONS - i), PX + 2,
|
|
|
|
XTRACT (i + OTHER_OPTIONS));
|
2002-09-13 20:29:32 +04:00
|
|
|
add_widget (conf_dlg, check_options[i + OTHER_OPTIONS].widget);
|
1998-02-27 07:54:42 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void configure_box (void)
|
|
|
|
{
|
|
|
|
int result, i;
|
|
|
|
|
|
|
|
init_configure ();
|
|
|
|
run_dlg (conf_dlg);
|
|
|
|
|
|
|
|
result = conf_dlg->ret_value;
|
|
|
|
if (result == B_ENTER || result == B_EXIT){
|
|
|
|
for (i = 0; check_options [i].text; i++)
|
|
|
|
if (check_options [i].widget->state & C_CHANGE){
|
|
|
|
if (check_options [i].toggle_function)
|
|
|
|
(*check_options [i].toggle_function)();
|
|
|
|
else
|
|
|
|
*check_options [i].variable =
|
|
|
|
!(*check_options [i].variable);
|
|
|
|
}
|
|
|
|
pause_after_run = pause_radio->sel;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* If they pressed the save button */
|
|
|
|
if (result == B_EXIT){
|
|
|
|
save_configure ();
|
|
|
|
sync_profiles ();
|
|
|
|
}
|
|
|
|
|
|
|
|
destroy_dlg (conf_dlg);
|
|
|
|
}
|