root/src/setup.c

/* [previous][next][first][last][top][bottom][index][help]  */

DEFINITIONS

This source file includes following definitions.
  1. setup__is_cfg_group_must_panel_config
  2. setup__move_panels_config_into_separate_file
  3. load_config
  4. setup__load_panel_state
  5. load_layout
  6. load_keys_from_section
  7. panel_save_type
  8. panels_load_options
  9. panels_save_options
  10. save_config
  11. save_layout
  12. save_panel_types
  13. setup_init
  14. load_setup
  15. save_setup
  16. done_setup
  17. setup_save_config_show_error
  18. load_key_defs
  19. load_anon_passwd
  20. panel_load_setup
  21. panel_save_setup

   1 /*
   2    Setup loading/saving.
   3 
   4    Copyright (C) 1994-2021
   5    Free Software Foundation, Inc.
   6 
   7    This file is part of the Midnight Commander.
   8 
   9    The Midnight Commander is free software: you can redistribute it
  10    and/or modify it under the terms of the GNU General Public License as
  11    published by the Free Software Foundation, either version 3 of the License,
  12    or (at your option) any later version.
  13 
  14    The Midnight Commander is distributed in the hope that it will be useful,
  15    but WITHOUT ANY WARRANTY; without even the implied warranty of
  16    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  17    GNU General Public License for more details.
  18 
  19    You should have received a copy of the GNU General Public License
  20    along with this program.  If not, see <http://www.gnu.org/licenses/>.
  21  */
  22 
  23 /** \file setup.c
  24  *  \brief Source: setup loading/saving
  25  */
  26 
  27 #include <config.h>
  28 
  29 #include <stdlib.h>
  30 #include <string.h>
  31 #include <stdio.h>
  32 #include <sys/types.h>
  33 #include <sys/stat.h>
  34 
  35 #include "lib/global.h"
  36 
  37 #include "lib/tty/tty.h"
  38 #include "lib/tty/key.h"
  39 #include "lib/mcconfig.h"       /* num_history_items_recorded */
  40 #include "lib/fileloc.h"
  41 #include "lib/timefmt.h"
  42 #include "lib/util.h"
  43 
  44 #ifdef ENABLE_VFS_FTP
  45 #include "src/vfs/ftpfs/ftpfs.h"
  46 #endif
  47 #ifdef ENABLE_VFS_FISH
  48 #include "src/vfs/fish/fish.h"
  49 #endif
  50 
  51 #ifdef HAVE_CHARSET
  52 #include "lib/charsets.h"
  53 #endif
  54 
  55 #include "filemanager/dir.h"
  56 #include "filemanager/filemanager.h"
  57 #include "filemanager/tree.h"   /* xtree_mode */
  58 #include "filemanager/hotlist.h"        /* load/save/done hotlist */
  59 #include "filemanager/panelize.h"       /* load/save/done panelize */
  60 #include "filemanager/layout.h"
  61 #include "filemanager/cmd.h"
  62 
  63 #include "args.h"
  64 #include "execute.h"            /* pause_after_run */
  65 #include "clipboard.h"
  66 
  67 #ifdef HAVE_CHARSET
  68 #include "selcodepage.h"
  69 #endif
  70 
  71 #ifdef USE_INTERNAL_EDIT
  72 #include "src/editor/edit.h"
  73 #endif
  74 
  75 #include "src/viewer/mcviewer.h"        /* For the externs */
  76 
  77 #include "setup.h"
  78 
  79 /*** global variables ****************************************************************************/
  80 
  81 char *global_profile_name;      /* mc.lib */
  82 
  83 /* Only used at program boot */
  84 gboolean boot_current_is_left = TRUE;
  85 
  86 /* If on, default for "No" in delete operations */
  87 gboolean safe_delete = FALSE;
  88 /* If on, default for "No" in overwrite files */
  89 gboolean safe_overwrite = FALSE;
  90 
  91 /* Controls screen clearing before an exec */
  92 gboolean clear_before_exec = TRUE;
  93 
  94 /* Asks for confirmation before deleting a file */
  95 gboolean confirm_delete = TRUE;
  96 /* Asks for confirmation before deleting a hotlist entry */
  97 gboolean confirm_directory_hotlist_delete = FALSE;
  98 /* Asks for confirmation before overwriting a file */
  99 gboolean confirm_overwrite = TRUE;
 100 /* Asks for confirmation before executing a program by pressing enter */
 101 gboolean confirm_execute = FALSE;
 102 /* Asks for confirmation before leaving the program */
 103 gboolean confirm_exit = FALSE;
 104 
 105 /* If true, at startup the user-menu is invoked */
 106 gboolean auto_menu = FALSE;
 107 /* This flag indicates if the pull down menus by default drop down */
 108 gboolean drop_menus = FALSE;
 109 
 110 /* Asks for confirmation when using F3 to view a directory and there
 111    are tagged files */
 112 gboolean confirm_view_dir = FALSE;
 113 
 114 /* Ask file name before start the editor */
 115 gboolean editor_ask_filename_before_edit = FALSE;
 116 
 117 panel_view_mode_t startup_left_mode;
 118 panel_view_mode_t startup_right_mode;
 119 
 120 gboolean copymove_persistent_attr = TRUE;
 121 
 122 /* Tab size */
 123 int option_tab_spacing = DEFAULT_TAB_SPACING;
 124 
 125 /* Ugly hack to allow panel_save_setup to work as a place holder for */
 126 /* default panel values */
 127 int saving_setup;
 128 
 129 panels_options_t panels_options = {
 130     .show_mini_info = TRUE,
 131     .kilobyte_si = FALSE,
 132     .mix_all_files = FALSE,
 133     .show_backups = TRUE,
 134     .show_dot_files = TRUE,
 135     .fast_reload = FALSE,
 136     .fast_reload_msg_shown = FALSE,
 137     .mark_moves_down = TRUE,
 138     .reverse_files_only = TRUE,
 139     .auto_save_setup = FALSE,
 140     .navigate_with_arrows = FALSE,
 141     .scroll_pages = TRUE,
 142     .scroll_center = FALSE,
 143     .mouse_move_pages = TRUE,
 144     .filetype_mode = TRUE,
 145     .permission_mode = FALSE,
 146     .qsearch_mode = QSEARCH_PANEL_CASE,
 147     .torben_fj_mode = FALSE,
 148     .select_flags = SELECT_MATCH_CASE | SELECT_SHELL_PATTERNS
 149 };
 150 
 151 gboolean easy_patterns = TRUE;
 152 
 153 /* It true saves the setup when quitting */
 154 gboolean auto_save_setup = TRUE;
 155 
 156 /* If true, then the +, - and \ keys have their special meaning only if the
 157  * command line is empty, otherwise they behave like regular letters
 158  */
 159 gboolean only_leading_plus_minus = TRUE;
 160 
 161 /* Automatically fills name with current selected item name on mkdir */
 162 gboolean auto_fill_mkdir_name = TRUE;
 163 
 164 /* If set and you don't have subshell support, then C-o will give you a shell */
 165 gboolean output_starts_shell = FALSE;
 166 
 167 /* If set, we execute the file command to check the file type */
 168 gboolean use_file_to_check_type = TRUE;
 169 
 170 gboolean verbose = TRUE;
 171 
 172 /*
 173  * Whether the Midnight Commander tries to provide more
 174  * information about copy/move sizes and bytes transferred
 175  * at the expense of some speed
 176  */
 177 gboolean file_op_compute_totals = TRUE;
 178 
 179 /* If true use the internal viewer */
 180 gboolean use_internal_view = TRUE;
 181 /* If set, use the builtin editor */
 182 gboolean use_internal_edit = TRUE;
 183 
 184 #ifdef HAVE_CHARSET
 185 /* Numbers of (file I/O) and (input/display) codepages. -1 if not selected */
 186 int default_source_codepage = -1;
 187 char *autodetect_codeset = NULL;
 188 gboolean is_autodetect_codeset_enabled = FALSE;
 189 #endif /* !HAVE_CHARSET */
 190 
 191 #ifdef HAVE_ASPELL
 192 char *spell_language = NULL;
 193 #endif
 194 
 195 /* Value of "other_dir" key in ini file */
 196 char *saved_other_dir = NULL;
 197 
 198 /* If set, then print to the given file the last directory we were at */
 199 char *last_wd_string = NULL;
 200 
 201 /* Set when main loop should be terminated */
 202 int quit = 0;
 203 
 204 /* Set to TRUE to suppress printing the last directory */
 205 int print_last_revert = FALSE;
 206 
 207 #ifdef USE_INTERNAL_EDIT
 208 /* index to record_macro_buf[], -1 if not recording a macro */
 209 int macro_index = -1;
 210 
 211 /* macro stuff */
 212 struct macro_action_t record_macro_buf[MAX_MACRO_LENGTH];
 213 
 214 GArray *macros_list;
 215 #endif /* USE_INTERNAL_EDIT */
 216 
 217 /*** file scope macro definitions ****************************************************************/
 218 
 219 /* In order to use everywhere the same setup for the locale we use defines */
 220 #define FMTYEAR _("%b %e  %Y")
 221 #define FMTTIME _("%b %e %H:%M")
 222 
 223 /*** file scope type declarations ****************************************************************/
 224 
 225 /*** file scope variables ************************************************************************/
 226 
 227 static char *profile_name = NULL;       /* ${XDG_CONFIG_HOME}/mc/ini */
 228 static char *panels_profile_name = NULL;        /* ${XDG_CACHE_HOME}/mc/panels.ini */
 229 
 230 /* *INDENT-OFF* */
 231 static const struct
 232 {
 233     const char *key;
 234     int  list_format;
 235 } list_formats [] = {
 236     { "full",  list_full  },
 237     { "brief", list_brief },
 238     { "long",  list_long  },
 239     { "user",  list_user  },
 240     { NULL, 0 }
 241 };
 242 
 243 static const struct
 244 {
 245     const char *opt_name;
 246     panel_view_mode_t opt_type;
 247 } panel_types [] = {
 248     { "listing",   view_listing },
 249     { "quickview", view_quick },
 250     { "info",      view_info },
 251     { "tree",      view_tree },
 252     { NULL,        view_listing }
 253 };
 254 
 255 static const struct
 256 {
 257     const char *opt_name;
 258     int *opt_addr;
 259 } layout_int_options [] = {
 260     { "output_lines", &output_lines },
 261     { "left_panel_size", &panels_layout.left_panel_size },
 262     { "top_panel_size", &panels_layout.top_panel_size },
 263     { NULL, NULL }
 264 };
 265 
 266 static const struct
 267 {
 268     const char *opt_name;
 269     gboolean *opt_addr;
 270 } layout_bool_options [] = {
 271     { "message_visible", &mc_global.message_visible },
 272     { "keybar_visible", &mc_global.keybar_visible },
 273     { "xterm_title", &xterm_title },
 274     { "command_prompt", &command_prompt },
 275     { "menubar_visible", &menubar_visible },
 276     { "free_space", &free_space },
 277     { "horizontal_split", &panels_layout.horizontal_split },
 278     { "vertical_equal", &panels_layout.vertical_equal },
 279     { "horizontal_equal", &panels_layout.horizontal_equal },
 280     { NULL, NULL }
 281 };
 282 
 283 static const struct
 284 {
 285     const char *opt_name;
 286     gboolean *opt_addr;
 287 } bool_options [] = {
 288     { "verbose", &verbose },
 289     { "shell_patterns", &easy_patterns },
 290     { "auto_save_setup", &auto_save_setup },
 291     { "preallocate_space", &mc_global.vfs.preallocate_space },
 292     { "auto_menu", &auto_menu },
 293     { "use_internal_view", &use_internal_view },
 294     { "use_internal_edit", &use_internal_edit },
 295     { "clear_before_exec", &clear_before_exec },
 296     { "confirm_delete", &confirm_delete },
 297     { "confirm_overwrite", &confirm_overwrite },
 298     { "confirm_execute", &confirm_execute },
 299     { "confirm_history_cleanup", &mc_global.widget.confirm_history_cleanup },
 300     { "confirm_exit", &confirm_exit },
 301     { "confirm_directory_hotlist_delete", &confirm_directory_hotlist_delete },
 302     { "confirm_view_dir", &confirm_view_dir },
 303     { "safe_delete", &safe_delete },
 304     { "safe_overwrite", &safe_overwrite },
 305 #ifndef HAVE_CHARSET
 306     { "eight_bit_clean", &mc_global.eight_bit_clean },
 307     { "full_eight_bits", &mc_global.full_eight_bits },
 308 #endif /* !HAVE_CHARSET */
 309     { "use_8th_bit_as_meta", &use_8th_bit_as_meta },
 310     { "mouse_move_pages_viewer", &mcview_mouse_move_pages },
 311     { "mouse_close_dialog", &mouse_close_dialog},
 312     { "fast_refresh", &fast_refresh },
 313     { "drop_menus", &drop_menus },
 314     { "wrap_mode",  &mcview_global_flags.wrap },
 315     { "old_esc_mode", &old_esc_mode },
 316     { "cd_symlinks", &mc_global.vfs.cd_symlinks },
 317     { "show_all_if_ambiguous", &mc_global.widget.show_all_if_ambiguous },
 318 #ifdef USE_FILE_CMD
 319     { "use_file_to_guess_type", &use_file_to_check_type },
 320 #endif
 321     { "alternate_plus_minus", &mc_global.tty.alternate_plus_minus },
 322     { "only_leading_plus_minus", &only_leading_plus_minus },
 323     { "show_output_starts_shell", &output_starts_shell },
 324     { "xtree_mode", &xtree_mode },
 325     { "file_op_compute_totals", &file_op_compute_totals },
 326     { "classic_progressbar", &classic_progressbar },
 327 #ifdef ENABLE_VFS
 328 #ifdef ENABLE_VFS_FTP
 329     { "use_netrc", &ftpfs_use_netrc },
 330     { "ftpfs_always_use_proxy", &ftpfs_always_use_proxy },
 331     { "ftpfs_use_passive_connections", &ftpfs_use_passive_connections },
 332     { "ftpfs_use_passive_connections_over_proxy", &ftpfs_use_passive_connections_over_proxy },
 333     { "ftpfs_use_unix_list_options", &ftpfs_use_unix_list_options },
 334     { "ftpfs_first_cd_then_ls", &ftpfs_first_cd_then_ls },
 335     { "ignore_ftp_chattr_errors", & ftpfs_ignore_chattr_errors} ,
 336 #endif /* ENABLE_VFS_FTP */
 337 #endif /* ENABLE_VFS */
 338 #ifdef USE_INTERNAL_EDIT
 339     { "editor_fill_tabs_with_spaces", &option_fill_tabs_with_spaces },
 340     { "editor_return_does_auto_indent", &option_return_does_auto_indent },
 341     { "editor_backspace_through_tabs", &option_backspace_through_tabs },
 342     { "editor_fake_half_tabs", &option_fake_half_tabs },
 343     { "editor_option_save_position", &option_save_position },
 344     { "editor_option_auto_para_formatting", &option_auto_para_formatting },
 345     { "editor_option_typewriter_wrap", &option_typewriter_wrap },
 346     { "editor_edit_confirm_save", &edit_confirm_save },
 347     { "editor_syntax_highlighting", &option_syntax_highlighting },
 348     { "editor_persistent_selections", &option_persistent_selections },
 349     { "editor_drop_selection_on_copy", &option_drop_selection_on_copy },
 350     { "editor_cursor_beyond_eol", &option_cursor_beyond_eol },
 351     { "editor_cursor_after_inserted_block", &option_cursor_after_inserted_block },
 352     { "editor_visible_tabs", &visible_tabs },
 353     { "editor_visible_spaces", &visible_tws },
 354     { "editor_line_state", &option_line_state },
 355     { "editor_simple_statusbar", &simple_statusbar },
 356     { "editor_check_new_line", &option_check_nl_at_eof },
 357     { "editor_show_right_margin", &show_right_margin },
 358     { "editor_group_undo", &option_group_undo },
 359     { "editor_state_full_filename", &option_state_full_filename },
 360 #endif /* USE_INTERNAL_EDIT */
 361     { "editor_ask_filename_before_edit", &editor_ask_filename_before_edit },
 362     { "nice_rotating_dash", &nice_rotating_dash },
 363     { "shadows", &mc_global.tty.shadows },
 364     { "mcview_remember_file_position", &mcview_remember_file_position },
 365     { "auto_fill_mkdir_name", &auto_fill_mkdir_name },
 366     { "copymove_persistent_attr", &copymove_persistent_attr },
 367     { NULL, NULL }
 368 };
 369 
 370 static const struct
 371 {
 372     const char *opt_name;
 373     int *opt_addr;
 374 } int_options [] = {
 375     { "pause_after_run", &pause_after_run },
 376     { "mouse_repeat_rate", &mou_auto_repeat },
 377     { "double_click_speed", &double_click_speed },
 378     { "old_esc_mode_timeout", &old_esc_mode_timeout },
 379     { "max_dirt_limit", &mcview_max_dirt_limit },
 380     { "num_history_items_recorded", &num_history_items_recorded },
 381 #ifdef ENABLE_VFS
 382     { "vfs_timeout", &vfs_timeout },
 383 #ifdef ENABLE_VFS_FTP
 384     { "ftpfs_directory_timeout", &ftpfs_directory_timeout },
 385     { "ftpfs_retry_seconds", &ftpfs_retry_seconds },
 386 #endif /* ENABLE_VFS_FTP */
 387 #ifdef ENABLE_VFS_FISH
 388     { "fish_directory_timeout", &fish_directory_timeout },
 389 #endif /* ENABLE_VFS_FISH */
 390 #endif /* ENABLE_VFS */
 391     /* option_tab_spacing is used in internal viewer */
 392     { "editor_tab_spacing", &option_tab_spacing },
 393 #ifdef USE_INTERNAL_EDIT
 394     { "editor_word_wrap_line_length", &option_word_wrap_line_length },
 395     { "editor_option_save_mode", &option_save_mode },
 396 #endif /* USE_INTERNAL_EDIT */
 397     { NULL, NULL }
 398 };
 399 
 400 static const struct
 401 {
 402     const char *opt_name;
 403     char **opt_addr;
 404     const char *opt_defval;
 405 } str_options[] = {
 406 #ifdef USE_INTERNAL_EDIT
 407     { "editor_backup_extension", &option_backup_ext, "~" },
 408     { "editor_filesize_threshold", &option_filesize_threshold, "64M" },
 409     { "editor_stop_format_chars", &option_stop_format_chars, "-+*\\,.;:&>" },
 410 #endif
 411     { "mcview_eof", &mcview_show_eof, "" },
 412     {  NULL, NULL, NULL }
 413 };
 414 
 415 static const struct
 416 {
 417     const char *opt_name;
 418     gboolean *opt_addr;
 419 } panels_ini_options[] = {
 420     { "show_mini_info", &panels_options.show_mini_info },
 421     { "kilobyte_si", &panels_options.kilobyte_si },
 422     { "mix_all_files", &panels_options.mix_all_files },
 423     { "show_backups", &panels_options.show_backups },
 424     { "show_dot_files", &panels_options.show_dot_files },
 425     { "fast_reload", &panels_options.fast_reload },
 426     { "fast_reload_msg_shown", &panels_options.fast_reload_msg_shown },
 427     { "mark_moves_down", &panels_options.mark_moves_down },
 428     { "reverse_files_only", &panels_options.reverse_files_only },
 429     { "auto_save_setup_panels", &panels_options.auto_save_setup },
 430     { "navigate_with_arrows", &panels_options.navigate_with_arrows },
 431     { "panel_scroll_pages", &panels_options.scroll_pages },
 432     { "panel_scroll_center", &panels_options.scroll_center },
 433     { "mouse_move_pages",  &panels_options.mouse_move_pages },
 434     { "filetype_mode", &panels_options.filetype_mode },
 435     { "permission_mode", &panels_options.permission_mode },
 436     { "torben_fj_mode", &panels_options.torben_fj_mode },
 437     { NULL, NULL }
 438 };
 439 /* *INDENT-ON* */
 440 
 441 /* --------------------------------------------------------------------------------------------- */
 442 /*** file scope functions ************************************************************************/
 443 /* --------------------------------------------------------------------------------------------- */
 444 
 445 static const char *
 446 setup__is_cfg_group_must_panel_config (const char *grp)
     /* [previous][next][first][last][top][bottom][index][help]  */
 447 {
 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;
 453 }
 454 
 455 /* --------------------------------------------------------------------------------------------- */
 456 
 457 static void
 458 setup__move_panels_config_into_separate_file (const char *profile)
     /* [previous][next][first][last][top][bottom][index][help]  */
 459 {
 460     mc_config_t *tmp_cfg;
 461     char **groups, **curr_grp;
 462 
 463     if (!exist_file (profile))
 464         return;
 465 
 466     tmp_cfg = mc_config_init (profile, FALSE);
 467     if (tmp_cfg == NULL)
 468         return;
 469 
 470     groups = mc_config_get_groups (tmp_cfg, NULL);
 471     if (*groups == NULL)
 472     {
 473         g_strfreev (groups);
 474         mc_config_deinit (tmp_cfg);
 475         return;
 476     }
 477 
 478     for (curr_grp = groups; *curr_grp != NULL; curr_grp++)
 479         if (setup__is_cfg_group_must_panel_config (*curr_grp) == NULL)
 480             mc_config_del_group (tmp_cfg, *curr_grp);
 481 
 482     mc_config_save_to_file (tmp_cfg, panels_profile_name, NULL);
 483     mc_config_deinit (tmp_cfg);
 484 
 485     tmp_cfg = mc_config_init (profile, FALSE);
 486     if (tmp_cfg == NULL)
 487     {
 488         g_strfreev (groups);
 489         return;
 490     }
 491 
 492     for (curr_grp = groups; *curr_grp != NULL; curr_grp++)
 493     {
 494         const char *need_grp;
 495 
 496         need_grp = setup__is_cfg_group_must_panel_config (*curr_grp);
 497         if (need_grp != NULL)
 498             mc_config_del_group (tmp_cfg, need_grp);
 499     }
 500     g_strfreev (groups);
 501 
 502     mc_config_save_file (tmp_cfg, NULL);
 503     mc_config_deinit (tmp_cfg);
 504 }
 505 
 506 /* --------------------------------------------------------------------------------------------- */
 507 
 508 static void
 509 load_config (void)
     /* [previous][next][first][last][top][bottom][index][help]  */
 510 {
 511     size_t i;
 512     const char *kt;
 513 
 514     /* Load boolean options */
 515     for (i = 0; bool_options[i].opt_name != NULL; i++)
 516         *bool_options[i].opt_addr =
 517             mc_config_get_bool (mc_global.main_config, CONFIG_APP_SECTION, bool_options[i].opt_name,
 518                                 *bool_options[i].opt_addr);
 519 
 520     /* Load integer options */
 521     for (i = 0; int_options[i].opt_name != NULL; i++)
 522         *int_options[i].opt_addr =
 523             mc_config_get_int (mc_global.main_config, CONFIG_APP_SECTION, int_options[i].opt_name,
 524                                *int_options[i].opt_addr);
 525 
 526     /* Load string options */
 527     for (i = 0; str_options[i].opt_name != NULL; i++)
 528         *str_options[i].opt_addr =
 529             mc_config_get_string (mc_global.main_config, CONFIG_APP_SECTION,
 530                                   str_options[i].opt_name, str_options[i].opt_defval);
 531 
 532     /* Overwrite some options */
 533 #ifdef USE_INTERNAL_EDIT
 534     if (option_word_wrap_line_length <= 0)
 535         option_word_wrap_line_length = DEFAULT_WRAP_LINE_LENGTH;
 536 #else
 537     /* Reset forced in case of build without internal editor */
 538     use_internal_edit = FALSE;
 539 #endif /* USE_INTERNAL_EDIT */
 540 
 541     if (option_tab_spacing <= 0)
 542         option_tab_spacing = DEFAULT_TAB_SPACING;
 543 
 544     kt = getenv ("KEYBOARD_KEY_TIMEOUT_US");
 545     if (kt != NULL && kt[0] != '\0')
 546         old_esc_mode_timeout = atoi (kt);
 547 }
 548 
 549 /* --------------------------------------------------------------------------------------------- */
 550 
 551 static panel_view_mode_t
 552 setup__load_panel_state (const char *section)
     /* [previous][next][first][last][top][bottom][index][help]  */
 553 {
 554     char *buffer;
 555     size_t i;
 556     panel_view_mode_t mode = view_listing;
 557 
 558     /* Load the display mode */
 559     buffer = mc_config_get_string (mc_global.panels_config, section, "display", "listing");
 560 
 561     for (i = 0; panel_types[i].opt_name != NULL; i++)
 562         if (g_ascii_strcasecmp (panel_types[i].opt_name, buffer) == 0)
 563         {
 564             mode = panel_types[i].opt_type;
 565             break;
 566         }
 567 
 568     g_free (buffer);
 569 
 570     return mode;
 571 }
 572 
 573 /* --------------------------------------------------------------------------------------------- */
 574 
 575 static void
 576 load_layout (void)
     /* [previous][next][first][last][top][bottom][index][help]  */
 577 {
 578     size_t i;
 579 
 580     /* actual options override legacy ones */
 581     for (i = 0; layout_int_options[i].opt_name != NULL; i++)
 582         *layout_int_options[i].opt_addr =
 583             mc_config_get_int (mc_global.main_config, CONFIG_LAYOUT_SECTION,
 584                                layout_int_options[i].opt_name, *layout_int_options[i].opt_addr);
 585 
 586     for (i = 0; layout_bool_options[i].opt_name != NULL; i++)
 587         *layout_bool_options[i].opt_addr =
 588             mc_config_get_bool (mc_global.main_config, CONFIG_LAYOUT_SECTION,
 589                                 layout_bool_options[i].opt_name, *layout_bool_options[i].opt_addr);
 590 
 591     startup_left_mode = setup__load_panel_state ("New Left Panel");
 592     startup_right_mode = setup__load_panel_state ("New Right Panel");
 593 
 594     /* At least one of the panels is a listing panel */
 595     if (startup_left_mode != view_listing && startup_right_mode != view_listing)
 596         startup_left_mode = view_listing;
 597 
 598     boot_current_is_left =
 599         mc_config_get_bool (mc_global.panels_config, "Dirs", "current_is_left", TRUE);
 600 }
 601 
 602 /* --------------------------------------------------------------------------------------------- */
 603 
 604 static void
 605 load_keys_from_section (const char *terminal, mc_config_t * cfg)
     /* [previous][next][first][last][top][bottom][index][help]  */
 606 {
 607     char *section_name;
 608     gchar **profile_keys, **keys;
 609     char *valcopy, *value;
 610     long key_code;
 611 
 612     if (terminal == NULL)
 613         return;
 614 
 615     section_name = g_strconcat ("terminal:", terminal, (char *) NULL);
 616     keys = mc_config_get_keys (cfg, section_name, NULL);
 617 
 618     for (profile_keys = keys; *profile_keys != NULL; profile_keys++)
 619     {
 620         /* copy=other causes all keys from [terminal:other] to be loaded. */
 621         if (g_ascii_strcasecmp (*profile_keys, "copy") == 0)
 622         {
 623             valcopy = mc_config_get_string (cfg, section_name, *profile_keys, "");
 624             load_keys_from_section (valcopy, cfg);
 625             g_free (valcopy);
 626             continue;
 627         }
 628 
 629         key_code = lookup_key (*profile_keys, NULL);
 630         if (key_code != 0)
 631         {
 632             gchar **values;
 633 
 634             values = mc_config_get_string_list (cfg, section_name, *profile_keys, NULL);
 635             if (values != NULL)
 636             {
 637                 gchar **curr_values;
 638 
 639                 for (curr_values = values; *curr_values != NULL; curr_values++)
 640                 {
 641                     valcopy = convert_controls (*curr_values);
 642                     define_sequence (key_code, valcopy, MCKEY_NOACTION);
 643                     g_free (valcopy);
 644                 }
 645 
 646                 g_strfreev (values);
 647             }
 648             else
 649             {
 650                 value = mc_config_get_string (cfg, section_name, *profile_keys, "");
 651                 valcopy = convert_controls (value);
 652                 define_sequence (key_code, valcopy, MCKEY_NOACTION);
 653                 g_free (valcopy);
 654                 g_free (value);
 655             }
 656         }
 657     }
 658     g_strfreev (keys);
 659     g_free (section_name);
 660 }
 661 
 662 /* --------------------------------------------------------------------------------------------- */
 663 
 664 static void
 665 panel_save_type (const char *section, panel_view_mode_t type)
     /* [previous][next][first][last][top][bottom][index][help]  */
 666 {
 667     size_t i;
 668 
 669     for (i = 0; panel_types[i].opt_name != NULL; i++)
 670         if (panel_types[i].opt_type == type)
 671         {
 672             mc_config_set_string (mc_global.panels_config, section, "display",
 673                                   panel_types[i].opt_name);
 674             break;
 675         }
 676 }
 677 
 678 /* --------------------------------------------------------------------------------------------- */
 679 
 680 /**
 681  * Load panels options from [Panels] section.
 682  */
 683 static void
 684 panels_load_options (void)
     /* [previous][next][first][last][top][bottom][index][help]  */
 685 {
 686     if (mc_config_has_group (mc_global.main_config, CONFIG_PANELS_SECTION))
 687     {
 688         size_t i;
 689         int qmode;
 690 
 691         for (i = 0; panels_ini_options[i].opt_name != NULL; i++)
 692             *panels_ini_options[i].opt_addr =
 693                 mc_config_get_bool (mc_global.main_config, CONFIG_PANELS_SECTION,
 694                                     panels_ini_options[i].opt_name,
 695                                     *panels_ini_options[i].opt_addr);
 696 
 697         qmode = mc_config_get_int (mc_global.main_config, CONFIG_PANELS_SECTION,
 698                                    "quick_search_mode", (int) panels_options.qsearch_mode);
 699         if (qmode < 0)
 700             panels_options.qsearch_mode = QSEARCH_CASE_INSENSITIVE;
 701         else if (qmode >= QSEARCH_NUM)
 702             panels_options.qsearch_mode = QSEARCH_PANEL_CASE;
 703         else
 704             panels_options.qsearch_mode = (qsearch_mode_t) qmode;
 705 
 706         panels_options.select_flags =
 707             mc_config_get_int (mc_global.main_config, CONFIG_PANELS_SECTION, "select_flags",
 708                                (int) panels_options.select_flags);
 709     }
 710 }
 711 
 712 /* --------------------------------------------------------------------------------------------- */
 713 
 714 /**
 715  * Save panels options in [Panels] section.
 716  */
 717 static void
 718 panels_save_options (void)
     /* [previous][next][first][last][top][bottom][index][help]  */
 719 {
 720     size_t i;
 721 
 722     for (i = 0; panels_ini_options[i].opt_name != NULL; i++)
 723         mc_config_set_bool (mc_global.main_config, CONFIG_PANELS_SECTION,
 724                             panels_ini_options[i].opt_name, *panels_ini_options[i].opt_addr);
 725 
 726     mc_config_set_int (mc_global.main_config, CONFIG_PANELS_SECTION,
 727                        "quick_search_mode", (int) panels_options.qsearch_mode);
 728     mc_config_set_int (mc_global.main_config, CONFIG_PANELS_SECTION,
 729                        "select_flags", (int) panels_options.select_flags);
 730 }
 731 
 732 /* --------------------------------------------------------------------------------------------- */
 733 
 734 static void
 735 save_config (void)
     /* [previous][next][first][last][top][bottom][index][help]  */
 736 {
 737     size_t i;
 738 
 739     /* Save boolean options */
 740     for (i = 0; bool_options[i].opt_name != NULL; i++)
 741         mc_config_set_bool (mc_global.main_config, CONFIG_APP_SECTION, bool_options[i].opt_name,
 742                             *bool_options[i].opt_addr);
 743 
 744     /* Save integer options */
 745     for (i = 0; int_options[i].opt_name != NULL; i++)
 746         mc_config_set_int (mc_global.main_config, CONFIG_APP_SECTION, int_options[i].opt_name,
 747                            *int_options[i].opt_addr);
 748 
 749     /* Save string options */
 750     for (i = 0; str_options[i].opt_name != NULL; i++)
 751         mc_config_set_string (mc_global.main_config, CONFIG_APP_SECTION, str_options[i].opt_name,
 752                               *str_options[i].opt_addr);
 753 }
 754 
 755 /* --------------------------------------------------------------------------------------------- */
 756 
 757 static void
 758 save_layout (void)
     /* [previous][next][first][last][top][bottom][index][help]  */
 759 {
 760     size_t i;
 761 
 762     /* Save integer options */
 763     for (i = 0; layout_int_options[i].opt_name != NULL; i++)
 764         mc_config_set_int (mc_global.main_config, CONFIG_LAYOUT_SECTION,
 765                            layout_int_options[i].opt_name, *layout_int_options[i].opt_addr);
 766 
 767     /* Save boolean options */
 768     for (i = 0; layout_bool_options[i].opt_name != NULL; i++)
 769         mc_config_set_bool (mc_global.main_config, CONFIG_LAYOUT_SECTION,
 770                             layout_bool_options[i].opt_name, *layout_bool_options[i].opt_addr);
 771 }
 772 
 773 /* --------------------------------------------------------------------------------------------- */
 774 
 775 /* save panels.ini */
 776 static void
 777 save_panel_types (void)
     /* [previous][next][first][last][top][bottom][index][help]  */
 778 {
 779     panel_view_mode_t type;
 780 
 781     if (mc_global.mc_run_mode != MC_RUN_FULL)
 782         return;
 783 
 784     type = get_panel_type (0);
 785     panel_save_type ("New Left Panel", type);
 786     if (type == view_listing)
 787         panel_save_setup (left_panel, left_panel->name);
 788     type = get_panel_type (1);
 789     panel_save_type ("New Right Panel", type);
 790     if (type == view_listing)
 791         panel_save_setup (right_panel, right_panel->name);
 792 
 793     {
 794         char *dirs;
 795 
 796         dirs = get_panel_dir_for (other_panel);
 797         mc_config_set_string (mc_global.panels_config, "Dirs", "other_dir", dirs);
 798         g_free (dirs);
 799     }
 800 
 801     if (current_panel != NULL)
 802         mc_config_set_bool (mc_global.panels_config, "Dirs", "current_is_left",
 803                             get_current_index () == 0);
 804 
 805     if (mc_global.panels_config->ini_path == NULL)
 806         mc_global.panels_config->ini_path = g_strdup (panels_profile_name);
 807 
 808     mc_config_del_group (mc_global.panels_config, "Temporal:New Left Panel");
 809     mc_config_del_group (mc_global.panels_config, "Temporal:New Right Panel");
 810 
 811     mc_config_save_file (mc_global.panels_config, NULL);
 812 }
 813 
 814 /* --------------------------------------------------------------------------------------------- */
 815 /*** public functions ****************************************************************************/
 816 /* --------------------------------------------------------------------------------------------- */
 817 
 818 const char *
 819 setup_init (void)
     /* [previous][next][first][last][top][bottom][index][help]  */
 820 {
 821     if (profile_name == NULL)
 822     {
 823         char *profile;
 824 
 825         profile = mc_config_get_full_path (MC_CONFIG_FILE);
 826         if (!exist_file (profile))
 827         {
 828             char *inifile;
 829 
 830             inifile = mc_build_filename (mc_global.sysconfig_dir, "mc.ini", (char *) NULL);
 831             if (exist_file (inifile))
 832             {
 833                 g_free (profile);
 834                 profile = inifile;
 835             }
 836             else
 837             {
 838                 g_free (inifile);
 839                 inifile = mc_build_filename (mc_global.share_data_dir, "mc.ini", (char *) NULL);
 840                 if (!exist_file (inifile))
 841                     g_free (inifile);
 842                 else
 843                 {
 844                     g_free (profile);
 845                     profile = inifile;
 846                 }
 847             }
 848         }
 849 
 850         profile_name = profile;
 851     }
 852 
 853     return profile_name;
 854 }
 855 
 856 /* --------------------------------------------------------------------------------------------- */
 857 
 858 void
 859 load_setup (void)
     /* [previous][next][first][last][top][bottom][index][help]  */
 860 {
 861     const char *profile;
 862 
 863 #ifdef HAVE_CHARSET
 864     const char *cbuffer;
 865 
 866     load_codepages_list ();
 867 #endif /* HAVE_CHARSET */
 868 
 869     profile = setup_init ();
 870 
 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))
 876     {
 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);
 880     }
 881 
 882     panels_profile_name = mc_config_get_full_path (MC_PANELS_FILE);
 883 
 884     mc_global.main_config = mc_config_init (profile, FALSE);
 885 
 886     if (!exist_file (panels_profile_name))
 887         setup__move_panels_config_into_separate_file (profile);
 888 
 889     mc_global.panels_config = mc_config_init (panels_profile_name, FALSE);
 890 
 891     load_config ();
 892     load_layout ();
 893     panels_load_options ();
 894     load_panelize ();
 895 
 896     /* Load time formats */
 897     user_recent_timeformat =
 898         mc_config_get_string (mc_global.main_config, CONFIG_MISC_SECTION, "timeformat_recent",
 899                               FMTTIME);
 900     user_old_timeformat =
 901         mc_config_get_string (mc_global.main_config, CONFIG_MISC_SECTION, "timeformat_old",
 902                               FMTYEAR);
 903 
 904 #ifdef ENABLE_VFS_FTP
 905     ftpfs_proxy_host =
 906         mc_config_get_string (mc_global.main_config, CONFIG_MISC_SECTION, "ftp_proxy_host", "gate");
 907     ftpfs_init_passwd ();
 908 #endif /* ENABLE_VFS_FTP */
 909 
 910     /* The default color and the terminal dependent color */
 911     mc_global.tty.setup_color_string =
 912         mc_config_get_string (mc_global.main_config, "Colors", "base_color", "");
 913     mc_global.tty.term_color_string =
 914         mc_config_get_string (mc_global.main_config, "Colors", getenv ("TERM"), "");
 915     mc_global.tty.color_terminal_string =
 916         mc_config_get_string (mc_global.main_config, "Colors", "color_terminals", "");
 917 
 918     /* Load the directory history */
 919     /*    directory_history_load (); */
 920     /* Remove the temporal entries */
 921 
 922 #ifdef HAVE_CHARSET
 923     if (codepages->len > 1)
 924     {
 925         char *buffer;
 926 
 927         buffer =
 928             mc_config_get_string (mc_global.main_config, CONFIG_MISC_SECTION, "display_codepage",
 929                                   "");
 930         if (buffer[0] != '\0')
 931         {
 932             mc_global.display_codepage = get_codepage_index (buffer);
 933             cp_display = get_codepage_id (mc_global.display_codepage);
 934         }
 935         g_free (buffer);
 936         buffer =
 937             mc_config_get_string (mc_global.main_config, CONFIG_MISC_SECTION, "source_codepage",
 938                                   "");
 939         if (buffer[0] != '\0')
 940         {
 941             default_source_codepage = get_codepage_index (buffer);
 942             mc_global.source_codepage = default_source_codepage;        /* May be source_codepage doesn't need this */
 943             cp_source = get_codepage_id (mc_global.source_codepage);
 944         }
 945         g_free (buffer);
 946     }
 947 
 948     autodetect_codeset =
 949         mc_config_get_string (mc_global.main_config, CONFIG_MISC_SECTION, "autodetect_codeset", "");
 950     if ((autodetect_codeset[0] != '\0') && (strcmp (autodetect_codeset, "off") != 0))
 951         is_autodetect_codeset_enabled = TRUE;
 952 
 953     g_free (init_translation_table (mc_global.source_codepage, mc_global.display_codepage));
 954     cbuffer = get_codepage_id (mc_global.display_codepage);
 955     if (cbuffer != NULL)
 956         mc_global.utf8_display = str_isutf8 (cbuffer);
 957 #endif /* HAVE_CHARSET */
 958 
 959 #ifdef HAVE_ASPELL
 960     spell_language =
 961         mc_config_get_string (mc_global.main_config, CONFIG_MISC_SECTION, "spell_language", "en");
 962 #endif /* HAVE_ASPELL */
 963 
 964     clipboard_store_path =
 965         mc_config_get_string (mc_global.main_config, CONFIG_MISC_SECTION, "clipboard_store", "");
 966     clipboard_paste_path =
 967         mc_config_get_string (mc_global.main_config, CONFIG_MISC_SECTION, "clipboard_paste", "");
 968 }
 969 
 970 /* --------------------------------------------------------------------------------------------- */
 971 
 972 gboolean
 973 save_setup (gboolean save_options, gboolean save_panel_options)
     /* [previous][next][first][last][top][bottom][index][help]  */
 974 {
 975     gboolean ret = TRUE;
 976 
 977     saving_setup = 1;
 978 
 979     save_hotlist ();
 980 
 981     if (save_panel_options)
 982         save_panel_types ();
 983 
 984     if (save_options)
 985     {
 986         char *tmp_profile;
 987 
 988         save_config ();
 989         save_layout ();
 990         panels_save_options ();
 991         save_panelize ();
 992         /* directory_history_save (); */
 993 
 994 #ifdef ENABLE_VFS_FTP
 995         mc_config_set_string (mc_global.main_config, CONFIG_MISC_SECTION, "ftpfs_password",
 996                               ftpfs_anonymous_passwd);
 997         if (ftpfs_proxy_host)
 998             mc_config_set_string (mc_global.main_config, CONFIG_MISC_SECTION, "ftp_proxy_host",
 999                                   ftpfs_proxy_host);
1000 #endif /* ENABLE_VFS_FTP */
1001 
1002 #ifdef HAVE_CHARSET
1003         mc_config_set_string (mc_global.main_config, CONFIG_MISC_SECTION, "display_codepage",
1004                               get_codepage_id (mc_global.display_codepage));
1005         mc_config_set_string (mc_global.main_config, CONFIG_MISC_SECTION, "source_codepage",
1006                               get_codepage_id (default_source_codepage));
1007         mc_config_set_string (mc_global.main_config, CONFIG_MISC_SECTION, "autodetect_codeset",
1008                               autodetect_codeset);
1009 #endif /* HAVE_CHARSET */
1010 
1011 #ifdef HAVE_ASPELL
1012         mc_config_set_string (mc_global.main_config, CONFIG_MISC_SECTION, "spell_language",
1013                               spell_language);
1014 #endif /* HAVE_ASPELL */
1015 
1016         mc_config_set_string (mc_global.main_config, CONFIG_MISC_SECTION, "clipboard_store",
1017                               clipboard_store_path);
1018         mc_config_set_string (mc_global.main_config, CONFIG_MISC_SECTION, "clipboard_paste",
1019                               clipboard_paste_path);
1020 
1021         tmp_profile = mc_config_get_full_path (MC_CONFIG_FILE);
1022         ret = mc_config_save_to_file (mc_global.main_config, tmp_profile, NULL);
1023         g_free (tmp_profile);
1024     }
1025 
1026     saving_setup = 0;
1027 
1028     return ret;
1029 }
1030 
1031 /* --------------------------------------------------------------------------------------------- */
1032 
1033 void
1034 done_setup (void)
     /* [previous][next][first][last][top][bottom][index][help]  */
