2 Configure box module for the Midnight Commander
4 Copyright (C) 1994, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
5 2007, 2009, 2010, 2011, 2012
6 The Free Software Foundation, Inc.
8 This file is part of the Midnight Commander.
10 The Midnight Commander is free software: you can redistribute it
11 and/or modify it under the terms of the GNU General Public License as
12 published by the Free Software Foundation, either version 3 of the License,
13 or (at your option) any later version.
15 The Midnight Commander is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with this program. If not, see <http://www.gnu.org/licenses/>.
25 * \brief Source: configure boxes module
30 #include <stdlib.h> /* atoi() */
32 #include <sys/types.h>
35 #include "lib/global.h"
36 #include "lib/mcconfig.h"
37 #include "lib/strutil.h" /* str_term_width1() */
38 #include "lib/tty/key.h" /* old_esc_mode_timeout */
39 #include "lib/widget.h"
41 #include "src/setup.h" /* variables */
42 #include "src/history.h" /* MC_HISTORY_ESC_TIMEOUT */
43 #include "src/execute.h" /* pause_after_run */
45 #include "layout.h" /* nice_rotating_dash */
46 #include "panel.h" /* update_panels() */
50 /*** global variables ****************************************************************************/
52 /*** file scope macro definitions ****************************************************************/
54 /*** file scope type declarations ****************************************************************/
56 /*** file scope variables ************************************************************************/
58 unsigned long configure_old_esc_mode_id
, configure_time_out_id
;
60 /* --------------------------------------------------------------------------------------------- */
61 /*** file scope functions ************************************************************************/
62 /* --------------------------------------------------------------------------------------------- */
65 configure_callback (Widget
* w
, Widget
* sender
, widget_msg_t msg
, int parm
, void *data
)
70 /* message from "Single press" checkbutton */
71 if (sender
!= NULL
&& sender
->id
== configure_old_esc_mode_id
)
73 const gboolean not_single
= !(CHECK (sender
)->state
& C_BOOL
);
77 ww
= dlg_find_by_id (DIALOG (w
), configure_time_out_id
);
78 widget_disable (ww
, not_single
);
82 return MSG_NOT_HANDLED
;
85 return dlg_default_callback (w
, sender
, msg
, parm
, data
);
89 /* --------------------------------------------------------------------------------------------- */
90 /*** public functions ****************************************************************************/
91 /* --------------------------------------------------------------------------------------------- */
96 const char *pause_options
[] = {
98 N_("On dum&b terminals"),
102 int pause_options_num
;
105 pause_options_num
= G_N_ELEMENTS (pause_options
);
108 char time_out
[BUF_TINY
] = "";
111 quick_widget_t quick_widgets
[] = {
114 QUICK_START_GROUPBOX (N_("File operations")),
115 QUICK_CHECKBOX (N_("&Verbose operation"), &verbose
, NULL
),
116 QUICK_CHECKBOX (N_("Compute tota&ls"), &file_op_compute_totals
, NULL
),
117 QUICK_CHECKBOX (N_("Classic pro&gressbar"), &classic_progressbar
, NULL
),
118 QUICK_CHECKBOX (N_("Mkdi&r autoname"), &auto_fill_mkdir_name
, NULL
),
119 QUICK_CHECKBOX (N_("Preallocate &space"), &mc_global
.vfs
.preallocate_space
,
122 QUICK_START_GROUPBOX (N_("Esc key mode")),
123 QUICK_CHECKBOX (N_("S&ingle press"), &old_esc_mode
, &configure_old_esc_mode_id
),
124 QUICK_LABELED_INPUT (N_("Timeout:"), input_label_left
,
125 (const char *) time_out
, 0, MC_HISTORY_ESC_TIMEOUT
,
126 &time_out_new
, &configure_time_out_id
),
128 QUICK_START_GROUPBOX (N_("Pause after run")),
129 QUICK_RADIO (pause_options_num
, pause_options
, &pause_after_run
, NULL
),
132 QUICK_START_GROUPBOX (N_("Other options")),
133 QUICK_CHECKBOX (N_("Use internal edi&t"), &use_internal_edit
, NULL
),
134 QUICK_CHECKBOX (N_("Use internal vie&w"), &use_internal_view
, NULL
),
135 QUICK_CHECKBOX (N_("Auto m&enus"), &auto_menu
, NULL
),
136 QUICK_CHECKBOX (N_("&Drop down menus"), &drop_menus
, NULL
),
137 QUICK_CHECKBOX (N_("Shell &patterns"), &easy_patterns
, NULL
),
138 QUICK_CHECKBOX (N_("Co&mplete: show all"),
139 &mc_global
.widget
.show_all_if_ambiguous
, NULL
),
140 QUICK_CHECKBOX (N_("Rotating d&ash"), &nice_rotating_dash
, NULL
),
141 QUICK_CHECKBOX (N_("Cd follows lin&ks"), &mc_global
.vfs
.cd_symlinks
, NULL
),
142 QUICK_CHECKBOX (N_("Sa&fe delete"), &safe_delete
, NULL
),
143 QUICK_CHECKBOX (N_("A&uto save setup"), &auto_save_setup
, NULL
),
144 QUICK_SEPARATOR (FALSE
),
145 QUICK_SEPARATOR (FALSE
),
146 QUICK_SEPARATOR (FALSE
),
147 QUICK_SEPARATOR (FALSE
),
150 QUICK_BUTTONS_OK_CANCEL
,
155 quick_dialog_t qdlg
= {
157 N_("Configure options"), "[Configuration]",
158 quick_widgets
, configure_callback
, NULL
161 g_snprintf (time_out
, sizeof (time_out
), "%d", old_esc_mode_timeout
);
164 quick_widgets
[10].options
= quick_widgets
[11].options
= W_DISABLED
;
166 #ifndef HAVE_POSIX_FALLOCATE
167 mc_global
.vfs
.preallocate_space
= FALSE
;
168 quick_widgets
[7].options
= W_DISABLED
;
171 if (quick_dialog (&qdlg
) == B_ENTER
)
172 old_esc_mode_timeout
= atoi (time_out_new
);
174 g_free (time_out_new
);
178 /* --------------------------------------------------------------------------------------------- */
181 panel_options_box (void)
183 const char *qsearch_options
[] = {
184 N_("Case &insensitive"),
185 N_("Cas&e sensitive"),
186 N_("Use panel sort mo&de")
191 simple_swap
= mc_config_get_bool (mc_main_config
, CONFIG_PANELS_SECTION
,
192 "simple_swap", FALSE
) ? 1 : 0;
195 quick_widget_t quick_widgets
[] = {
198 QUICK_START_GROUPBOX (N_("Main options")),
199 QUICK_CHECKBOX (N_("Show mi&ni-status"), &panels_options
.show_mini_info
, NULL
),
200 QUICK_CHECKBOX (N_("Use SI si&ze units"), &panels_options
.kilobyte_si
, NULL
),
201 QUICK_CHECKBOX (N_("Mi&x all files"), &panels_options
.mix_all_files
, NULL
),
202 QUICK_CHECKBOX (N_("Show &backup files"), &panels_options
.show_backups
, NULL
),
203 QUICK_CHECKBOX (N_("Show &hidden files"), &panels_options
.show_dot_files
, NULL
),
204 QUICK_CHECKBOX (N_("&Fast dir reload"), &panels_options
.fast_reload
, NULL
),
205 QUICK_CHECKBOX (N_("Ma&rk moves down"), &panels_options
.mark_moves_down
, NULL
),
206 QUICK_CHECKBOX (N_("Re&verse files only"), &panels_options
.reverse_files_only
,
208 QUICK_CHECKBOX (N_("Simple s&wap"), &simple_swap
, NULL
),
209 QUICK_CHECKBOX (N_("A&uto save panels setup"), &panels_options
.auto_save_setup
,
211 QUICK_SEPARATOR (FALSE
),
212 QUICK_SEPARATOR (FALSE
),
215 QUICK_START_GROUPBOX (N_("Navigation")),
216 QUICK_CHECKBOX (N_("L&ynx-like motion"), &panels_options
.navigate_with_arrows
,
218 QUICK_CHECKBOX (N_("Pa&ge scrolling"), &panels_options
.scroll_pages
, NULL
),
219 QUICK_CHECKBOX (N_("&Mouse page scrolling"), &panels_options
.mouse_move_pages
,
222 QUICK_START_GROUPBOX (N_("File highlight")),
223 QUICK_CHECKBOX (N_("File &types"), &panels_options
.filetype_mode
, NULL
),
224 QUICK_CHECKBOX (N_("&Permissions"), &panels_options
.permission_mode
, NULL
),
226 QUICK_START_GROUPBOX (N_("Quick search")),
227 QUICK_RADIO (QSEARCH_NUM
, qsearch_options
, (int *) &panels_options
.qsearch_mode
,
231 QUICK_BUTTONS_OK_CANCEL
,
236 quick_dialog_t qdlg
= {
238 N_("Panel options"), "[Panel options]",
239 quick_widgets
, NULL
, NULL
242 if (quick_dialog (&qdlg
) != B_ENTER
)
246 mc_config_set_bool (mc_main_config
, CONFIG_PANELS_SECTION
,
247 "simple_swap", (gboolean
) (simple_swap
& C_BOOL
));
249 if (!panels_options
.fast_reload_msg_shown
&& panels_options
.fast_reload
)
251 message (D_NORMAL
, _("Information"),
252 _("Using the fast reload option may not reflect the exact\n"
253 "directory contents. In this case you'll need to do a\n"
254 "manual reload of the directory. See the man page for\n" "the details."));
255 panels_options
.fast_reload_msg_shown
= TRUE
;
258 update_panels (UP_RELOAD
, UP_KEEPSEL
);
261 /* --------------------------------------------------------------------------------------------- */