/* save panels.ini */ static void save_panel_types (void) { panel_view_mode_t type; if (mc_run_mode != MC_RUN_FULL) return; type = get_display_type (0); panel_save_type ("New Left Panel", type); if (type == view_listing) panel_save_setup (left_panel, left_panel->panel_name); type = get_display_type (1); panel_save_type ("New Right Panel", type); if (type == view_listing) panel_save_setup (right_panel, right_panel->panel_name); mc_config_set_string (mc_panels_config, "Dirs", "other_dir", get_panel_dir_for (other_panel)); if (current_panel != NULL) mc_config_set_string (mc_panels_config, "Dirs", "current_is_left", get_current_index () == 0 ? "1" : "0"); if (mc_panels_config->ini_path == NULL) mc_panels_config->ini_path = g_strdup (panels_profile_name); mc_config_del_group (mc_panels_config, "Temporal:New Left Panel"); mc_config_del_group (mc_panels_config, "Temporal:New Right Panel"); mc_config_save_file (mc_panels_config, NULL); }
static void setup__move_panels_config_into_separate_file (const char *profile) { mc_config_t *tmp_cfg; char **groups, **curr_grp; if (!exist_file (profile)) return; tmp_cfg = mc_config_init (profile, FALSE); if (!tmp_cfg) return; curr_grp = groups = mc_config_get_groups (tmp_cfg, NULL); if (!groups) { mc_config_deinit (tmp_cfg); return; } while (*curr_grp) { if (setup__is_cfg_group_must_panel_config (*curr_grp) == NULL) mc_config_del_group (tmp_cfg, *curr_grp); curr_grp++; } mc_config_save_to_file (tmp_cfg, panels_profile_name, NULL); mc_config_deinit (tmp_cfg); tmp_cfg = mc_config_init (profile, FALSE); if (!tmp_cfg) { g_strfreev (groups); return; } curr_grp = groups; while (*curr_grp) { const char *need_grp; need_grp = setup__is_cfg_group_must_panel_config (*curr_grp); if (need_grp != NULL) { mc_config_del_group (tmp_cfg, need_grp); } curr_grp++; } g_strfreev (groups); mc_config_save_file (tmp_cfg, NULL); mc_config_deinit (tmp_cfg); }
/** * Save history to the mc_config, but don't save config to file */ void history_save (struct mc_config_t *cfg, const char *name, GList * h) { GIConv conv = INVALID_CONV; GString *buffer; int i; if (name == NULL || *name == '\0' || h == NULL) return; /* go to end of list */ h = g_list_last (h); /* go back 60 places */ for (i = 0; (i < num_history_items_recorded - 1) && (h->prev != NULL); i++) h = g_list_previous (h); if (name != NULL) mc_config_del_group (cfg, name); /* create charset conversion handler to convert strings from system codepage to UTF-8 */ if (!mc_global.utf8_display) conv = str_crt_conv_to ("UTF-8"); buffer = g_string_sized_new (64); /* dump history into profile */ for (i = 0; h != NULL; h = g_list_next (h)) { char key[BUF_TINY]; char *text = (char *) h->data; /* We shouldn't have null entries, but let's be sure */ if (text == NULL) continue; g_snprintf (key, sizeof (key), "%d", i++); if (conv == INVALID_CONV) mc_config_set_string_raw (cfg, name, key, text); else { g_string_set_size (buffer, 0); if (str_convert (conv, text, buffer) == ESTR_FAILURE) mc_config_set_string_raw (cfg, name, key, text); else mc_config_set_string_raw (cfg, name, key, buffer->str); } } g_string_free (buffer, TRUE); if (conv != INVALID_CONV) str_close_conv (conv); }
static void mc_skin_color_check_bw_mode (mc_skin_t * mc_skin) { gchar **groups, **orig_groups; if (tty_use_colors () && !mc_args__disable_colors) return; orig_groups = groups = mc_config_get_groups (mc_skin->config, NULL); if (groups == NULL) return; for (; *groups != NULL; groups++) { if (mc_skin_color_check_inisection (*groups)) mc_config_del_group (mc_skin->config, *groups); } g_strfreev (orig_groups); mc_skin_hardcoded_blackwhite_colors (mc_skin); }