1035 {
1036     size_t i;
1037 
1038     g_free (clipboard_store_path);
1039     g_free (clipboard_paste_path);
1040     g_free (global_profile_name);
1041     g_free (mc_global.tty.color_terminal_string);
1042     g_free (mc_global.tty.term_color_string);
1043     g_free (mc_global.tty.setup_color_string);
1044     g_free (profile_name);
1045     g_free (panels_profile_name);
1046     mc_config_deinit (mc_global.main_config);
1047     mc_config_deinit (mc_global.panels_config);
1048 
1049     g_free (user_recent_timeformat);
1050     g_free (user_old_timeformat);
1051 
1052     for (i = 0; str_options[i].opt_name != NULL; i++)
1053         g_free (*str_options[i].opt_addr);
1054 
1055     done_hotlist ();
1056     done_panelize ();
1057     /*    directory_history_free (); */
1058 
1059 #ifdef HAVE_CHARSET
1060     g_free (autodetect_codeset);
1061     free_codepages_list ();
1062 #endif
1063 
1064 #ifdef HAVE_ASPELL
1065     g_free (spell_language);
1066 #endif /* HAVE_ASPELL */
1067 }
1068 
1069 
1070 /* --------------------------------------------------------------------------------------------- */
1071 
1072 void
1073 setup_save_config_show_error (const char *filename, GError ** mcerror)
     /* [previous][next][first][last][top][bottom][index][help]  */
