Removed useless return.
[midnight-commander.git] / src / setup.c
blobda15e2cf57399b8240f4b8358e562b0ac23611f0
1 /*
2 Setup loading/saving.
4 Copyright (C) 1994, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
5 2006, 2007, 2009, 2010, 2011
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 setup.c
25 * \brief Source: setup loading/saving
28 #include <config.h>
30 #include <stdlib.h>
31 #include <string.h>
32 #include <stdio.h>
33 #include <sys/types.h>
34 #include <sys/stat.h>
36 #include "lib/global.h"
38 #include "lib/tty/tty.h"
39 #include "lib/tty/key.h"
40 #include "lib/mcconfig.h"
41 #include "lib/fileloc.h"
42 #include "lib/timefmt.h"
43 #include "lib/util.h"
44 #include "lib/widget.h"
46 #include "lib/vfs/vfs.h"
48 #ifdef ENABLE_VFS_FTP
49 #include "src/vfs/ftpfs/ftpfs.h"
50 #endif
51 #ifdef ENABLE_VFS_FISH
52 #include "src/vfs/fish/fish.h"
53 #endif
55 #ifdef HAVE_CHARSET
56 #include "lib/charsets.h"
57 #endif
59 #include "filemanager/dir.h"
60 #include "filemanager/midnight.h"
61 #include "filemanager/tree.h" /* xtree_mode */
62 #include "filemanager/hotlist.h" /* load/save/done hotlist */
63 #include "filemanager/panelize.h" /* load/save/done panelize */
64 #include "filemanager/layout.h"
65 #include "filemanager/cmd.h"
67 #include "args.h"
68 #include "execute.h" /* pause_after_run */
69 #include "clipboard.h"
70 #include "keybind-defaults.h" /* keybind_lookup_action */
72 #ifdef HAVE_CHARSET
73 #include "selcodepage.h"
74 #endif
76 #ifdef USE_INTERNAL_EDIT
77 #include "src/editor/edit.h"
78 #endif
80 #include "src/viewer/mcviewer.h" /* For the externs */
82 #include "setup.h"
84 /*** global variables ****************************************************************************/
86 char *profile_name; /* ${XDG_CONFIG_HOME}/mc/ini */
87 char *global_profile_name; /* mc.lib */
89 /* Only used at program boot */
90 gboolean boot_current_is_left = TRUE;
92 /* If on, default for "No" in delete operations */
93 int safe_delete = 0;
95 /* Controls screen clearing before an exec */
96 int clear_before_exec = 1;
98 /* Asks for confirmation before deleting a file */
99 int confirm_delete = 1;
100 /* Asks for confirmation before deleting a hotlist entry */
101 int confirm_directory_hotlist_delete = 1;
102 /* Asks for confirmation before overwriting a file */
103 int confirm_overwrite = 1;
104 /* Asks for confirmation before executing a program by pressing enter */
105 int confirm_execute = 0;
106 /* Asks for confirmation before leaving the program */
107 int confirm_exit = 1;
109 /* If true, at startup the user-menu is invoked */
110 int auto_menu = 0;
111 /* This flag indicates if the pull down menus by default drop down */
112 int drop_menus = 0;
114 /* Asks for confirmation when using F3 to view a directory and there
115 are tagged files */
116 int confirm_view_dir = 0;
118 panel_view_mode_t startup_left_mode;
119 panel_view_mode_t startup_right_mode;
121 int setup_copymove_persistent_attr = 1;
123 /* Tab size */
124 int option_tab_spacing = DEFAULT_TAB_SPACING;
126 /* Ugly hack to allow panel_save_setup to work as a place holder for */
127 /* default panel values */
128 int saving_setup;
130 panels_options_t panels_options = {
131 .show_mini_info = TRUE,
132 .kilobyte_si = FALSE,
133 .mix_all_files = FALSE,
134 .show_backups = TRUE,
135 .show_dot_files = TRUE,
136 .fast_reload = FALSE,
137 .fast_reload_msg_shown = FALSE,
138 .mark_moves_down = TRUE,
139 .reverse_files_only = TRUE,
140 .auto_save_setup = FALSE,
141 .navigate_with_arrows = FALSE,
142 .scroll_pages = TRUE,
143 .mouse_move_pages = TRUE,
144 .filetype_mode = TRUE,
145 .permission_mode = FALSE,
146 .qsearch_mode = QSEARCH_PANEL_CASE,
147 .torben_fj_mode = FALSE
150 int easy_patterns = 1;
152 /* It true saves the setup when quitting */
153 int auto_save_setup = 1;
155 /* If true, then the +, - and \ keys have their special meaning only if the
156 * command line is emtpy, otherwise they behave like regular letters
158 int only_leading_plus_minus = 1;
160 /* Automatically fills name with current selected item name on mkdir */
161 int auto_fill_mkdir_name = 1;
163 /* If set and you don't have subshell support,then C-o will give you a shell */
164 int output_starts_shell = 0;
166 /* If set, we execute the file command to check the file type */
167 int use_file_to_check_type = 1;
169 int verbose = 1;
172 * Whether the Midnight Commander tries to provide more
173 * information about copy/move sizes and bytes transfered
174 * at the expense of some speed
176 int file_op_compute_totals = 1;
178 /*** file scope macro definitions ****************************************************************/
180 /* In order to use everywhere the same setup for the locale we use defines */
181 #define FMTYEAR _("%b %e %Y")
182 #define FMTTIME _("%b %e %H:%M")
184 /*** file scope type declarations ****************************************************************/
186 /*** file scope variables ************************************************************************/
188 static char *panels_profile_name = NULL; /* ${XDG_CACHE_HOME}/mc/panels.ini */
190 /* *INDENT-OFF* */
191 static const struct
193 const char *key;
194 int list_type;
195 } list_types [] = {
196 { "full", list_full },
197 { "brief", list_brief },
198 { "long", list_long },
199 { "user", list_user },
200 { NULL, 0 }
203 static const struct
205 const char *opt_name;
206 panel_view_mode_t opt_type;
207 } panel_types [] = {
208 { "listing", view_listing },
209 { "quickview", view_quick },
210 { "info", view_info },
211 { "tree", view_tree },
212 { NULL, view_listing }
215 static const struct
217 const char *opt_name;
218 int *opt_addr;
219 } layout [] = {
220 { "message_visible", &mc_global.message_visible },
221 { "keybar_visible", &mc_global.keybar_visible },
222 { "xterm_title", &xterm_title },
223 { "output_lines", &output_lines },
224 { "command_prompt", &command_prompt },
225 { "menubar_visible", &menubar_visible },
226 { "free_space", &free_space },
227 { "horizontal_split", &panels_layout.horizontal_split },
228 { "vertical_equal", &panels_layout.vertical_equal },
229 { "left_panel_size", &panels_layout.left_panel_size },
230 { "horizontal_equal", &panels_layout.horizontal_equal },
231 { "top_panel_size", &panels_layout.top_panel_size },
232 { NULL, NULL }
235 static const struct
237 const char *opt_name;
238 int *opt_addr;
239 } int_options [] = {
240 { "verbose", &verbose },
241 { "pause_after_run", &pause_after_run },
242 { "shell_patterns", &easy_patterns },
243 { "auto_save_setup", &auto_save_setup },
244 { "preallocate_space", &mc_global.vfs.preallocate_space },
245 { "auto_menu", &auto_menu },
246 { "use_internal_view", &use_internal_view },
247 { "use_internal_edit", &use_internal_edit },
248 { "clear_before_exec", &clear_before_exec },
249 { "confirm_delete", &confirm_delete },
250 { "confirm_overwrite", &confirm_overwrite },
251 { "confirm_execute", &confirm_execute },
252 { "confirm_history_cleanup", &mc_global.widget.confirm_history_cleanup },
253 { "confirm_exit", &confirm_exit },
254 { "confirm_directory_hotlist_delete", &confirm_directory_hotlist_delete },
255 { "safe_delete", &safe_delete },
256 { "mouse_repeat_rate", &mou_auto_repeat },
257 { "double_click_speed", &double_click_speed },
258 #ifndef HAVE_CHARSET
259 { "eight_bit_clean", &mc_global.eight_bit_clean },
260 { "full_eight_bits", &mc_global.full_eight_bits },
261 #endif /* !HAVE_CHARSET */
262 { "use_8th_bit_as_meta", &use_8th_bit_as_meta },
263 { "confirm_view_dir", &confirm_view_dir },
264 { "mouse_move_pages_viewer", &mcview_mouse_move_pages },
265 { "mouse_close_dialog", &mouse_close_dialog},
266 { "fast_refresh", &fast_refresh },
267 { "drop_menus", &drop_menus },
268 { "wrap_mode", &mcview_global_wrap_mode},
269 { "old_esc_mode", &old_esc_mode },
270 { "old_esc_mode_timeout", &old_esc_mode_timeout },
271 { "cd_symlinks", &mc_global.vfs.cd_symlinks },
272 { "show_all_if_ambiguous", &mc_global.widget.show_all_if_ambiguous },
273 { "max_dirt_limit", &mcview_max_dirt_limit },
274 { "use_file_to_guess_type", &use_file_to_check_type },
275 { "alternate_plus_minus", &mc_global.tty.alternate_plus_minus },
276 { "only_leading_plus_minus", &only_leading_plus_minus },
277 { "show_output_starts_shell", &output_starts_shell },
278 { "xtree_mode", &xtree_mode },
279 { "num_history_items_recorded", &num_history_items_recorded },
280 { "file_op_compute_totals", &file_op_compute_totals },
281 { "classic_progressbar", &classic_progressbar},
282 #ifdef ENABLE_VFS
283 { "vfs_timeout", &vfs_timeout },
284 #ifdef ENABLE_VFS_FTP
285 { "ftpfs_directory_timeout", &ftpfs_directory_timeout },
286 { "use_netrc", &ftpfs_use_netrc },
287 { "ftpfs_retry_seconds", &ftpfs_retry_seconds },
288 { "ftpfs_always_use_proxy", &ftpfs_always_use_proxy },
289 { "ftpfs_use_passive_connections", &ftpfs_use_passive_connections },
290 { "ftpfs_use_passive_connections_over_proxy", &ftpfs_use_passive_connections_over_proxy },
291 { "ftpfs_use_unix_list_options", &ftpfs_use_unix_list_options },
292 { "ftpfs_first_cd_then_ls", &ftpfs_first_cd_then_ls },
293 #endif /* ENABLE_VFS_FTP */
294 #ifdef ENABLE_VFS_FISH
295 { "fish_directory_timeout", &fish_directory_timeout },
296 #endif /* ENABLE_VFS_FISH */
297 #endif /* ENABLE_VFS */
298 /* option_tab_spacing is used in internal viewer */
299 { "editor_tab_spacing", &option_tab_spacing },
300 #ifdef USE_INTERNAL_EDIT
301 { "editor_word_wrap_line_length", &option_word_wrap_line_length },
302 { "editor_fill_tabs_with_spaces", &option_fill_tabs_with_spaces },
303 { "editor_return_does_auto_indent", &option_return_does_auto_indent },
304 { "editor_backspace_through_tabs", &option_backspace_through_tabs },
305 { "editor_fake_half_tabs", &option_fake_half_tabs },
306 { "editor_option_save_mode", &option_save_mode },
307 { "editor_option_save_position", &option_save_position },
308 { "editor_option_auto_para_formatting", &option_auto_para_formatting },
309 { "editor_option_typewriter_wrap", &option_typewriter_wrap },
310 { "editor_edit_confirm_save", &edit_confirm_save },
311 { "editor_syntax_highlighting", &option_syntax_highlighting },
312 { "editor_persistent_selections", &option_persistent_selections },
313 { "editor_cursor_beyond_eol", &option_cursor_beyond_eol },
314 { "editor_visible_tabs", &visible_tabs },
315 { "editor_visible_spaces", &visible_tws },
316 { "editor_line_state", &option_line_state },
317 { "editor_simple_statusbar", &simple_statusbar },
318 { "editor_check_new_line", &option_check_nl_at_eof },
319 { "editor_show_right_margin", &show_right_margin },
320 { "editor_group_undo", &option_group_undo },
321 #endif /* USE_INTERNAL_EDIT */
322 { "nice_rotating_dash", &nice_rotating_dash },
323 { "mcview_remember_file_position", &mcview_remember_file_position },
324 { "auto_fill_mkdir_name", &auto_fill_mkdir_name },
325 { "copymove_persistent_attr", &setup_copymove_persistent_attr },
326 { "select_flags", &select_flags },
327 { NULL, NULL }
330 static const struct
332 const char *opt_name;
333 char **opt_addr;
334 const char *opt_defval;
335 } str_options[] = {
336 #ifdef USE_INTERNAL_EDIT
337 { "editor_backup_extension", &option_backup_ext, "~" },
338 #endif
339 { "mcview_eof", &mcview_show_eof, "" },
340 { NULL, NULL, NULL }
343 static const struct
345 const char *opt_name;
346 gboolean *opt_addr;
347 } panels_ini_options[] = {
348 { "show_mini_info", &panels_options.show_mini_info },
349 { "kilobyte_si", &panels_options.kilobyte_si },
350 { "mix_all_files", &panels_options.mix_all_files },
351 { "show_backups", &panels_options.show_backups },
352 { "show_dot_files", &panels_options.show_dot_files },
353 { "fast_reload", &panels_options.fast_reload },
354 { "fast_reload_msg_shown", &panels_options.fast_reload_msg_shown },
355 { "mark_moves_down", &panels_options.mark_moves_down },
356 { "reverse_files_only", &panels_options.reverse_files_only },
357 { "auto_save_setup_panels", &panels_options.auto_save_setup },
358 { "navigate_with_arrows", &panels_options.navigate_with_arrows },
359 { "panel_scroll_pages", &panels_options.scroll_pages },
360 { "mouse_move_pages", &panels_options.mouse_move_pages },
361 { "filetype_mode", &panels_options.filetype_mode },
362 { "permission_mode", &panels_options.permission_mode },
363 { "torben_fj_mode", &panels_options.torben_fj_mode },
364 { NULL, NULL }
366 /* *INDENT-ON* */
368 /*** file scope functions ************************************************************************/
369 /* --------------------------------------------------------------------------------------------- */
372 Get name of config file.
374 \param subdir
375 if not NULL, then config also search into specified subdir.
377 \param config_file_name
378 If specified filename is relative, then will search in standart patches.
380 \return
381 Newly allocated path to config name or NULL if file not found.
383 If config_file_name is a relative path, then search config in stantart paths.
385 static char *
386 load_setup_get_full_config_name (const char *subdir, const char *config_file_name)
389 TODO: IMHO, in future this function must be placed into mc_config module.
391 char *lc_basename, *ret;
393 if (config_file_name == NULL)
394 return NULL;
396 if (g_path_is_absolute (config_file_name))
397 return g_strdup (config_file_name);
400 lc_basename = g_path_get_basename (config_file_name);
401 if (lc_basename == NULL)
402 return NULL;
404 if (subdir != NULL)
405 ret = g_build_filename (mc_config_get_path (), subdir, lc_basename, NULL);
406 else
407 ret = g_build_filename (mc_config_get_path (), lc_basename, NULL);
409 if (exist_file (ret))
411 g_free (lc_basename);
412 return ret;
414 g_free (ret);
416 if (subdir != NULL)
417 ret = g_build_filename (mc_global.sysconfig_dir, subdir, lc_basename, NULL);
418 else
419 ret = g_build_filename (mc_global.sysconfig_dir, lc_basename, NULL);
421 if (exist_file (ret))
423 g_free (lc_basename);
424 return ret;
426 g_free (ret);
428 if (subdir != NULL)
429 ret = g_build_filename (mc_global.share_data_dir, subdir, lc_basename, NULL);
430 else
431 ret = g_build_filename (mc_global.share_data_dir, lc_basename, NULL);
433 g_free (lc_basename);
435 if (exist_file (ret))
436 return ret;
438 g_free (ret);
439 return NULL;
443 /* --------------------------------------------------------------------------------------------- */
445 static const char *
446 setup__is_cfg_group_must_panel_config (const char *grp)
448 return (!strcasecmp ("Dirs", grp) ||
449 !strcasecmp ("Temporal:New Right Panel", grp) ||
450 !strcasecmp ("Temporal:New Left Panel", grp) ||
451 !strcasecmp ("New Left Panel", grp) || !strcasecmp ("New Right Panel", grp))
452 ? grp : NULL;
455 /* --------------------------------------------------------------------------------------------- */
457 static void
458 setup__move_panels_config_into_separate_file (const char *profile)
460 mc_config_t *tmp_cfg;
461 char **groups, **curr_grp;
462 const char *need_grp;
464 if (!exist_file (profile))
465 return;
467 tmp_cfg = mc_config_init (profile);
468 if (!tmp_cfg)
469 return;
471 curr_grp = groups = mc_config_get_groups (tmp_cfg, NULL);
472 if (!groups)
474 mc_config_deinit (tmp_cfg);
475 return;
478 while (*curr_grp)
480 if (setup__is_cfg_group_must_panel_config (*curr_grp) == NULL)
481 mc_config_del_group (tmp_cfg, *curr_grp);
482 curr_grp++;
485 mc_config_save_to_file (tmp_cfg, panels_profile_name, NULL);
486 mc_config_deinit (tmp_cfg);
488 tmp_cfg = mc_config_init (profile);
489 if (!tmp_cfg)
491 g_strfreev (groups);
492 return;
495 curr_grp = groups;
497 while (*curr_grp)
499 need_grp = setup__is_cfg_group_must_panel_config (*curr_grp);
500 if (need_grp != NULL)
502 mc_config_del_group (tmp_cfg, need_grp);
504 curr_grp++;
506 g_strfreev (groups);
508 mc_config_save_file (tmp_cfg, NULL);
509 mc_config_deinit (tmp_cfg);
512 /* --------------------------------------------------------------------------------------------- */
514 Create new mc_config object from specified ini-file or
515 append data to existing mc_config object from ini-file
518 static void
519 load_setup_init_config_from_file (mc_config_t ** config, const char *fname)
522 TODO: IMHO, in future this function must be placed into mc_config module.
524 if (exist_file (fname))
526 if (*config != NULL)
527 mc_config_read_file (*config, fname, TRUE);
528 else
529 *config = mc_config_init (fname);
533 /* --------------------------------------------------------------------------------------------- */
535 static void
536 load_layout (void)
538 size_t i;
539 int equal_split;
540 int first_panel_size;
542 /* legacy options */
543 panels_layout.horizontal_split = mc_config_get_int (mc_main_config, CONFIG_APP_SECTION,
544 "horizontal_split", 0);
545 equal_split = mc_config_get_int (mc_main_config, "Layout", "equal_split", 1);
546 first_panel_size = mc_config_get_int (mc_main_config, "Layout", "first_panel_size", 1);
547 if (panels_layout.horizontal_split)
549 panels_layout.horizontal_equal = equal_split;
550 panels_layout.left_panel_size = first_panel_size;
552 else
554 panels_layout.vertical_equal = equal_split;
555 panels_layout.top_panel_size = first_panel_size;
558 /* actual options override legacy ones */
559 for (i = 0; layout[i].opt_name != NULL; i++)
560 *layout[i].opt_addr = mc_config_get_int (mc_main_config, "Layout",
561 layout[i].opt_name, *layout[i].opt_addr);
563 /* remove legacy options */
564 mc_config_del_key (mc_main_config, CONFIG_APP_SECTION, "horizontal_split");
565 mc_config_del_key (mc_main_config, "Layout", "equal_split");
566 mc_config_del_key (mc_main_config, "Layout", "first_panel_size");
569 /* --------------------------------------------------------------------------------------------- */
571 static void
572 load_keys_from_section (const char *terminal, mc_config_t * cfg)
574 char *section_name;
575 gchar **profile_keys, **keys;
576 gchar **values, **curr_values;
577 char *valcopy, *value;
578 long key_code;
579 gsize len, values_len;
581 if (terminal == NULL)
582 return;
584 section_name = g_strconcat ("terminal:", terminal, (char *) NULL);
585 profile_keys = keys = mc_config_get_keys (cfg, section_name, &len);
587 while (*profile_keys != NULL)
589 /* copy=other causes all keys from [terminal:other] to be loaded. */
590 if (g_ascii_strcasecmp (*profile_keys, "copy") == 0)
592 valcopy = mc_config_get_string (cfg, section_name, *profile_keys, "");
593 load_keys_from_section (valcopy, cfg);
594 g_free (valcopy);
595 profile_keys++;
596 continue;
599 curr_values = values =
600 mc_config_get_string_list (cfg, section_name, *profile_keys, &values_len);
602 key_code = lookup_key (*profile_keys, NULL);
604 if (key_code != 0)
606 if (curr_values != NULL)
608 while (*curr_values != NULL)
610 valcopy = convert_controls (*curr_values);
611 define_sequence (key_code, valcopy, MCKEY_NOACTION);
612 g_free (valcopy);
613 curr_values++;
616 else
618 value = mc_config_get_string (cfg, section_name, *profile_keys, "");
619 valcopy = convert_controls (value);
620 define_sequence (key_code, valcopy, MCKEY_NOACTION);
621 g_free (valcopy);
622 g_free (value);
626 profile_keys++;
627 g_strfreev (values);
629 g_strfreev (keys);
630 g_free (section_name);
633 /* --------------------------------------------------------------------------------------------- */
635 static void
636 load_keymap_from_section (const char *section_name, GArray * keymap, mc_config_t * cfg)
638 gchar **profile_keys, **keys;
639 gsize len;
641 if (section_name == NULL)
642 return;
644 profile_keys = keys = mc_config_get_keys (cfg, section_name, &len);
646 while (*profile_keys != NULL)
648 gchar **values, **curr_values;
650 curr_values = values = mc_config_get_string_list (cfg, section_name, *profile_keys, &len);
652 if (curr_values != NULL)
654 int action;
656 action = keybind_lookup_action (*profile_keys);
657 if (action > 0)
658 while (*curr_values != NULL)
660 keybind_cmd_bind (keymap, *curr_values, action);
661 curr_values++;
664 g_strfreev (values);
667 profile_keys++;
670 g_strfreev (keys);
673 /* --------------------------------------------------------------------------------------------- */
675 static mc_config_t *
676 load_setup_get_keymap_profile_config (gboolean load_from_file)
679 TODO: IMHO, in future this function must be placed into mc_config module.
681 mc_config_t *keymap_config;
682 char *fname, *fname2;
684 /* 0) Create default keymap */
685 keymap_config = create_default_keymap ();
686 if (!load_from_file)
687 return keymap_config;
689 /* 1) /usr/share/mc (mc_global.share_data_dir) */
690 fname = g_build_filename (mc_global.share_data_dir, GLOBAL_KEYMAP_FILE, NULL);
691 load_setup_init_config_from_file (&keymap_config, fname);
692 g_free (fname);
694 /* 2) /etc/mc (mc_global.sysconfig_dir) */
695 fname = g_build_filename (mc_global.sysconfig_dir, GLOBAL_KEYMAP_FILE, NULL);
696 load_setup_init_config_from_file (&keymap_config, fname);
697 g_free (fname);
699 /* 3) ${XDG_CONFIG_HOME}/mc */
700 fname = mc_config_get_full_path (GLOBAL_KEYMAP_FILE);
701 load_setup_init_config_from_file (&keymap_config, fname);
702 g_free (fname);
704 /* 4) main config; [Midnight Commander] -> keymap */
705 fname2 =
706 mc_config_get_string (mc_main_config, CONFIG_APP_SECTION, "keymap", GLOBAL_KEYMAP_FILE);
707 fname = load_setup_get_full_config_name (NULL, fname2);
708 if (fname != NULL)
710 load_setup_init_config_from_file (&keymap_config, fname);
711 g_free (fname);
713 g_free (fname2);
715 /* 5) getenv("MC_KEYMAP") */
716 fname = load_setup_get_full_config_name (NULL, g_getenv ("MC_KEYMAP"));
717 if (fname != NULL)
719 load_setup_init_config_from_file (&keymap_config, fname);
720 g_free (fname);
723 /* 6) --keymap=<keymap> */
724 fname = load_setup_get_full_config_name (NULL, mc_args__keymap_file);
725 if (fname != NULL)
727 load_setup_init_config_from_file (&keymap_config, fname);
728 g_free (fname);
731 return keymap_config;
734 /* --------------------------------------------------------------------------------------------- */
736 static panel_view_mode_t
737 setup__load_panel_state (const char *section)
739 char *buffer;
740 size_t i;
741 panel_view_mode_t mode = view_listing;
743 /* Load the display mode */
744 buffer = mc_config_get_string (mc_panels_config, section, "display", "listing");
746 for (i = 0; panel_types[i].opt_name != NULL; i++)
747 if (g_ascii_strcasecmp (panel_types[i].opt_name, buffer) == 0)
749 mode = panel_types[i].opt_type;
750 break;
753 g_free (buffer);
755 return mode;
758 /* --------------------------------------------------------------------------------------------- */
760 static void
761 panel_save_type (const char *section, panel_view_mode_t type)
763 size_t i;
765 for (i = 0; panel_types[i].opt_name != NULL; i++)
766 if (panel_types[i].opt_type == type)
768 mc_config_set_string (mc_panels_config, section, "display", panel_types[i].opt_name);
769 break;
773 /* --------------------------------------------------------------------------------------------- */
775 /* save panels.ini */
776 static void
777 save_panel_types (void)
779 panel_view_mode_t type;
781 if (mc_global.mc_run_mode != MC_RUN_FULL)
782 return;
784 type = get_display_type (0);
785 panel_save_type ("New Left Panel", type);
786 if (type == view_listing)
787 panel_save_setup (left_panel, left_panel->panel_name);
788 type = get_display_type (1);
789 panel_save_type ("New Right Panel", type);
790 if (type == view_listing)
791 panel_save_setup (right_panel, right_panel->panel_name);
794 char *dirs;
796 dirs = get_panel_dir_for (other_panel);
797 mc_config_set_string (mc_panels_config, "Dirs", "other_dir", dirs);
798 g_free (dirs);
801 if (current_panel != NULL)
802 mc_config_set_string (mc_panels_config, "Dirs", "current_is_left",
803 get_current_index () == 0 ? "1" : "0");
805 if (mc_panels_config->ini_path == NULL)
806 mc_panels_config->ini_path = g_strdup (panels_profile_name);
808 mc_config_del_group (mc_panels_config, "Temporal:New Left Panel");
809 mc_config_del_group (mc_panels_config, "Temporal:New Right Panel");
811 mc_config_save_file (mc_panels_config, NULL);
814 /* --------------------------------------------------------------------------------------------- */
815 /*** public functions ****************************************************************************/
816 /* --------------------------------------------------------------------------------------------- */
818 char *
819 setup_init (void)
821 char *profile;
822 char *inifile;
824 if (profile_name != NULL)
825 return profile_name;
827 profile = mc_config_get_full_path (MC_CONFIG_FILE);
828 if (!exist_file (profile))
830 inifile = mc_build_filename (mc_global.sysconfig_dir, "mc.ini", NULL);
831 if (exist_file (inifile))
833 g_free (profile);
834 profile = inifile;
836 else
838 g_free (inifile);
839 inifile = mc_build_filename (mc_global.share_data_dir, "mc.ini", NULL);
840 if (exist_file (inifile))
842 g_free (profile);
843 profile = inifile;
845 else
846 g_free (inifile);
850 profile_name = profile;
852 return profile;
855 /* --------------------------------------------------------------------------------------------- */
857 void
858 load_setup (void)
860 char *profile;
861 size_t i;
862 char *buffer;
863 const char *kt;
865 #ifdef HAVE_CHARSET
866 load_codepages_list ();
867 #endif /* HAVE_CHARSET */
869 profile = setup_init ();
871 /* mc.lib is common for all users, but has priority lower than
872 ${XDG_CONFIG_HOME}/mc/ini. FIXME: it's only used for keys and treestore now */
873 global_profile_name =
874 g_build_filename (mc_global.sysconfig_dir, MC_GLOBAL_CONFIG_FILE, (char *) NULL);
875 if (!exist_file (global_profile_name))
877 g_free (global_profile_name);
878 global_profile_name =
879 g_build_filename (mc_global.share_data_dir, MC_GLOBAL_CONFIG_FILE, (char *) NULL);
882 panels_profile_name = mc_config_get_full_path (MC_PANELS_FILE);
884 mc_main_config = mc_config_init (profile);
886 if (!exist_file (panels_profile_name))
887 setup__move_panels_config_into_separate_file (profile);
889 mc_panels_config = mc_config_init (panels_profile_name);
891 /* Load integer boolean options */
892 for (i = 0; int_options[i].opt_name != NULL; i++)
893 *int_options[i].opt_addr =
894 mc_config_get_int (mc_main_config, CONFIG_APP_SECTION, int_options[i].opt_name,
895 *int_options[i].opt_addr);
897 if (option_tab_spacing <= 0)
898 option_tab_spacing = DEFAULT_TAB_SPACING;
900 #ifdef USE_INTERNAL_EDIT
901 if (option_word_wrap_line_length <= 0)
902 option_word_wrap_line_length = DEFAULT_WRAP_LINE_LENGTH;
903 #endif /* USE_INTERNAL_EDIT */
905 /* overwrite old_esc_mode_timeout */
906 kt = getenv ("KEYBOARD_KEY_TIMEOUT_US");
907 if ((kt != NULL) && (kt[0] != '\0'))
908 old_esc_mode_timeout = atoi (kt);
910 /* Load string options */
911 for (i = 0; str_options[i].opt_name != NULL; i++)
912 *str_options[i].opt_addr =
913 mc_config_get_string (mc_main_config, CONFIG_APP_SECTION, str_options[i].opt_name,
914 str_options[i].opt_defval);
916 load_layout ();
917 panels_load_options ();
918 load_panelize ();
920 startup_left_mode = setup__load_panel_state ("New Left Panel");
921 startup_right_mode = setup__load_panel_state ("New Right Panel");
923 /* At least one of the panels is a listing panel */
924 if (startup_left_mode != view_listing && startup_right_mode != view_listing)
925 startup_left_mode = view_listing;
927 if (mc_run_param1 == NULL)
929 vfs_path_t *vpath;
930 buffer = mc_config_get_string (mc_panels_config, "Dirs", "other_dir", ".");
931 vpath = vfs_path_from_str (buffer);
932 if (vfs_file_is_local (vpath))
933 mc_run_param1 = buffer;
934 else
935 g_free (buffer);
936 vfs_path_free (vpath);
939 boot_current_is_left = mc_config_get_bool (mc_panels_config, "Dirs", "current_is_left", TRUE);
941 /* Load time formats */
942 user_recent_timeformat =
943 mc_config_get_string (mc_main_config, "Misc", "timeformat_recent", FMTTIME);
944 user_old_timeformat = mc_config_get_string (mc_main_config, "Misc", "timeformat_old", FMTYEAR);
946 #ifdef ENABLE_VFS_FTP
947 ftpfs_proxy_host = mc_config_get_string (mc_main_config, "Misc", "ftp_proxy_host", "gate");
948 ftpfs_ignore_chattr_errors = mc_config_get_bool (mc_main_config, CONFIG_APP_SECTION,
949 "ignore_ftp_chattr_errors", TRUE);
950 ftpfs_init_passwd ();
951 #endif /* ENABLE_VFS_FTP */
953 /* The default color and the terminal dependent color */
954 mc_global.tty.setup_color_string =
955 mc_config_get_string (mc_main_config, "Colors", "base_color", "");
956 mc_global.tty.term_color_string =
957 mc_config_get_string (mc_main_config, "Colors", getenv ("TERM"), "");
958 mc_global.tty.color_terminal_string =
959 mc_config_get_string (mc_main_config, "Colors", "color_terminals", "");
961 /* Load the directory history */
962 /* directory_history_load (); */
963 /* Remove the temporal entries */
965 #ifdef HAVE_CHARSET
966 if (codepages->len > 1)
968 buffer = mc_config_get_string (mc_main_config, "Misc", "display_codepage", "");
969 if (buffer[0] != '\0')
971 mc_global.display_codepage = get_codepage_index (buffer);
972 cp_display = get_codepage_id (mc_global.display_codepage);
974 g_free (buffer);
975 buffer = mc_config_get_string (mc_main_config, "Misc", "source_codepage", "");
976 if (buffer[0] != '\0')
978 default_source_codepage = get_codepage_index (buffer);
979 mc_global.source_codepage = default_source_codepage; /* May be source_codepage doesn't need this */
980 cp_source = get_codepage_id (mc_global.source_codepage);
982 g_free (buffer);
985 autodetect_codeset = mc_config_get_string (mc_main_config, "Misc", "autodetect_codeset", "");
986 if ((autodetect_codeset[0] != '\0') && (strcmp (autodetect_codeset, "off") != 0))
987 is_autodetect_codeset_enabled = TRUE;
989 g_free (init_translation_table (mc_global.source_codepage, mc_global.display_codepage));
990 buffer = (char *) get_codepage_id (mc_global.display_codepage);
991 if (buffer != NULL)
992 mc_global.utf8_display = str_isutf8 (buffer);
993 #endif /* HAVE_CHARSET */
995 clipboard_store_path = mc_config_get_string (mc_main_config, "Misc", "clipboard_store", "");
996 clipboard_paste_path = mc_config_get_string (mc_main_config, "Misc", "clipboard_paste", "");
999 /* --------------------------------------------------------------------------------------------- */
1001 gboolean
1002 save_setup (gboolean save_options, gboolean save_panel_options)
1004 gboolean ret = TRUE;
1006 saving_setup = 1;
1008 save_hotlist ();
1010 if (save_panel_options)
1011 save_panel_types ();
1013 if (save_options)
1015 char *tmp_profile;
1017 save_config ();
1018 save_layout ();
1019 panels_save_options ();
1020 save_panelize ();
1021 /* directory_history_save (); */
1023 #ifdef ENABLE_VFS_FTP
1024 mc_config_set_string (mc_main_config, "Misc", "ftpfs_password", ftpfs_anonymous_passwd);
1025 if (ftpfs_proxy_host)
1026 mc_config_set_string (mc_main_config, "Misc", "ftp_proxy_host", ftpfs_proxy_host);
1027 #endif /* ENABLE_VFS_FTP */
1029 #ifdef HAVE_CHARSET
1030 mc_config_set_string (mc_main_config, "Misc", "display_codepage",
1031 get_codepage_id (mc_global.display_codepage));
1032 mc_config_set_string (mc_main_config, "Misc", "source_codepage",
1033 get_codepage_id (default_source_codepage));
1034 mc_config_set_string (mc_main_config, "Misc", "autodetect_codeset", autodetect_codeset);
1035 #endif /* HAVE_CHARSET */
1036 mc_config_set_string (mc_main_config, "Misc", "clipboard_store", clipboard_store_path);
1037 mc_config_set_string (mc_main_config, "Misc", "clipboard_paste", clipboard_paste_path);
1039 tmp_profile = mc_config_get_full_path (MC_CONFIG_FILE);
1040 ret = mc_config_save_to_file (mc_main_config, tmp_profile, NULL);
1041 g_free (tmp_profile);
1044 saving_setup = 0;
1046 return ret;
1049 /* --------------------------------------------------------------------------------------------- */
1051 void
1052 done_setup (void)
1054 size_t i;
1056 g_free (clipboard_store_path);
1057 g_free (clipboard_paste_path);
1058 g_free (profile_name);
1059 g_free (global_profile_name);
1060 g_free (mc_global.tty.color_terminal_string);
1061 g_free (mc_global.tty.term_color_string);
1062 g_free (mc_global.tty.setup_color_string);
1063 g_free (panels_profile_name);
1064 mc_config_deinit (mc_main_config);
1065 mc_config_deinit (mc_panels_config);
1067 g_free (user_recent_timeformat);
1068 g_free (user_old_timeformat);
1070 for (i = 0; str_options[i].opt_name != NULL; i++)
1071 g_free (*str_options[i].opt_addr);
1073 done_hotlist ();
1074 done_panelize ();
1075 /* directory_history_free (); */
1077 #ifdef HAVE_CHARSET
1078 g_free (autodetect_codeset);
1079 free_codepages_list ();
1080 #endif
1083 /* --------------------------------------------------------------------------------------------- */
1085 void
1086 save_config (void)
1088 size_t i;
1090 /* Save integer options */
1091 for (i = 0; int_options[i].opt_name != NULL; i++)
1092 mc_config_set_int (mc_main_config, CONFIG_APP_SECTION, int_options[i].opt_name,
1093 *int_options[i].opt_addr);
1095 /* Save string options */
1096 for (i = 0; str_options[i].opt_name != NULL; i++)
1097 mc_config_set_string (mc_main_config, CONFIG_APP_SECTION, str_options[i].opt_name,
1098 *str_options[i].opt_addr);
1101 /* --------------------------------------------------------------------------------------------- */
1103 void
1104 setup_save_config_show_error (const char *filename, GError ** error)
1106 if (error != NULL && *error != NULL)
1108 message (D_ERROR, MSG_ERROR, _("Cannot save file %s:\n%s"), filename, (*error)->message);
1109 g_error_free (*error);
1110 *error = NULL;
1114 /* --------------------------------------------------------------------------------------------- */
1116 void
1117 save_layout (void)
1119 size_t i;
1121 /* Save integer options */
1122 for (i = 0; layout[i].opt_name != NULL; i++)
1123 mc_config_set_int (mc_main_config, "Layout", layout[i].opt_name, *layout[i].opt_addr);
1126 /* --------------------------------------------------------------------------------------------- */
1128 void
1129 load_key_defs (void)
1132 * Load keys from mc.lib before ${XDG_CONFIG_HOME}/mc/ini, so that the user
1133 * definitions override global settings.
1135 mc_config_t *mc_global_config;
1137 mc_global_config = mc_config_init (global_profile_name);
1138 if (mc_global_config != NULL)
1140 load_keys_from_section ("general", mc_global_config);
1141 load_keys_from_section (getenv ("TERM"), mc_global_config);
1142 mc_config_deinit (mc_global_config);
1145 load_keys_from_section ("general", mc_main_config);
1146 load_keys_from_section (getenv ("TERM"), mc_main_config);
1149 /* --------------------------------------------------------------------------------------------- */
1151 #ifdef ENABLE_VFS_FTP
1152 char *
1153 load_anon_passwd (void)
1155 char *buffer;
1157 buffer = mc_config_get_string (mc_main_config, "Misc", "ftpfs_password", "");
1159 if ((buffer != NULL) && (buffer[0] != '\0'))
1160 return buffer;
1162 g_free (buffer);
1163 return NULL;
1165 #endif /* ENABLE_VFS_FTP */
1167 /* --------------------------------------------------------------------------------------------- */
1169 void
1170 load_keymap_defs (gboolean load_from_file)
1173 * Load keymap from GLOBAL_KEYMAP_FILE before ${XDG_CONFIG_HOME}/mc/mc.keymap, so that the user
1174 * definitions override global settings.
1176 mc_config_t *mc_global_keymap;
1178 mc_global_keymap = load_setup_get_keymap_profile_config (load_from_file);
1180 if (mc_global_keymap != NULL)
1182 main_keymap = g_array_new (TRUE, FALSE, sizeof (global_keymap_t));
1183 load_keymap_from_section (KEYMAP_SECTION_MAIN, main_keymap, mc_global_keymap);
1184 main_x_keymap = g_array_new (TRUE, FALSE, sizeof (global_keymap_t));
1185 load_keymap_from_section (KEYMAP_SECTION_MAIN_EXT, main_x_keymap, mc_global_keymap);
1187 panel_keymap = g_array_new (TRUE, FALSE, sizeof (global_keymap_t));
1188 load_keymap_from_section (KEYMAP_SECTION_PANEL, panel_keymap, mc_global_keymap);
1190 dialog_keymap = g_array_new (TRUE, FALSE, sizeof (global_keymap_t));
1191 load_keymap_from_section (KEYMAP_SECTION_DIALOG, dialog_keymap, mc_global_keymap);
1193 input_keymap = g_array_new (TRUE, FALSE, sizeof (global_keymap_t));
1194 load_keymap_from_section (KEYMAP_SECTION_INPUT, input_keymap, mc_global_keymap);
1196 listbox_keymap = g_array_new (TRUE, FALSE, sizeof (global_keymap_t));
1197 load_keymap_from_section (KEYMAP_SECTION_LISTBOX, listbox_keymap, mc_global_keymap);
1199 tree_keymap = g_array_new (TRUE, FALSE, sizeof (global_keymap_t));
1200 load_keymap_from_section (KEYMAP_SECTION_TREE, tree_keymap, mc_global_keymap);
1202 help_keymap = g_array_new (TRUE, FALSE, sizeof (global_keymap_t));
1203 load_keymap_from_section (KEYMAP_SECTION_HELP, help_keymap, mc_global_keymap);
1205 #ifdef USE_INTERNAL_EDIT
1206 editor_keymap = g_array_new (TRUE, FALSE, sizeof (global_keymap_t));
1207 load_keymap_from_section (KEYMAP_SECTION_EDITOR, editor_keymap, mc_global_keymap);
1208 editor_x_keymap = g_array_new (TRUE, FALSE, sizeof (global_keymap_t));
1209 load_keymap_from_section (KEYMAP_SECTION_EDITOR_EXT, editor_x_keymap, mc_global_keymap);
1210 #endif
1212 viewer_keymap = g_array_new (TRUE, FALSE, sizeof (global_keymap_t));
1213 load_keymap_from_section (KEYMAP_SECTION_VIEWER, viewer_keymap, mc_global_keymap);
1214 viewer_hex_keymap = g_array_new (TRUE, FALSE, sizeof (global_keymap_t));
1215 load_keymap_from_section (KEYMAP_SECTION_VIEWER_HEX, viewer_hex_keymap, mc_global_keymap);
1217 #ifdef USE_DIFF_VIEW
1218 diff_keymap = g_array_new (TRUE, FALSE, sizeof (global_keymap_t));
1219 load_keymap_from_section (KEYMAP_SECTION_DIFFVIEWER, diff_keymap, mc_global_keymap);
1220 #endif
1222 mc_config_deinit (mc_global_keymap);
1225 main_map = (global_keymap_t *) main_keymap->data;
1226 main_x_map = (global_keymap_t *) main_x_keymap->data;
1227 panel_map = (global_keymap_t *) panel_keymap->data;
1228 dialog_map = (global_keymap_t *) dialog_keymap->data;
1229 input_map = (global_keymap_t *) input_keymap->data;
1230 listbox_map = (global_keymap_t *) listbox_keymap->data;
1231 tree_map = (global_keymap_t *) tree_keymap->data;
1232 help_map = (global_keymap_t *) help_keymap->data;
1233 #ifdef USE_INTERNAL_EDIT
1234 editor_map = (global_keymap_t *) editor_keymap->data;
1235 editor_x_map = (global_keymap_t *) editor_x_keymap->data;
1236 #endif
1237 viewer_map = (global_keymap_t *) viewer_keymap->data;
1238 viewer_hex_map = (global_keymap_t *) viewer_hex_keymap->data;
1239 #ifdef USE_DIFF_VIEW
1240 diff_map = (global_keymap_t *) diff_keymap->data;
1241 #endif
1244 /* --------------------------------------------------------------------------------------------- */
1246 void
1247 free_keymap_defs (void)
1249 if (main_keymap != NULL)
1250 g_array_free (main_keymap, TRUE);
1251 if (main_x_keymap != NULL)
1252 g_array_free (main_x_keymap, TRUE);
1253 if (panel_keymap != NULL)
1254 g_array_free (panel_keymap, TRUE);
1255 if (dialog_keymap != NULL)
1256 g_array_free (dialog_keymap, TRUE);
1257 if (input_keymap != NULL)
1258 g_array_free (input_keymap, TRUE);
1259 if (listbox_keymap != NULL)
1260 g_array_free (listbox_keymap, TRUE);
1261 if (tree_keymap != NULL)
1262 g_array_free (tree_keymap, TRUE);
1263 if (help_keymap != NULL)
1264 g_array_free (help_keymap, TRUE);
1265 #ifdef USE_INTERNAL_EDIT
1266 if (editor_keymap != NULL)
1267 g_array_free (editor_keymap, TRUE);
1268 if (editor_x_keymap != NULL)
1269 g_array_free (editor_x_keymap, TRUE);
1270 #endif
1271 if (viewer_keymap != NULL)
1272 g_array_free (viewer_keymap, TRUE);
1273 if (viewer_hex_keymap != NULL)
1274 g_array_free (viewer_hex_keymap, TRUE);
1275 #ifdef USE_DIFF_VIEW
1276 if (diff_keymap != NULL)
1277 g_array_free (diff_keymap, TRUE);
1278 #endif
1281 /* --------------------------------------------------------------------------------------------- */
1283 void
1284 panel_load_setup (WPanel * panel, const char *section)
1286 size_t i;
1287 char *buffer, buffer2[BUF_TINY];
1289 panel->sort_info.reverse = mc_config_get_int (mc_panels_config, section, "reverse", 0);
1290 panel->sort_info.case_sensitive =
1291 mc_config_get_int (mc_panels_config, section, "case_sensitive",
1292 OS_SORT_CASE_SENSITIVE_DEFAULT);
1293 panel->sort_info.exec_first = mc_config_get_int (mc_panels_config, section, "exec_first", 0);
1295 /* Load sort order */
1296 buffer = mc_config_get_string (mc_panels_config, section, "sort_order", "name");
1297 panel->sort_info.sort_field = panel_get_field_by_id (buffer);
1298 if (panel->sort_info.sort_field == NULL)
1299 panel->sort_info.sort_field = panel_get_field_by_id ("name");
1301 g_free (buffer);
1303 /* Load the listing mode */
1304 buffer = mc_config_get_string (mc_panels_config, section, "list_mode", "full");
1305 panel->list_type = list_full;
1306 for (i = 0; list_types[i].key != NULL; i++)
1307 if (g_ascii_strcasecmp (list_types[i].key, buffer) == 0)
1309 panel->list_type = list_types[i].list_type;
1310 break;
1312 g_free (buffer);
1314 /* User formats */
1315 g_free (panel->user_format);
1316 panel->user_format =
1317 mc_config_get_string (mc_panels_config, section, "user_format", DEFAULT_USER_FORMAT);
1319 for (i = 0; i < LIST_TYPES; i++)
1321 g_free (panel->user_status_format[i]);
1322 g_snprintf (buffer2, BUF_TINY, "user_status%lld", (long long) i);
1323 panel->user_status_format[i] =
1324 mc_config_get_string (mc_panels_config, section, buffer2, DEFAULT_USER_FORMAT);
1327 panel->user_mini_status = mc_config_get_int (mc_panels_config, section, "user_mini_status", 0);
1330 /* --------------------------------------------------------------------------------------------- */
1332 void
1333 panel_save_setup (struct WPanel *panel, const char *section)
1335 char buffer[BUF_TINY];
1336 size_t i;
1338 mc_config_set_int (mc_panels_config, section, "reverse", panel->sort_info.reverse);
1339 mc_config_set_int (mc_panels_config, section, "case_sensitive",
1340 panel->sort_info.case_sensitive);
1341 mc_config_set_int (mc_panels_config, section, "exec_first", panel->sort_info.exec_first);
1343 mc_config_set_string (mc_panels_config, section, "sort_order", panel->sort_info.sort_field->id);
1345 for (i = 0; list_types[i].key != NULL; i++)
1346 if (list_types[i].list_type == panel->list_type)
1348 mc_config_set_string (mc_panels_config, section, "list_mode", list_types[i].key);
1349 break;
1352 mc_config_set_string (mc_panels_config, section, "user_format", panel->user_format);
1354 for (i = 0; i < LIST_TYPES; i++)
1356 g_snprintf (buffer, BUF_TINY, "user_status%lld", (long long) i);
1357 mc_config_set_string (mc_panels_config, section, buffer, panel->user_status_format[i]);
1360 mc_config_set_int (mc_panels_config, section, "user_mini_status", panel->user_mini_status);
1363 /* --------------------------------------------------------------------------------------------- */
1366 Load panels options from [Panels] section.
1368 void
1369 panels_load_options (void)
1371 if (mc_config_has_group (mc_main_config, CONFIG_PANELS_SECTION))
1373 size_t i;
1374 int qmode;
1376 for (i = 0; panels_ini_options[i].opt_name != NULL; i++)
1377 *panels_ini_options[i].opt_addr =
1378 mc_config_get_bool (mc_main_config, CONFIG_PANELS_SECTION,
1379 panels_ini_options[i].opt_name,
1380 *panels_ini_options[i].opt_addr);
1382 qmode = mc_config_get_int (mc_main_config, CONFIG_PANELS_SECTION,
1383 "quick_search_mode", (int) panels_options.qsearch_mode);
1384 if (qmode < 0)
1385 panels_options.qsearch_mode = QSEARCH_CASE_INSENSITIVE;
1386 else if (qmode >= QSEARCH_NUM)
1387 panels_options.qsearch_mode = QSEARCH_PANEL_CASE;
1388 else
1389 panels_options.qsearch_mode = (qsearch_mode_t) qmode;
1393 /* --------------------------------------------------------------------------------------------- */
1396 Save panels options in [Panels] section.
1398 void
1399 panels_save_options (void)
1401 size_t i;
1403 for (i = 0; panels_ini_options[i].opt_name != NULL; i++)
1404 mc_config_set_bool (mc_main_config, CONFIG_PANELS_SECTION,
1405 panels_ini_options[i].opt_name, *panels_ini_options[i].opt_addr);
1407 mc_config_set_int (mc_main_config, CONFIG_PANELS_SECTION,
1408 "quick_search_mode", (int) panels_options.qsearch_mode);
1411 /* --------------------------------------------------------------------------------------------- */