Esempio n. 1
0
gboolean
mc_skin_ini_file_parse (mc_skin_t * mc_skin)
{
    mc_skin->description =
        mc_config_get_string (mc_skin->config, "skin", "description", "- no description -");
    if (!mc_skin_color_parse_ini_file (mc_skin))
        return FALSE;

    mc_skin_lines_parse_ini_file (mc_skin);
    mc_skin->have_256_colors = mc_config_get_bool (mc_skin->config, "skin", "256colors", FALSE);
    mc_skin->have_true_colors = mc_config_get_bool (mc_skin->config, "skin", "truecolors", FALSE);

    return TRUE;
}
Esempio n. 2
0
/**
  Load panels options from [Panels] section.
*/
void
panels_load_options (void)
{
    if (mc_config_has_group (mc_main_config, CONFIG_PANELS_SECTION))
    {
        size_t i;
        int qmode;

        for (i = 0; panels_ini_options[i].opt_name != NULL; i++)
            *panels_ini_options[i].opt_addr =
                mc_config_get_bool (mc_main_config, CONFIG_PANELS_SECTION,
                                    panels_ini_options[i].opt_name,
                                    *panels_ini_options[i].opt_addr);

        qmode = mc_config_get_int (mc_main_config, CONFIG_PANELS_SECTION,
                                   "quick_search_mode", (int) panels_options.qsearch_mode);
        if (qmode < 0)
            panels_options.qsearch_mode = QSEARCH_CASE_INSENSITIVE;
        else if (qmode >= QSEARCH_NUM)
            panels_options.qsearch_mode = QSEARCH_PANEL_CASE;
        else
            panels_options.qsearch_mode = (qsearch_mode_t) qmode;

        panels_options.select_flags =
            mc_config_get_int (mc_main_config, CONFIG_PANELS_SECTION, "select_flags",
                               (int) panels_options.select_flags);
    }
}
Esempio n. 3
0
/* *INDENT-OFF* */
END_PARAMETRIZED_TEST
/* *INDENT-ON* */

/* --------------------------------------------------------------------------------------------- */

