From 4ef9bf5119f6b7dbd9ac6f409e7992b44895a835 Mon Sep 17 00:00:00 2001 From: Andrew Borodin Date: Sat, 28 Jan 2012 18:28:45 +0300 Subject: [PATCH] Added macros for Layout and Misc sections of main config file. Signed-off-by: Andrew Borodin --- lib/mcconfig.h | 2 ++ src/filemanager/find.c | 4 ++-- src/main.c | 3 ++- src/setup.c | 51 ++++++++++++++++++++++++++++++-------------------- 4 files changed, 37 insertions(+), 23 deletions(-) diff --git a/lib/mcconfig.h b/lib/mcconfig.h index 36d736f35..11114386e 100644 --- a/lib/mcconfig.h +++ b/lib/mcconfig.h @@ -5,6 +5,8 @@ #define CONFIG_APP_SECTION "Midnight-Commander" #define CONFIG_PANELS_SECTION "Panels" +#define CONFIG_LAYOUT_SECTION "Layout" +#define CONFIG_MISC_SECTION "Misc" /*** enums ***************************************************************************************/ diff --git a/src/filemanager/find.c b/src/filemanager/find.c index c85226822..b4208011c 100644 --- a/src/filemanager/find.c +++ b/src/filemanager/find.c @@ -298,8 +298,8 @@ find_load_options (void) mc_config_get_bool (mc_main_config, "FindFile", "ignore_dirs_enable", TRUE); /* Back compatibility: try load old parameter at first */ - ignore_dirs = mc_config_get_string (mc_main_config, "Misc", "find_ignore_dirs", ""); - mc_config_del_key (mc_main_config, "Misc", "find_ignore_dirs"); + ignore_dirs = mc_config_get_string (mc_main_config, CONFIG_MISC_SECTION, "find_ignore_dirs", ""); + mc_config_del_key (mc_main_config, CONFIG_MISC_SECTION, "find_ignore_dirs"); /* Then load new parameters */ options.ignore_dirs = mc_config_get_string (mc_main_config, "FindFile", "ignore_dirs", ""); diff --git a/src/main.c b/src/main.c index a26b27185..d88ffab28 100644 --- a/src/main.c +++ b/src/main.c @@ -147,7 +147,8 @@ check_codeset (void) if (mc_global.display_codepage == -1) mc_global.display_codepage = 0; - mc_config_set_string (mc_main_config, "Misc", "display_codepage", cp_display); + mc_config_set_string (mc_main_config, CONFIG_MISC_SECTION, "display_codepage", + cp_display); } } #endif diff --git a/src/setup.c b/src/setup.c index c3e045d70..1aa5f44fb 100644 --- a/src/setup.c +++ b/src/setup.c @@ -557,7 +557,7 @@ load_layout (void) /* actual options override legacy ones */ for (i = 0; layout[i].opt_name != NULL; i++) - *layout[i].opt_addr = mc_config_get_int (mc_main_config, "Layout", + *layout[i].opt_addr = mc_config_get_int (mc_main_config, CONFIG_LAYOUT_SECTION, layout[i].opt_name, *layout[i].opt_addr); /* remove legacy options */ @@ -934,13 +934,15 @@ load_setup (void) /* Load time formats */ user_recent_timeformat = - mc_config_get_string (mc_main_config, "Misc", "timeformat_recent", FMTTIME); - user_old_timeformat = mc_config_get_string (mc_main_config, "Misc", "timeformat_old", FMTYEAR); + mc_config_get_string (mc_main_config, CONFIG_MISC_SECTION, "timeformat_recent", FMTTIME); + user_old_timeformat = + mc_config_get_string (mc_main_config, CONFIG_MISC_SECTION, "timeformat_old", FMTYEAR); #ifdef ENABLE_VFS_FTP - ftpfs_proxy_host = mc_config_get_string (mc_main_config, "Misc", "ftp_proxy_host", "gate"); - ftpfs_ignore_chattr_errors = mc_config_get_bool (mc_main_config, CONFIG_APP_SECTION, - "ignore_ftp_chattr_errors", TRUE); + ftpfs_proxy_host = + mc_config_get_string (mc_main_config, CONFIG_MISC_SECTION, "ftp_proxy_host", "gate"); + ftpfs_ignore_chattr_errors = + mc_config_get_bool (mc_main_config, CONFIG_APP_SECTION, "ignore_ftp_chattr_errors", TRUE); ftpfs_init_passwd (); #endif /* ENABLE_VFS_FTP */ @@ -959,14 +961,14 @@ load_setup (void) #ifdef HAVE_CHARSET if (codepages->len > 1) { - buffer = mc_config_get_string (mc_main_config, "Misc", "display_codepage", ""); + buffer = mc_config_get_string (mc_main_config, CONFIG_MISC_SECTION, "display_codepage", ""); if (buffer[0] != '\0') { mc_global.display_codepage = get_codepage_index (buffer); cp_display = get_codepage_id (mc_global.display_codepage); } g_free (buffer); - buffer = mc_config_get_string (mc_main_config, "Misc", "source_codepage", ""); + buffer = mc_config_get_string (mc_main_config, CONFIG_MISC_SECTION, "source_codepage", ""); if (buffer[0] != '\0') { default_source_codepage = get_codepage_index (buffer); @@ -976,7 +978,8 @@ load_setup (void) g_free (buffer); } - autodetect_codeset = mc_config_get_string (mc_main_config, "Misc", "autodetect_codeset", ""); + autodetect_codeset = + mc_config_get_string (mc_main_config, CONFIG_MISC_SECTION, "autodetect_codeset", ""); if ((autodetect_codeset[0] != '\0') && (strcmp (autodetect_codeset, "off") != 0)) is_autodetect_codeset_enabled = TRUE; @@ -986,8 +989,10 @@ load_setup (void) mc_global.utf8_display = str_isutf8 (buffer); #endif /* HAVE_CHARSET */ - clipboard_store_path = mc_config_get_string (mc_main_config, "Misc", "clipboard_store", ""); - clipboard_paste_path = mc_config_get_string (mc_main_config, "Misc", "clipboard_paste", ""); + clipboard_store_path = + mc_config_get_string (mc_main_config, CONFIG_MISC_SECTION, "clipboard_store", ""); + clipboard_paste_path = + mc_config_get_string (mc_main_config, CONFIG_MISC_SECTION, "clipboard_paste", ""); } /* --------------------------------------------------------------------------------------------- */ @@ -1015,20 +1020,25 @@ save_setup (gboolean save_options, gboolean save_panel_options) /* directory_history_save (); */ #ifdef ENABLE_VFS_FTP - mc_config_set_string (mc_main_config, "Misc", "ftpfs_password", ftpfs_anonymous_passwd); + mc_config_set_string (mc_main_config, CONFIG_MISC_SECTION, "ftpfs_password", + ftpfs_anonymous_passwd); if (ftpfs_proxy_host) - mc_config_set_string (mc_main_config, "Misc", "ftp_proxy_host", ftpfs_proxy_host); + mc_config_set_string (mc_main_config, CONFIG_MISC_SECTION, "ftp_proxy_host", + ftpfs_proxy_host); #endif /* ENABLE_VFS_FTP */ #ifdef HAVE_CHARSET - mc_config_set_string (mc_main_config, "Misc", "display_codepage", + mc_config_set_string (mc_main_config, CONFIG_MISC_SECTION, "display_codepage", get_codepage_id (mc_global.display_codepage)); - mc_config_set_string (mc_main_config, "Misc", "source_codepage", + mc_config_set_string (mc_main_config, CONFIG_MISC_SECTION, "source_codepage", get_codepage_id (default_source_codepage)); - mc_config_set_string (mc_main_config, "Misc", "autodetect_codeset", autodetect_codeset); + mc_config_set_string (mc_main_config, CONFIG_MISC_SECTION, "autodetect_codeset", + autodetect_codeset); #endif /* HAVE_CHARSET */ - mc_config_set_string (mc_main_config, "Misc", "clipboard_store", clipboard_store_path); - mc_config_set_string (mc_main_config, "Misc", "clipboard_paste", clipboard_paste_path); + mc_config_set_string (mc_main_config, CONFIG_MISC_SECTION, "clipboard_store", + clipboard_store_path); + mc_config_set_string (mc_main_config, CONFIG_MISC_SECTION, "clipboard_paste", + clipboard_paste_path); tmp_profile = mc_config_get_full_path (MC_CONFIG_FILE); ret = mc_config_save_to_file (mc_main_config, tmp_profile, NULL); @@ -1114,7 +1124,8 @@ save_layout (void) /* Save integer options */ for (i = 0; layout[i].opt_name != NULL; i++) - mc_config_set_int (mc_main_config, "Layout", layout[i].opt_name, *layout[i].opt_addr); + mc_config_set_int (mc_main_config, CONFIG_LAYOUT_SECTION, layout[i].opt_name, + *layout[i].opt_addr); } /* --------------------------------------------------------------------------------------------- */ @@ -1148,7 +1159,7 @@ load_anon_passwd (void) { char *buffer; - buffer = mc_config_get_string (mc_main_config, "Misc", "ftpfs_password", ""); + buffer = mc_config_get_string (mc_main_config, CONFIG_MISC_SECTION, "ftpfs_password", ""); if ((buffer != NULL) && (buffer[0] != '\0')) return buffer; -- 2.11.4.GIT