1074 {
1075     if (mcerror != NULL && *mcerror != NULL)
1076     {
1077         message (D_ERROR, MSG_ERROR, _("Cannot save file %s:\n%s"), filename, (*mcerror)->message);
1078         g_error_free (*mcerror);
1079         *mcerror = NULL;
1080     }
1081 }
1082 
1083 /* --------------------------------------------------------------------------------------------- */
1084 
1085 void
1086 load_key_defs (void)
     /* [previous][next][first][last][top][bottom][index][help]  */
1087 {
1088     /*
1089      * Load keys from mc.lib before ${XDG_CONFIG_HOME}/mc/ini, so that the user
1090      * definitions override global settings.
1091      */
1092     mc_config_t *mc_global_config;
1093 
1094     mc_global_config = mc_config_init (global_profile_name, FALSE);
1095     if (mc_global_config != NULL)
1096     {
1097         load_keys_from_section ("general", mc_global_config);
1098         load_keys_from_section (getenv ("TERM"), mc_global_config);
1099         mc_config_deinit (mc_global_config);
1100     }
1101 
1102     load_keys_from_section ("general", mc_global.main_config);
1103     load_keys_from_section (getenv ("TERM"), mc_global.main_config);
1104 }
1105 
1106 /* --------------------------------------------------------------------------------------------- */
1107 
1108 #ifdef ENABLE_VFS_FTP
1109 char *
1110 load_anon_passwd (void)
     /* [previous][next][first][last][top][bottom][index][help]  */