/* *INDENT-OFF* */
START_TEST (test_deserialize_config)
/* *INDENT-ON* */
{
    /* given */
    mc_config_t *actual;
    char *actual_value;

    /* when */
    actual = mc_deserialize_config (deserialize_input_value1, &error);

    /* then */
    mctest_assert_not_null (actual);

    actual_value = mc_config_get_string_raw (actual, "group1", "param1", "");
    mctest_assert_str_eq (actual_value, "some value");
    g_free (actual_value);

    actual_value = mc_config_get_string (actual, "group1", "param2", "");
    mctest_assert_str_eq (actual_value, "some value ");
    g_free (actual_value);

    mctest_assert_int_eq (mc_config_get_bool (actual, "group2", "param1", FALSE), TRUE);

    mctest_assert_int_eq (mc_config_get_int (actual, "group2", "param2", 0), 123456);

    actual_value = mc_config_get_string_raw (actual, "group3", "param1", "");
    mctest_assert_str_eq (actual_value, "::bla-bla::");
    g_free (actual_value);

    actual_value = mc_config_get_string (actual, "group3", "param2", "");
    mctest_assert_str_eq (actual_value, "bla-:p1:w:v2:12:g3:123:bla-bla\n");
    g_free (actual_value);

    mctest_assert_int_eq (mc_config_get_bool (actual, "group4", "param1", TRUE), FALSE);

    mctest_assert_int_eq (mc_config_get_int (actual, "group4", "param2", 0), 654321);

    mc_config_deinit (actual);
}
Esempio n. 4
0
static gboolean
mc_fhl_parse_get_extensions (mc_fhl_t * fhl, const gchar * group_name)
{
    mc_fhl_filter_t *mc_filter;
    gchar **exts, **exts_orig;
    gsize exts_size;
    GString *buf;

    exts_orig = exts =
        mc_config_get_string_list (fhl->config, group_name, "extensions", &exts_size);

    if (exts_orig == NULL || exts_orig[0] == NULL)
    {
        g_strfreev (exts_orig);
        return FALSE;
    }

    buf = g_string_sized_new (64);
    for (exts = exts_orig; *exts != NULL; exts++)
    {
        char *esc_ext;

        esc_ext = strutils_regex_escape (*exts);
        if (buf->len != 0)
            g_string_append_c (buf, '|');
        g_string_append (buf, esc_ext);
        g_free (esc_ext);
    }
    g_strfreev (exts_orig);

    g_string_prepend (buf, ".*\\.(");
    g_string_append (buf, ")$");

    mc_filter = g_new0 (mc_fhl_filter_t, 1);
    mc_filter->type = MC_FLHGH_T_FREGEXP;
    mc_filter->search_condition = mc_search_new (buf->str, -1);
    mc_filter->search_condition->is_case_sensitive =
        mc_config_get_bool (fhl->config, group_name, "extensions_case", TRUE);
    mc_filter->search_condition->search_type = MC_SEARCH_T_REGEX;

    mc_fhl_parse_fill_color_info (mc_filter, fhl, group_name);
    g_ptr_array_add (fhl->filters, (gpointer) mc_filter);
    g_string_free (buf, TRUE);
    return TRUE;
}
Esempio n. 5
0
void
panel_options_box (void)
{
    int simple_swap;

    simple_swap = mc_config_get_bool (mc_main_config, CONFIG_PANELS_SECTION,
                                      "simple_swap", FALSE) ? 1 : 0;
    {
        const char *qsearch_options[] = {
            N_("Case &insensitive"),
            N_("Cas&e sensitive"),
            N_("Use panel sort mo&de")
        };

        quick_widget_t quick_widgets[] = {
            /* *INDENT-OFF* */
            QUICK_START_COLUMNS,
                QUICK_START_GROUPBOX (N_("Main options")),
                    QUICK_CHECKBOX (N_("Show mi&ni-status"), &panels_options.show_mini_info, NULL),
                    QUICK_CHECKBOX (N_("Use SI si&ze units"), &panels_options.kilobyte_si, NULL),
                    QUICK_CHECKBOX (N_("Mi&x all files"), &panels_options.mix_all_files, NULL),
                    QUICK_CHECKBOX (N_("Show &backup files"), &panels_options.show_backups, NULL),
                    QUICK_CHECKBOX (N_("Show &hidden files"), &panels_options.show_dot_files, NULL),
                    QUICK_CHECKBOX (N_("&Fast dir reload"), &panels_options.fast_reload, NULL),
                    QUICK_CHECKBOX (N_("Ma&rk moves down"), &panels_options.mark_moves_down, NULL),
                    QUICK_CHECKBOX (N_("Re&verse files only"), &panels_options.reverse_files_only,
                                    NULL),
                    QUICK_CHECKBOX (N_("Simple s&wap"), &simple_swap, NULL),
                    QUICK_CHECKBOX (N_("A&uto save panels setup"), &panels_options.auto_save_setup,
                                    NULL),
                    QUICK_SEPARATOR (FALSE),
                    QUICK_SEPARATOR (FALSE),
                QUICK_STOP_GROUPBOX,
            QUICK_NEXT_COLUMN,
                QUICK_START_GROUPBOX (N_("Navigation")),
                    QUICK_CHECKBOX (N_("L&ynx-like motion"), &panels_options.navigate_with_arrows,
                                    NULL),
                    QUICK_CHECKBOX (N_("Pa&ge scrolling"), &panels_options.scroll_pages, NULL),
                    QUICK_CHECKBOX (N_("&Mouse page scrolling"), &panels_options.mouse_move_pages,
                                    NULL),
                QUICK_STOP_GROUPBOX,
                QUICK_START_GROUPBOX (N_("File highlight")),
                    QUICK_CHECKBOX (N_("File &types"), &panels_options.filetype_mode, NULL),
                    QUICK_CHECKBOX (N_("&Permissions"), &panels_options.permission_mode, NULL),
                QUICK_STOP_GROUPBOX,
                QUICK_START_GROUPBOX (N_("Quick search")),
                    QUICK_RADIO (QSEARCH_NUM, qsearch_options, (int *) &panels_options.qsearch_mode,
                                 NULL),
                QUICK_STOP_GROUPBOX,
            QUICK_STOP_COLUMNS,
            QUICK_BUTTONS_OK_CANCEL,
            QUICK_END
            /* *INDENT-ON* */
        };

        quick_dialog_t qdlg = {
            -1, -1, 60,
            N_("Panel options"), "[Panel options]",
            quick_widgets, NULL, NULL
        };

        if (quick_dialog (&qdlg) != B_ENTER)
            return;
    }

    mc_config_set_bool (mc_main_config, CONFIG_PANELS_SECTION,
                        "simple_swap", (gboolean) (simple_swap & C_BOOL));

    if (!panels_options.fast_reload_msg_shown && panels_options.fast_reload)
    {
        message (D_NORMAL, _("Information"),
                 _("Using the fast reload option may not reflect the exact\n"
                   "directory contents. In this case you'll need to do a\n"
                   "manual reload of the directory. See the man page for\n" "the details."));
        panels_options.fast_reload_msg_shown = TRUE;
    }

    update_panels (UP_RELOAD, UP_KEEPSEL);
}
Esempio n. 6
0
File: layout.c Progetto: m32/mc
void
swap_panels (void)
{
    WPanel *panel1, *panel2;
    Widget *tmp_widget;

    panel1 = PANEL (panels[0].widget);
    panel2 = PANEL (panels[1].widget);

    if (panels[0].type == view_listing && panels[1].type == view_listing &&
            !mc_config_get_bool (mc_main_config, CONFIG_PANELS_SECTION, "simple_swap", FALSE))
    {
        WPanel panel;

#define panelswap(x) panel.x = panel1->x; panel1->x = panel2->x; panel2->x = panel.x;

#define panelswapstr(e) strcpy (panel.e, panel1->e); \
                        strcpy (panel1->e, panel2->e); \
                        strcpy (panel2->e, panel.e);
        /* Change content and related stuff */
        panelswap (dir);
        panelswap (active);
        panelswap (cwd_vpath);
        panelswap (lwd_vpath);
        panelswap (marked);
        panelswap (dirs_marked);
        panelswap (total);
        panelswap (top_file);
        panelswap (selected);
        panelswap (is_panelized);
        panelswap (dir_stat);
#undef panelswapstr
#undef panelswap

        panel1->searching = FALSE;
        panel2->searching = FALSE;

        if (current_panel == panel1)
            current_panel = panel2;
        else
            current_panel = panel1;

        /* if sort options are different -> resort panels */
        if (memcmp (&panel1->sort_info, &panel2->sort_info, sizeof (dir_sort_options_t)) != 0)
        {
            panel_re_sort (other_panel);
            panel_re_sort (current_panel);
        }

        if (widget_is_active (panels[0].widget))
            dlg_select_widget (panels[1].widget);
        else if (widget_is_active (panels[1].widget))
            dlg_select_widget (panels[0].widget);
    }
    else
    {
        WPanel *tmp_panel;
        int x, y, cols, lines;
        int tmp_type;

        tmp_panel = right_panel;
        right_panel = left_panel;
        left_panel = tmp_panel;

        if (panels[0].type == view_listing)
        {
            if (strcmp (panel1->panel_name, get_nth_panel_name (0)) == 0)
            {
                g_free (panel1->panel_name);
                panel1->panel_name = g_strdup (get_nth_panel_name (1));
            }
        }
        if (panels[1].type == view_listing)
        {
            if (strcmp (panel2->panel_name, get_nth_panel_name (1)) == 0)
            {
                g_free (panel2->panel_name);
                panel2->panel_name = g_strdup (get_nth_panel_name (0));
            }
        }

        x = panels[0].widget->x;
        y = panels[0].widget->y;
        cols = panels[0].widget->cols;
        lines = panels[0].widget->lines;

        panels[0].widget->x = panels[1].widget->x;
        panels[0].widget->y = panels[1].widget->y;
        panels[0].widget->cols = panels[1].widget->cols;
        panels[0].widget->lines = panels[1].widget->lines;

        panels[1].widget->x = x;
        panels[1].widget->y = y;
        panels[1].widget->cols = cols;
        panels[1].widget->lines = lines;

        tmp_widget = panels[0].widget;
        panels[0].widget = panels[1].widget;
        panels[1].widget = tmp_widget;
        tmp_type = panels[0].type;
        panels[0].type = panels[1].type;
        panels[1].type = tmp_type;

        /* force update formats because of possible changed sizes */
        if (panels[0].type == view_listing)
            set_panel_formats (PANEL (panels[0].widget));
        if (panels[1].type == view_listing)
            set_panel_formats (PANEL (panels[1].widget));
    }
}
Esempio n. 7
0
File: option.c Progetto: ryanlee/mc
void
panel_options_box (void)
{
    int dlg_width = 60;
    int dlg_height = 19;

    int simple_swap = mc_config_get_bool (mc_main_config, CONFIG_PANELS_SECTION,
                                          "simple_swap", FALSE) ? 1 : 0;

    const char *qsearch_options[] = {
        N_("Case &insensitive"),
        N_("Case s&ensitive"),
        N_("Use panel sort mo&de")
    };

    QuickWidget quick_widgets[] = {
        /* buttons */
        QUICK_BUTTON (38, dlg_width, dlg_height - 3, dlg_height, N_("&Cancel"), B_CANCEL, NULL),
        QUICK_BUTTON (14, dlg_width, dlg_height - 3, dlg_height, N_("&OK"), B_ENTER, NULL),
        /* quick search */
        QUICK_RADIO (dlg_width / 2 + 2, dlg_width, 12, dlg_height, QSEARCH_NUM, qsearch_options,
                     (int *) &panels_options.qsearch_mode),
        QUICK_GROUPBOX (dlg_width / 2, dlg_width, 11, dlg_height, dlg_width / 2 - 4,
                        QSEARCH_NUM + 2,
                        N_("Quick search")),
        /* file highlighting */
        QUICK_CHECKBOX (dlg_width / 2 + 2, dlg_width, 9, dlg_height, N_("&Permissions"),
                        &panels_options.permission_mode),
        QUICK_CHECKBOX (dlg_width / 2 + 2, dlg_width, 8, dlg_height, N_("File &types"),
                        &panels_options.filetype_mode),
        QUICK_GROUPBOX (dlg_width / 2, dlg_width, 7, dlg_height, dlg_width / 2 - 4, 4,
                        N_("File highlight")),
        /* navigation */
        QUICK_CHECKBOX (dlg_width / 2 + 2, dlg_width, 5, dlg_height, N_("&Mouse page scrolling"),
                        &panels_options.mouse_move_pages),
        QUICK_CHECKBOX (dlg_width / 2 + 2, dlg_width, 4, dlg_height, N_("Pa&ge scrolling"),
                        &panels_options.scroll_pages),
        QUICK_CHECKBOX (dlg_width / 2 + 2, dlg_width, 3, dlg_height, N_("L&ynx-like motion"),
                        &panels_options.navigate_with_arrows),
        QUICK_GROUPBOX (dlg_width / 2, dlg_width, 2, dlg_height, dlg_width / 2 - 4, 5,
                        N_("Navigation")),
        /* main panel options */
        QUICK_CHECKBOX (5, dlg_width, 12, dlg_height, N_("A&uto save panels setup"),
                        &panels_options.auto_save_setup),
        QUICK_CHECKBOX (5, dlg_width, 11, dlg_height, N_("Simple s&wap"),
                        &simple_swap),
        QUICK_CHECKBOX (5, dlg_width, 10, dlg_height, N_("Re&verse files only"),
                        &panels_options.reverse_files_only),
        QUICK_CHECKBOX (5, dlg_width, 9, dlg_height, N_("Ma&rk moves down"),
                        &panels_options.mark_moves_down),
        QUICK_CHECKBOX (5, dlg_width, 8, dlg_height, N_("&Fast dir reload"),
                        &panels_options.fast_reload),
        QUICK_CHECKBOX (5, dlg_width, 7, dlg_height, N_("Show &hidden files"),
                        &panels_options.show_dot_files),
        QUICK_CHECKBOX (5, dlg_width, 6, dlg_height, N_("Show &backup files"),
                        &panels_options.show_backups),
        QUICK_CHECKBOX (5, dlg_width, 5, dlg_height, N_("Mi&x all files"),
                        &panels_options.mix_all_files),
        QUICK_CHECKBOX (5, dlg_width, 4, dlg_height, N_("Use SI si&ze units"),
                        &panels_options.kilobyte_si),
        QUICK_CHECKBOX (5, dlg_width, 3, dlg_height, N_("Show mi&ni-status"),
                        &panels_options.show_mini_info),
        QUICK_GROUPBOX (3, dlg_width, 2, dlg_height, dlg_width / 2 - 4, 14,
                        N_("Main options")),
        QUICK_END
    };

    const size_t qw_num = G_N_ELEMENTS (quick_widgets) - 1;

    QuickDialog Quick_input = {
        dlg_width, dlg_height, -1, -1,
        N_("Panel options"), "[Panel options]",
        quick_widgets, NULL, TRUE
    };

    int b0_len, b1_len;
    int b_len, c_len, g_len;
    size_t i;

#ifdef ENABLE_NLS
    for (i = 0; i < qw_num; i++)
        switch (i)
        {
        case 0:
        case 1:
            /* buttons */
            quick_widgets[i].u.button.text = _(quick_widgets[i].u.button.text);
            break;
        case 2:
            {
                /* radio button */
                size_t j;
                for (j = 0; j < QSEARCH_NUM; j++)
                    qsearch_options[j] = _(qsearch_options[j]);
            }
            break;
        case 3:
        case 6:
        case 10:
        case 21:
            /* groupboxes */
            quick_widgets[i].u.groupbox.title = _(quick_widgets[i].u.groupbox.title);
            break;
        default:
            /* checkboxes */
            quick_widgets[i].u.checkbox.text = _(quick_widgets[i].u.checkbox.text);
            break;
        }

    Quick_input.title = _(Quick_input.title);
#endif /* ENABLE_NLS */

    /* calculate widget and dialog widths */
    /* dialog title */
    dlg_width = max (dlg_width, str_term_width1 (Quick_input.title) + 4);
    /* buttons */
    b0_len = str_term_width1 (quick_widgets[0].u.button.text) + 3;
    b1_len = str_term_width1 (quick_widgets[1].u.button.text) + 5;
    b_len = b0_len + b1_len + 1;

    /* checkboxes within groupboxes */
    c_len = 0;
    for (i = 4; i < 21; i++)
        if ((i != 6) && (i != 10))
            c_len = max (c_len, str_term_width1 (quick_widgets[i].u.checkbox.text) + 4);

    /* radiobuttons */
    for (i = 0; i < QSEARCH_NUM; i++)
        c_len = max (c_len, str_term_width1 (qsearch_options[i]) + 3);
    /* groupboxes */
    g_len = max (c_len + 2, str_term_width1 (quick_widgets[3].u.groupbox.title) + 4);
    g_len = max (g_len, str_term_width1 (quick_widgets[6].u.groupbox.title) + 4);
    g_len = max (g_len, str_term_width1 (quick_widgets[10].u.groupbox.title) + 4);
    g_len = max (g_len, str_term_width1 (quick_widgets[21].u.groupbox.title) + 4);
    /* dialog width */
    Quick_input.xlen = max (dlg_width, g_len * 2 + 9);
    Quick_input.xlen = max (Quick_input.xlen, b_len + 2);
    if ((Quick_input.xlen & 1) != 0)
        Quick_input.xlen++;

    /* fix widget parameters */
    for (i = 0; i < qw_num; i++)
        quick_widgets[i].x_divisions = Quick_input.xlen;

    /* groupboxes */
    quick_widgets[3].u.groupbox.width =
        quick_widgets[6].u.groupbox.width =
        quick_widgets[10].u.groupbox.width = Quick_input.xlen / 2 - 3;
    quick_widgets[21].u.groupbox.width = Quick_input.xlen / 2 - 4;

    /* right column */
    quick_widgets[3].relative_x =
        quick_widgets[6].relative_x = quick_widgets[10].relative_x = Quick_input.xlen / 2;
    for (i = 2; i < 10; i++)
        if ((i != 3) && (i != 6))
            quick_widgets[i].relative_x = quick_widgets[3].relative_x + 2;

    /* buttons */
    quick_widgets[1].relative_x = (Quick_input.xlen - b_len) / 3;
    quick_widgets[0].relative_x = 2 * quick_widgets[1].relative_x + b1_len + 1;

    if (quick_dialog (&Quick_input) != B_ENTER)
        return;

    mc_config_set_bool (mc_main_config, CONFIG_PANELS_SECTION,
                        "simple_swap", (gboolean) (simple_swap & C_BOOL));

    if (!panels_options.fast_reload_msg_shown && panels_options.fast_reload)
    {
        message (D_NORMAL, _("Information"),
                 _("Using the fast reload option may not reflect the exact\n"
                   "directory contents. In this case you'll need to do a\n"
                   "manual reload of the directory. See the man page for\n" "the details."));
        panels_options.fast_reload_msg_shown = TRUE;
    }

    update_panels (UP_RELOAD, UP_KEEPSEL);
}
Esempio n. 8
0
END_TEST

