Ejemplo n.º 1
0
void
panel_save_setup (WPanel * panel, const char *section)
{
    char buffer[BUF_TINY];
    size_t i;

    mc_config_set_int (mc_panels_config, section, "reverse", panel->sort_info.reverse);
    mc_config_set_int (mc_panels_config, section, "case_sensitive",
                       panel->sort_info.case_sensitive);
    mc_config_set_int (mc_panels_config, section, "exec_first", panel->sort_info.exec_first);

    mc_config_set_string (mc_panels_config, section, "sort_order", panel->sort_field->id);

    for (i = 0; list_types[i].key != NULL; i++)
        if (list_types[i].list_type == panel->list_type)
        {
            mc_config_set_string (mc_panels_config, section, "list_mode", list_types[i].key);
            break;
        }

    mc_config_set_string (mc_panels_config, section, "user_format", panel->user_format);

    for (i = 0; i < LIST_TYPES; i++)
    {
        g_snprintf (buffer, BUF_TINY, "user_status%lld", (long long) i);
        mc_config_set_string (mc_panels_config, section, buffer, panel->user_status_format[i]);
    }

    mc_config_set_int (mc_panels_config, section, "user_mini_status", panel->user_mini_status);
}
Ejemplo n.º 2
0
/**
  Save panels options in [Panels] section.
*/
void
panels_save_options (void)
{
    size_t i;

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

    mc_config_set_int (mc_main_config, CONFIG_PANELS_SECTION,
                       "quick_search_mode", (int) panels_options.qsearch_mode);
    mc_config_set_int (mc_main_config, CONFIG_PANELS_SECTION,
                       "select_flags", (int) panels_options.select_flags);
}
Ejemplo n.º 3
0
void
save_layout (void)
{
    size_t i;

    /* Save integer options */
    for (i = 0; layout[i].opt_name != NULL; i++)
        mc_config_set_int (mc_main_config, CONFIG_LAYOUT_SECTION, layout[i].opt_name,
                           *layout[i].opt_addr);
}
Ejemplo n.º 4
0
END_TEST

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

#define etalon_str "g6:group1p6:param1v10:some valuep6:param2v11:some value " \
   "g6:group2p6:param1v4:truep6:param2v6:123456" \
   "g6:group3p6:param1v11:::bla-bla::p6:param2v31:bla-:p1:w:v2:12:g3:123:bla-bla\n" \
   "g6:group4p6:param1v5:falsep6:param2v6:654321"

START_TEST (test_serialize_config)
{
    mc_config_t *test_data;
    GError *error = NULL;
    char *actual;

    test_data = mc_config_init (NULL);

    mc_config_set_string_raw (test_data, "group1", "param1", "some value");
    mc_config_set_string (test_data, "group1", "param2", "some value ");

    mc_config_set_bool (test_data, "group2", "param1", TRUE);
    mc_config_set_int (test_data, "group2", "param2", 123456);

    mc_config_set_string_raw (test_data, "group3", "param1", "::bla-bla::");
    mc_config_set_string (test_data, "group3", "param2", "bla-:p1:w:v2:12:g3:123:bla-bla\n");

    mc_config_set_bool (test_data, "group4", "param1", FALSE);
    mc_config_set_int (test_data, "group4", "param2", 654321);

    actual = mc_serialize_config (test_data, &error);
    mc_config_deinit (test_data);

    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;
    }

    fail_unless(strcmp(actual, etalon_str) == 0, "Not equal:\nactual (%s)\netalon (%s)", actual, etalon_str);
    g_free(actual);
}
Ejemplo n.º 5
0
/* *INDENT-OFF* */
END_PARAMETRIZED_TEST
/* *INDENT-ON* */

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

/* *INDENT-OFF* */
START_TEST (test_serialize_config)
/* *INDENT-ON* */
{
    /* given */
    mc_config_t *test_data;
    char *actual;
    const char *expected_result = "g6:group1p6:param1v10:some valuep6:param2v11:some value "
        "g6:group2p6:param1v4:truep6:param2v6:123456"
        "g6:group3p6:param1v11:::bla-bla::p6:param2v31:bla-:p1:w:v2:12:g3:123:bla-bla\n"
        "g6:group4p6:param1v5:falsep6:param2v6:654321";

    test_data = mc_config_init (NULL, FALSE);

    mc_config_set_string_raw (test_data, "group1", "param1", "some value");
    mc_config_set_string (test_data, "group1", "param2", "some value ");

    mc_config_set_bool (test_data, "group2", "param1", TRUE);
    mc_config_set_int (test_data, "group2", "param2", 123456);

    mc_config_set_string_raw (test_data, "group3", "param1", "::bla-bla::");
    mc_config_set_string (test_data, "group3", "param2", "bla-:p1:w:v2:12:g3:123:bla-bla\n");

    mc_config_set_bool (test_data, "group4", "param1", FALSE);
    mc_config_set_int (test_data, "group4", "param2", 654321);

    /* when */
    actual = mc_serialize_config (test_data, &error);
    mc_config_deinit (test_data);

    /* then */
    mctest_assert_not_null (actual);
    mctest_assert_str_eq (actual, expected_result);

    g_free (actual);
}
Ejemplo n.º 6
0
void
save_layout (void)
{
    char *profile;
    size_t i;

    profile = g_build_filename (mc_config_get_path (), MC_CONFIG_FILE, NULL);
    /* 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_save_to_file (mc_main_config, profile, NULL);
    g_free (profile);
}
Ejemplo n.º 7
0
int
mc_config_get_int (mc_config_t * mc_config, const gchar * group, const gchar * param, int def)
{
    if (!mc_config || !group || !param)
        return def;

    if (!mc_config_has_param (mc_config, group, param))
    {
        mc_config_set_int (mc_config, group, param, def);
        return def;
    }

    return g_key_file_get_integer (mc_config->handle, group, param, NULL);
}
Ejemplo n.º 8
0
void
save_config (void)
{
    size_t i;

    /* Save integer options */
    for (i = 0; int_options[i].opt_name != NULL; i++)
        mc_config_set_int (mc_main_config, CONFIG_APP_SECTION, int_options[i].opt_name,
                           *int_options[i].opt_addr);

    /* Save string options */
    for (i = 0; str_options[i].opt_name != NULL; i++)
        mc_config_set_string (mc_main_config, CONFIG_APP_SECTION, str_options[i].opt_name,
                              *str_options[i].opt_addr);
}
Ejemplo n.º 9
0
void
save_config (void)
{
    char *profile;
    GError *error = NULL;
    size_t i;

    profile = g_build_filename (mc_config_get_path (), MC_CONFIG_FILE, NULL);

    /* Save integer options */
    for (i = 0; int_options[i].opt_name != NULL; i++)
        mc_config_set_int (mc_main_config, CONFIG_APP_SECTION, int_options[i].opt_name,
                           *int_options[i].opt_addr);

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

    if (!mc_config_save_to_file (mc_main_config, profile, &error))
        setup_save_config_show_error (profile, &error);

    g_free (profile);
}