1111 {
1112     char *buffer;
1113 
1114     buffer =
1115         mc_config_get_string (mc_global.main_config, CONFIG_MISC_SECTION, "ftpfs_password", "");
1116 
1117     if ((buffer != NULL) && (buffer[0] != '\0'))
1118         return buffer;
1119 
1120     g_free (buffer);
1121     return NULL;
1122 }
1123 #endif /* ENABLE_VFS_FTP */
1124 
1125 /* --------------------------------------------------------------------------------------------- */
1126 
1127 void
1128 panel_load_setup (WPanel * panel, const char *section)
     /* [previous][next][first][last][top][bottom][index][help]  */
1129 {
1130     size_t i;
1131     char *buffer, buffer2[BUF_TINY];
1132 
1133     panel->sort_info.reverse =
1134         mc_config_get_bool (mc_global.panels_config, section, "reverse", FALSE);
1135     panel->sort_info.case_sensitive =
1136         mc_config_get_bool (mc_global.panels_config, section, "case_sensitive",
1137                             OS_SORT_CASE_SENSITIVE_DEFAULT);
1138     panel->sort_info.exec_first =
1139         mc_config_get_bool (mc_global.panels_config, section, "exec_first", FALSE);
1140 
1141     /* Load sort order */
1142     buffer = mc_config_get_string (mc_global.panels_config, section, "sort_order", "name");
1143     panel->sort_field = panel_get_field_by_id (buffer);
1144     if (panel->sort_field == NULL)
1145         panel->sort_field = panel_get_field_by_id ("name");
1146 
1147     g_free (buffer);
1148 
1149     /* Load the listing format */
1150     buffer = mc_config_get_string (mc_global.panels_config, section, "list_format", NULL);
1151     if (buffer == NULL)
1152     {
1153         /* fallback to old option */
1154         buffer = mc_config_get_string (mc_global.panels_config, section, "list_mode", "full");
1155     }
1156     panel->list_format = list_full;
1157     for (i = 0; list_formats[i].key != NULL; i++)
1158         if (g_ascii_strcasecmp (list_formats[i].key, buffer) == 0)
1159         {
1160             panel->list_format = list_formats[i].list_format;
1161             break;
1162         }
1163     g_free (buffer);
1164 
1165     panel->brief_cols = mc_config_get_int (mc_global.panels_config, section, "brief_cols", 2);
1166 
1167     /* User formats */
1168     g_free (panel->user_format);
1169     panel->user_format =
1170         mc_config_get_string (mc_global.panels_config, section, "user_format", DEFAULT_USER_FORMAT);
1171 
1172     for (i = 0; i < LIST_FORMATS; i++)
1173     {
1174         g_free (panel->user_status_format[i]);
1175         g_snprintf (buffer2, sizeof (buffer2), "user_status%lld", (long long) i);
1176         panel->user_status_format[i] =
1177             mc_config_get_string (mc_global.panels_config, section, buffer2, DEFAULT_USER_FORMAT);
1178     }
1179 
1180     panel->user_mini_status =
1181         mc_config_get_bool (mc_global.panels_config, section, "user_mini_status", FALSE);
1182 }
1183 
1184 /* --------------------------------------------------------------------------------------------- */
1185 
1186 void
1187 panel_save_setup (WPanel * panel, const char *section)
     /* [previous][next][first][last][top][bottom][index][help]  */
