mirror of https://github.com/MidnightCommander/mc
Ticket #1939: fix of panel state saving.
Panel state is saved in ~/.mc/panels.ini: 1) when "Save setup" command is invoked; or 2) when MC is quited and "Auto save panels setup" option is set. Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
parent
39fd2ff03b
commit
2745980520
|
@ -1566,10 +1566,9 @@ dirsizes_cmd (void)
|
|||
void
|
||||
save_setup_cmd (void)
|
||||
{
|
||||
if (!save_setup ())
|
||||
return;
|
||||
message (D_NORMAL, _("Setup"), _("Setup saved to ~/%s"),
|
||||
MC_USERCONF_DIR PATH_SEP_STR MC_CONFIG_FILE);
|
||||
if (save_setup (TRUE, TRUE))
|
||||
message (D_NORMAL, _("Setup"), _("Setup saved to ~/%s"),
|
||||
MC_USERCONF_DIR PATH_SEP_STR MC_CONFIG_FILE);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
|
|
@ -58,7 +58,7 @@
|
|||
#include "src/main.h"
|
||||
#include "src/consaver/cons.saver.h"
|
||||
#include "src/viewer/mcviewer.h" /* The view widget */
|
||||
#include "src/setup.h" /* For save_setup() */
|
||||
#include "src/setup.h"
|
||||
#include "src/subshell.h" /* For use_subshell and resize_subshell() */
|
||||
#include "src/background.h" /* we_are_background */
|
||||
|
||||
|
|
|
@ -838,13 +838,7 @@ done_mc (void)
|
|||
* we only change the setup data if we have the auto save feature set
|
||||
*/
|
||||
|
||||
if (auto_save_setup)
|
||||
save_setup (); /* does also call save_hotlist */
|
||||
else
|
||||
{
|
||||
save_hotlist ();
|
||||
save_panel_types ();
|
||||
}
|
||||
save_setup (auto_save_setup, panels_options.auto_save_setup);
|
||||
done_screen ();
|
||||
|
||||
vfs_stamp_path (vfs_get_current_dir ());
|
||||
|
|
|
@ -1215,13 +1215,19 @@ panel_destroy (WPanel * p)
|
|||
{
|
||||
size_t i;
|
||||
|
||||
char *name = panel_save_name (p);
|
||||
if (panels_options.auto_save_setup)
|
||||
{
|
||||
char *name;
|
||||
|
||||
name = panel_save_name (p);
|
||||
panel_save_setup (p, name);
|
||||
g_free (name);
|
||||
}
|
||||
|
||||
panel_save_setup (p, name);
|
||||
panel_clean_dir (p);
|
||||
|
||||
/* save and clean history */
|
||||
if (p->dir_history)
|
||||
if (p->dir_history != NULL)
|
||||
{
|
||||
history_put (p->hist_name, p->dir_history);
|
||||
|
||||
|
@ -1229,7 +1235,6 @@ panel_destroy (WPanel * p)
|
|||
g_list_foreach (p->dir_history, (GFunc) g_free, NULL);
|
||||
g_list_free (p->dir_history);
|
||||
}
|
||||
|
||||
g_free (p->hist_name);
|
||||
|
||||
delete_format (p->format);
|
||||
|
@ -1240,7 +1245,6 @@ panel_destroy (WPanel * p)
|
|||
g_free (p->user_status_format[i]);
|
||||
g_free (p->dir.list);
|
||||
g_free (p->panel_name);
|
||||
g_free (name);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
|
|
@ -59,7 +59,7 @@
|
|||
|
||||
#include "args.h"
|
||||
#include "subshell.h"
|
||||
#include "setup.h" /* save_setup() */
|
||||
#include "setup.h" /* load_setup() */
|
||||
|
||||
#ifdef HAVE_CHARSET
|
||||
#include "lib/charsets.h"
|
||||
|
|
125
src/setup.c
125
src/setup.c
|
@ -765,6 +765,41 @@ panel_save_type (const char *section, panel_view_mode_t type)
|
|||
}
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
/* 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);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
/*** public functions ****************************************************************************/
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
@ -945,42 +980,51 @@ load_setup (void)
|
|||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
gboolean
|
||||
save_setup (void)
|
||||
save_setup (gboolean save_options, gboolean save_panel_options)
|
||||
{
|
||||
char *tmp_profile;
|
||||
gboolean ret;
|
||||
gboolean ret = TRUE;
|
||||
|
||||
saving_setup = 1;
|
||||
|
||||
save_config ();
|
||||
save_layout ();
|
||||
panels_save_options ();
|
||||
save_hotlist ();
|
||||
save_panelize ();
|
||||
save_panel_types ();
|
||||
/* directory_history_save (); */
|
||||
|
||||
if (save_panel_options)
|
||||
save_panel_types ();
|
||||
|
||||
if (save_options)
|
||||
{
|
||||
char *tmp_profile;
|
||||
|
||||
save_config ();
|
||||
save_layout ();
|
||||
panels_save_options ();
|
||||
save_panelize ();
|
||||
/* directory_history_save (); */
|
||||
|
||||
#ifdef ENABLE_VFS_FTP
|
||||
mc_config_set_string (mc_main_config, "Misc", "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, "Misc", "ftpfs_password", ftpfs_anonymous_passwd);
|
||||
if (ftpfs_proxy_host)
|
||||
mc_config_set_string (mc_main_config, "Misc", "ftp_proxy_host", ftpfs_proxy_host);
|
||||
#endif /* ENABLE_VFS_FTP */
|
||||
|
||||
#ifdef HAVE_CHARSET
|
||||
mc_config_set_string (mc_main_config, "Misc", "display_codepage",
|
||||
get_codepage_id (display_codepage));
|
||||
mc_config_set_string (mc_main_config, "Misc", "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, "Misc", "display_codepage",
|
||||
get_codepage_id (display_codepage));
|
||||
mc_config_set_string (mc_main_config, "Misc", "source_codepage",
|
||||
get_codepage_id (default_source_codepage));
|
||||
mc_config_set_string (mc_main_config, "Misc", "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, "Misc", "clipboard_store", clipboard_store_path);
|
||||
mc_config_set_string (mc_main_config, "Misc", "clipboard_paste", clipboard_paste_path);
|
||||
|
||||
tmp_profile = g_build_filename (home_dir, MC_USERCONF_DIR, MC_CONFIG_FILE, NULL);
|
||||
ret = mc_config_save_to_file (mc_main_config, tmp_profile, NULL);
|
||||
tmp_profile = g_build_filename (home_dir, MC_USERCONF_DIR, MC_CONFIG_FILE, NULL);
|
||||
ret = mc_config_save_to_file (mc_main_config, tmp_profile, NULL);
|
||||
|
||||
g_free (tmp_profile);
|
||||
}
|
||||
|
||||
g_free (tmp_profile);
|
||||
saving_setup = 0;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -1332,43 +1376,6 @@ panel_save_setup (struct WPanel *panel, const char *section)
|
|||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
void
|
||||
save_panel_types (void)
|
||||
{
|
||||
panel_view_mode_t type;
|
||||
|
||||
if (mc_run_mode != MC_RUN_FULL)
|
||||
return;
|
||||
|
||||
if (!panels_options.auto_save_setup)
|
||||
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);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
Load panels options from [Panels] section.
|
||||
*/
|
||||
|
|
|
@ -95,7 +95,7 @@ extern gboolean boot_current_is_left;
|
|||
|
||||
char *setup_init (void);
|
||||
void load_setup (void);
|
||||
gboolean save_setup (void);
|
||||
gboolean save_setup (gboolean save_options, gboolean save_panel_options);
|
||||
void done_setup (void);
|
||||
void save_config (void);
|
||||
void setup_save_config_show_error (const char *filename, GError ** error);
|
||||
|
@ -112,7 +112,6 @@ void free_keymap_defs (void);
|
|||
|
||||
void panel_load_setup (WPanel * panel, const char *section);
|
||||
void panel_save_setup (WPanel * panel, const char *section);
|
||||
void save_panel_types (void);
|
||||
|
||||
void panels_load_options (void);
|
||||
void panels_save_options (void);
|
||||
|
|
Loading…
Reference in New Issue