/* --------------------------------------------------------------------------------------------- */

#undef deserialize_check_incorrect
#define deserialize_check_incorrect( etalon_code, etalon_str ) { \
    if (actual != NULL) \
    { \
        fail("actual value but should be NULL", actual); \
        mc_config_deinit(actual); \
    } \
    else \
    { \
        fail_unless (error->code == etalon_code && strcmp(error->message, etalon_str) == 0, \
            "\nerror code is %d (should be %d);\nerror message is '%s' (should be '%s')", \
            error->code, etalon_code, error->message, etalon_str); \
        g_clear_error(&error); \
    } \
}

START_TEST (test_deserialize_config)
{
    mc_config_t *actual;
    GError *error = NULL;
    char *actual_value;

    actual = mc_deserialize_config ("g123error in group name", &error);
    deserialize_check_incorrect( -3,
        "mc_deserialize_config() at 1: mc_serialize_str(): Length delimiter ':' doesn't exists");

    actual = mc_deserialize_config ("p6:param1v10:some valuep6:param2v11:some value ", &error);
    deserialize_check_incorrect( -2,
        "mc_deserialize_config() at 1: mc_serialize_str(): String prefix doesn't equal to 'g'");

    actual = mc_deserialize_config ("g6:group1v10:some valuep6:param2v11:some value ", &error);
    deserialize_check_incorrect( -2,
        "mc_deserialize_config() at 10: mc_serialize_str(): String prefix doesn't equal to 'p'");

    actual = mc_deserialize_config ("g6:group1p6000:param2v11:some value ", &error);
    deserialize_check_incorrect( -3,
        "mc_deserialize_config() at 10: mc_serialize_str(): Specified data length (6000) is greater than actual data length (21)");

    actual = mc_deserialize_config (etalon_str, &error);

    if (actual == NULL)
    {
        fail("actual value is NULL!\nError code is '%d'; error message is '%s'", error->code, error->message);
        g_clear_error(&error);
        return;
    }

    actual_value = mc_config_get_string_raw(actual, "group1", "param1", "");
    fail_unless( strcmp(actual_value, "some value") == 0,
        "group1->param1(%s) should be equal to 'some value'", actual_value);
    g_free(actual_value);

    actual_value = mc_config_get_string(actual, "group1", "param2", "");
    fail_unless( strcmp(actual_value, "some value ") == 0,
        "group1->param2(%s) should be equal to 'some value '", actual_value);
    g_free(actual_value);

    fail_unless( mc_config_get_bool(actual, "group2", "param1", FALSE) == TRUE,
        "group2->param1(FALSE) should be equal to TRUE");

    fail_unless( mc_config_get_int(actual, "group2", "param2", 0) == 123456,
        "group2->param2(%d) should be equal to 123456", mc_config_get_int(actual, "group2", "param2", 0));

    actual_value = mc_config_get_string_raw(actual, "group3", "param1", "");
    fail_unless( strcmp(actual_value, "::bla-bla::") == 0,
        "group3->param1(%s) should be equal to '::bla-bla::'", actual_value);
    g_free(actual_value);

    actual_value = mc_config_get_string(actual, "group3", "param2", "");
    fail_unless( strcmp(actual_value, "bla-:p1:w:v2:12:g3:123:bla-bla\n") == 0,
        "group3->param2(%s) should be equal to 'bla-:p1:w:v2:12:g3:123:bla-bla\n'", actual_value);
    g_free(actual_value);

    fail_unless( mc_config_get_bool(actual, "group4", "param1", TRUE) == FALSE,
        "group4->param1(TRUE) should be equal to FALSE");

    fail_unless( mc_config_get_int(actual, "group4", "param2", 0) == 654321,
        "group4->param2(%d) should be equal to 654321", mc_config_get_int(actual, "group4", "param2", 0));

    mc_config_deinit (actual);
}
Esempio n. 9
0
void
load_setup (void)
{
    const char *profile;
    size_t i;
    const char *kt;

#ifdef HAVE_CHARSET
    char *buffer;

    load_codepages_list ();
#endif /* HAVE_CHARSET */

    profile = setup_init ();

    /* mc.lib is common for all users, but has priority lower than
       ${XDG_CONFIG_HOME}/mc/ini.  FIXME: it's only used for keys and treestore now */
    global_profile_name =
        g_build_filename (mc_global.sysconfig_dir, MC_GLOBAL_CONFIG_FILE, (char *) NULL);
    if (!exist_file (global_profile_name))
    {
        g_free (global_profile_name);
        global_profile_name =
            g_build_filename (mc_global.share_data_dir, MC_GLOBAL_CONFIG_FILE, (char *) NULL);
    }

    panels_profile_name = mc_config_get_full_path (MC_PANELS_FILE);

    mc_main_config = mc_config_init (profile, FALSE);

    if (!exist_file (panels_profile_name))
        setup__move_panels_config_into_separate_file (profile);

    mc_panels_config = mc_config_init (panels_profile_name, FALSE);

    /* Load integer boolean options */
    for (i = 0; int_options[i].opt_name != NULL; i++)
        *int_options[i].opt_addr =
            mc_config_get_int (mc_main_config, CONFIG_APP_SECTION, int_options[i].opt_name,
                               *int_options[i].opt_addr);
#ifndef USE_INTERNAL_EDIT
    /* reset forced in case of build without internal editor */
    use_internal_edit = 0;
#endif /* USE_INTERNAL_EDIT */

    if (option_tab_spacing <= 0)
        option_tab_spacing = DEFAULT_TAB_SPACING;

#ifdef USE_INTERNAL_EDIT
    if (option_word_wrap_line_length <= 0)
        option_word_wrap_line_length = DEFAULT_WRAP_LINE_LENGTH;
#endif /* USE_INTERNAL_EDIT */

    /* overwrite old_esc_mode_timeout */
    kt = getenv ("KEYBOARD_KEY_TIMEOUT_US");
    if ((kt != NULL) && (kt[0] != '\0'))
        old_esc_mode_timeout = atoi (kt);

    /* Load string options */
    for (i = 0; str_options[i].opt_name != NULL; i++)
        *str_options[i].opt_addr =
            mc_config_get_string (mc_main_config, CONFIG_APP_SECTION, str_options[i].opt_name,
                                  str_options[i].opt_defval);

    load_layout ();
    panels_load_options ();
    load_panelize ();

    startup_left_mode = setup__load_panel_state ("New Left Panel");
    startup_right_mode = setup__load_panel_state ("New Right Panel");

    /* At least one of the panels is a listing panel */
    if (startup_left_mode != view_listing && startup_right_mode != view_listing)
        startup_left_mode = view_listing;

    boot_current_is_left = mc_config_get_bool (mc_panels_config, "Dirs", "current_is_left", TRUE);

    /* Load time formats */
    user_recent_timeformat =
        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, 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 */

    /* The default color and the terminal dependent color */
    mc_global.tty.setup_color_string =
        mc_config_get_string (mc_main_config, "Colors", "base_color", "");
    mc_global.tty.term_color_string =
        mc_config_get_string (mc_main_config, "Colors", getenv ("TERM"), "");
    mc_global.tty.color_terminal_string =
        mc_config_get_string (mc_main_config, "Colors", "color_terminals", "");

    /* Load the directory history */
    /*    directory_history_load (); */
    /* Remove the temporal entries */

#ifdef HAVE_CHARSET
    if (codepages->len > 1)
    {
        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, CONFIG_MISC_SECTION, "source_codepage", "");
        if (buffer[0] != '\0')
        {
            default_source_codepage = get_codepage_index (buffer);
            mc_global.source_codepage = default_source_codepage;        /* May be source_codepage doesn't need this */
            cp_source = get_codepage_id (mc_global.source_codepage);
        }
        g_free (buffer);
    }

    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;

    g_free (init_translation_table (mc_global.source_codepage, mc_global.display_codepage));
    buffer = (char *) get_codepage_id (mc_global.display_codepage);
    if (buffer != NULL)
        mc_global.utf8_display = str_isutf8 (buffer);
#endif /* HAVE_CHARSET */

#ifdef HAVE_ASPELL
    spell_language =
        mc_config_get_string (mc_main_config, CONFIG_MISC_SECTION, "spell_language", "en");
#endif /* HAVE_ASPELL */

    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", "");
}