1188 {
1189     char buffer[BUF_TINY];
1190     size_t i;
1191 
1192     mc_config_set_bool (mc_global.panels_config, section, "reverse", panel->sort_info.reverse);
1193     mc_config_set_bool (mc_global.panels_config, section, "case_sensitive",
1194                         panel->sort_info.case_sensitive);
1195     mc_config_set_bool (mc_global.panels_config, section, "exec_first",
1196                         panel->sort_info.exec_first);
1197 
1198     mc_config_set_string (mc_global.panels_config, section, "sort_order", panel->sort_field->id);
1199 
1200     for (i = 0; list_formats[i].key != NULL; i++)
1201         if (list_formats[i].list_format == (int) panel->list_format)
1202         {
1203             mc_config_set_string (mc_global.panels_config, section, "list_format",
1204                                   list_formats[i].key);
1205             break;
1206         }
1207 
1208     mc_config_set_int (mc_global.panels_config, section, "brief_cols", panel->brief_cols);
1209 
1210     mc_config_set_string (mc_global.panels_config, section, "user_format", panel->user_format);
1211 
1212     for (i = 0; i < LIST_FORMATS; i++)
1213     {
1214         g_snprintf (buffer, sizeof (buffer), "user_status%lld", (long long) i);
1215         mc_config_set_string (mc_global.panels_config, section, buffer,
1216                               panel->user_status_format[i]);
1217     }
1218 
1219     mc_config_set_bool (mc_global.panels_config, section, "user_mini_status",
1220                         panel->user_mini_status);
1221 }
1222 
1223 /* --------------------------------------------------------------------------------------------- */

/* [previous][next][first][last][top][bottom][index][help]  */