Ticket #2841: adjust i18n label sizes in learn key dialog.
[midnight-commander.git] / src / filemanager / option.c
blob1894858d29a877e7eb902899e729ecfe7b8eed53
1 /*
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/>.
24 /** \file option.c
25 * \brief Source: configure boxes module
28 #include <config.h>
30 #include <stdlib.h> /* atoi() */
32 #include <sys/types.h>
33 #include <unistd.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() */
48 #include "option.h"
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 /* --------------------------------------------------------------------------------------------- */
64 static cb_ret_t
65 configure_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void *data)
67 switch (msg)
69 case MSG_ACTION:
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);
74 Widget *ww;
76 /* input line */
77 ww = dlg_find_by_id (DIALOG (w), configure_time_out_id);
78 widget_disable (ww, not_single);
80 return MSG_HANDLED;
82 return MSG_NOT_HANDLED;
84 default:
85 return dlg_default_callback (w, sender, msg, parm, data);
89 /* --------------------------------------------------------------------------------------------- */
90 /*** public functions ****************************************************************************/
91 /* --------------------------------------------------------------------------------------------- */
93 void
94 configure_box (void)
96 const char *pause_options[] = {
97 N_("&Never"),
98 N_("On dum&b terminals"),
99 N_("Alwa&ys")
102 int pause_options_num;
105 pause_options_num = G_N_ELEMENTS (pause_options);
108 char time_out[BUF_TINY] = "";
109 char *time_out_new;
111 quick_widget_t quick_widgets[] = {
112 /* *INDENT-OFF* */
113 QUICK_START_COLUMNS,
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,
120 NULL),
121 QUICK_STOP_GROUPBOX,
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),
127 QUICK_STOP_GROUPBOX,
128 QUICK_START_GROUPBOX (N_("Pause after run")),
129 QUICK_RADIO (pause_options_num, pause_options, &pause_after_run, NULL),
130 QUICK_STOP_GROUPBOX,
131 QUICK_NEXT_COLUMN,
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),
148 QUICK_STOP_GROUPBOX,
149 QUICK_STOP_COLUMNS,
150 QUICK_BUTTONS_OK_CANCEL,
151 QUICK_END
152 /* *INDENT-ON* */
155 quick_dialog_t qdlg = {
156 -1, -1, 60,
157 N_("Configure options"), "[Configuration]",
158 quick_widgets, configure_callback, NULL
161 g_snprintf (time_out, sizeof (time_out), "%d", old_esc_mode_timeout);
163 if (!old_esc_mode)
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;
169 #endif
171 if (quick_dialog (&qdlg) == B_ENTER)
172 old_esc_mode_timeout = atoi (time_out_new);
174 g_free (time_out_new);
178 /* --------------------------------------------------------------------------------------------- */
180 void
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")
189 int simple_swap;
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[] = {
196 /* *INDENT-OFF* */
197 QUICK_START_COLUMNS,
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,
207 NULL),
208 QUICK_CHECKBOX (N_("Simple s&wap"), &simple_swap, NULL),
209 QUICK_CHECKBOX (N_("A&uto save panels setup"), &panels_options.auto_save_setup,
210 NULL),
211 QUICK_SEPARATOR (FALSE),
212 QUICK_SEPARATOR (FALSE),
213 QUICK_STOP_GROUPBOX,
214 QUICK_NEXT_COLUMN,
215 QUICK_START_GROUPBOX (N_("Navigation")),
216 QUICK_CHECKBOX (N_("L&ynx-like motion"), &panels_options.navigate_with_arrows,
217 NULL),
218 QUICK_CHECKBOX (N_("Pa&ge scrolling"), &panels_options.scroll_pages, NULL),
219 QUICK_CHECKBOX (N_("&Mouse page scrolling"), &panels_options.mouse_move_pages,
220 NULL),
221 QUICK_STOP_GROUPBOX,
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),
225 QUICK_STOP_GROUPBOX,
226 QUICK_START_GROUPBOX (N_("Quick search")),
227 QUICK_RADIO (QSEARCH_NUM, qsearch_options, (int *) &panels_options.qsearch_mode,
228 NULL),
229 QUICK_STOP_GROUPBOX,
230 QUICK_STOP_COLUMNS,
231 QUICK_BUTTONS_OK_CANCEL,
232 QUICK_END
233 /* *INDENT-ON* */
236 quick_dialog_t qdlg = {
237 -1, -1, 60,
238 N_("Panel options"), "[Panel options]",
239 quick_widgets, NULL, NULL
242 if (quick_dialog (&qdlg) != B_ENTER)
243 return;
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 /* --------------------------------------------------------------------------------------------- */