1 /* Configure box module for the Midnight Commander
2 Copyright (C) 1994 Radek Doulik
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 /* Needed for the extern declarations of integer parameters */
23 #include <sys/types.h>
24 #include <sys/param.h>
36 #include "setup.h" /* For save_setup() */
37 #include "dialog.h" /* For do_refresh() */
39 #include "profile.h" /* For sync_profiles */
42 #include "panel.h" /* Needed for the externs */
44 #include "layout.h" /* For nice_rotating_dash */
54 static Dlg_head
*conf_dlg
;
58 #define TOGGLE_VARIABLE 0
60 extern int use_internal_edit
;
64 static int OX
= 33, first_width
= 27, second_width
= 27;
65 static char *configure_title
, *title1
, *title2
, *title3
;
70 void (*toggle_function
)(void);
73 } check_options
[] = {
74 {N_("safe de&Lete"), &know_not_what_am_i_doing
, TOGGLE_VARIABLE
,0, "safe-del" },
75 {N_("cd follows lin&Ks"), &cd_symlinks
, TOGGLE_VARIABLE
, 0, "cd-follow" },
76 {N_("advanced cho&Wn"), &advanced_chfns
, TOGGLE_VARIABLE
, 0, "achown" },
77 {N_("l&Ynx-like motion"), &navigate_with_arrows
,TOGGLE_VARIABLE
, 0, "lynx" },
79 {N_("Animation"), &dummy
, TOGGLE_VARIABLE
, 0, "dummy" },
81 {N_("ro&Tating dash"), &nice_rotating_dash
,TOGGLE_VARIABLE
, 0, "rotating" },
83 {N_("co&Mplete: show all"),&show_all_if_ambiguous
,TOGGLE_VARIABLE
, 0, "completion" },
84 {N_("&Use internal view"), &use_internal_view
, TOGGLE_VARIABLE
, 0, "view-int" },
85 {N_("use internal ed&It"), &use_internal_edit
, TOGGLE_VARIABLE
, 0, "edit-int" },
86 {N_("auto m&Enus"), &auto_menu
, TOGGLE_VARIABLE
, 0, "auto-menus" },
87 {N_("&Auto save setup"), &auto_save_setup
, TOGGLE_VARIABLE
, 0, "auto-save" },
88 {N_("shell &Patterns"), &easy_patterns
, TOGGLE_VARIABLE
, 0, "shell-patt" },
89 {N_("&Verbose operation"), &verbose
, TOGGLE_VARIABLE
, 0, "verbose" },
90 {N_("&Fast dir reload"), &fast_reload
, toggle_fast_reload
, 0, "fast-reload" },
91 {N_("mi&X all files"), &mix_all_files
, toggle_mix_all_files
, 0, "mix-files" },
92 {N_("&Drop down menus"), &drop_menus
, TOGGLE_VARIABLE
, 0, "drop-menus" },
93 {N_("ma&Rk moves down"), &mark_moves_down
, TOGGLE_VARIABLE
, 0, "mark-moves" },
94 {N_("show &Hidden files"), &show_dot_files
, toggle_show_hidden
, 0, "show-hidden" },
95 {N_("show &Backup files"), &show_backups
, toggle_show_backup
, 0, "show-backup" },
99 static WRadio
*pause_radio
;
101 static char *pause_options
[3] = {
103 N_("on dumb &Terminals"),
106 static int configure_callback (struct Dlg_head
*h
, int Id
, int Msg
)
111 attrset (COLOR_NORMAL
);
113 draw_box (h
, 1, 2, h
->lines
- 2, h
->cols
- 4);
114 draw_box (h
, PY
, PX
, 8, first_width
);
115 draw_box (h
, RY
, RX
, 5, first_width
);
116 draw_box (h
, OY
, OX
, 14, second_width
);
118 attrset (COLOR_HOT_NORMAL
);
119 dlg_move (h
, 1, (h
->cols
- strlen(configure_title
))/2);
120 addstr (configure_title
);
121 dlg_move (h
, OY
, OX
+1);
123 dlg_move (h
, RY
, RX
+1);
125 dlg_move (h
, PY
, PX
+1);
137 static void init_configure (void)
140 static int i18n_config_flag
= 0;
141 static int b1
, b2
, b3
;
142 char* ok_button
= _("&Ok");
143 char* cancel_button
= _("&Cancel");
144 char* save_button
= _("&Save");
146 if (!i18n_config_flag
)
150 /* Similar code is in layout.c (init_layout()) */
152 configure_title
= _(" Configure options ");
153 title1
= _(" Panel options ");
154 title2
= _(" Pause after run... ");
155 title3
= _(" Other options ");
157 first_width
= strlen (title1
) + 1;
158 for (i
= 12; i
< 18; i
++)
160 check_options
[i
].text
= _(check_options
[i
].text
);
161 l1
= strlen (check_options
[i
].text
) + 7;
162 if (l1
> first_width
)
166 i
= sizeof(pause_options
)/sizeof(char*);
169 pause_options
[i
] = _(pause_options
[i
]);
170 l1
= strlen (pause_options
[i
]) + 7;
171 if (l1
> first_width
)
175 l1
= strlen (title2
) + 1;
176 if (l1
> first_width
)
179 OX
= first_width
+ 5;
181 second_width
= strlen (title3
) + 1;
182 for (i
= 0; i
< 12; i
++)
184 check_options
[i
].text
= _(check_options
[i
].text
);
185 l1
= strlen (check_options
[i
].text
) + 7;
186 if (l1
> second_width
)
190 l1
= 11 + strlen (ok_button
)
191 + strlen (save_button
)
192 + strlen (cancel_button
);
194 i
= (first_width
+ second_width
- l1
) / 4;
196 b2
= b1
+ strlen(ok_button
) + i
+ 6;
197 b3
= b2
+ strlen(save_button
) + i
+ 4;
199 i18n_config_flag
= 1;
202 conf_dlg
= create_dlg (0, 0, 19, first_width
+ second_width
+ 9,
203 dialog_colors
, configure_callback
, "[Options Menu]",
204 "option", DLG_CENTER
| DLG_GRID
);
206 x_set_dialog_title (conf_dlg
, _("Configure options"));
208 add_widgetl (conf_dlg
,
209 button_new (BY
, b3
, B_CANCEL
, NORMAL_BUTTON
, cancel_button
, 0, 0, "button-cancel"),
212 add_widgetl (conf_dlg
,
213 button_new (BY
, b2
, B_EXIT
, NORMAL_BUTTON
, save_button
, 0, 0, "button-save"),
216 add_widgetl (conf_dlg
,
217 button_new (BY
, b1
, B_ENTER
, DEFPUSH_BUTTON
, ok_button
, 0, 0, "button-ok"),
220 #define XTRACT(i) *check_options[i].variable, check_options[i].text, check_options [i].tk
222 /* Add all the checkboxes */
223 for (i
= 0; i
< 12; i
++){
224 check_options
[i
].widget
= check_new (OY
+ (12-i
), OX
+2, XTRACT(i
));
225 add_widgetl (conf_dlg
, check_options
[i
].widget
,
229 pause_radio
= radio_new (RY
+1, RX
+2, 3, pause_options
, 1, "pause-radio");
230 pause_radio
->sel
= pause_after_run
;
232 add_widgetl (conf_dlg
, pause_radio
, XV_WLAY_BELOWCLOSE
);
234 for (i
= 0; i
< 6; i
++){
235 check_options
[i
+12].widget
= check_new (PY
+ (6-i
), PX
+2,
237 add_widgetl (conf_dlg
, check_options
[i
+12].widget
,
241 add_widgetl (conf_dlg
, label_new (OY
, OX
+ 1, _("Other options"), "label-other"),
243 add_widgetl (conf_dlg
, label_new (RY
, RX
+ 1, _("Pause after run..."), "label-pause"),
245 add_widgetl (conf_dlg
, label_new (PY
, PX
+ 1, _("Panel options"), "label-panel"),
251 void configure_box (void)
258 result
= conf_dlg
->ret_value
;
259 if (result
== B_ENTER
|| result
== B_EXIT
){
260 for (i
= 0; check_options
[i
].text
; i
++)
261 if (check_options
[i
].widget
->state
& C_CHANGE
){
262 if (check_options
[i
].toggle_function
)
263 (*check_options
[i
].toggle_function
)();
265 *check_options
[i
].variable
=
266 !(*check_options
[i
].variable
);
268 pause_after_run
= pause_radio
->sel
;
271 /* If they pressed the save button */
272 if (result
== B_EXIT
){
277 destroy_dlg (conf_dlg
);