mirror of
https://github.com/MidnightCommander/mc
synced 2025-01-18 09:19:24 +03:00
Ticket #38: fixed saving other_dir path into panels.ini.
Save Info, Tree and etc. panels state, and restore after. Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
parent
fbd2154cb5
commit
6a4124c8ea
35
src/layout.c
35
src/layout.c
@ -913,6 +913,14 @@ set_display_type (int num, int type)
|
||||
}
|
||||
}
|
||||
|
||||
/* Restoring saved path from panels.ini for nonlist panel */
|
||||
/* when it's first creation (for example view_info) */
|
||||
if (old_widget == NULL && type != view_listing) {
|
||||
char panel_dir[MC_MAXPATHLEN];
|
||||
mc_get_current_wd (panel_dir, sizeof (panel_dir));
|
||||
panels[num].last_saved_dir = g_strdup (panel_dir);
|
||||
}
|
||||
|
||||
switch (type){
|
||||
case view_listing:
|
||||
new_widget = restore_into_right_dir_panel(num, old_widget);
|
||||
@ -1133,7 +1141,8 @@ save_panel_dir (int index)
|
||||
}
|
||||
|
||||
/* Save current list_view widget directory into panel */
|
||||
Widget *restore_into_right_dir_panel(int index, Widget *from_widget)
|
||||
Widget *
|
||||
restore_into_right_dir_panel (int index, Widget *from_widget)
|
||||
{
|
||||
Widget *new_widget = 0;
|
||||
const char *saved_dir = panels [index].last_saved_dir;
|
||||
@ -1141,10 +1150,30 @@ Widget *restore_into_right_dir_panel(int index, Widget *from_widget)
|
||||
get_display_type(index) != view_listing);
|
||||
const char *p_name = get_nth_panel_name (index);
|
||||
|
||||
if (last_was_panel) {
|
||||
if (last_was_panel)
|
||||
new_widget = (Widget *) panel_new_with_dir (p_name, saved_dir);
|
||||
} else
|
||||
else
|
||||
new_widget = (Widget *) panel_new (p_name);
|
||||
|
||||
return new_widget;
|
||||
}
|
||||
|
||||
/* Return working dir, if it's view_listing - cwd,
|
||||
but for other types - last_saved_dir */
|
||||
const char *
|
||||
get_panel_dir_for (const WPanel *widget)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < MAX_VIEWS; i++)
|
||||
if ((WPanel *) get_panel_widget (i) == widget)
|
||||
break;
|
||||
|
||||
if (i >= MAX_VIEWS)
|
||||
return ".";
|
||||
|
||||
if (get_display_type (i) == view_listing)
|
||||
return ((WPanel *) get_panel_widget (i))->cwd;
|
||||
|
||||
return panels[i].last_saved_dir;
|
||||
}
|
||||
|
@ -29,6 +29,7 @@ struct WPanel *get_other_panel (void);
|
||||
|
||||
void save_panel_dir (int index);
|
||||
Widget *restore_into_right_dir_panel (int index, Widget *from_widget);
|
||||
const char *get_panel_dir_for (const WPanel *widget);
|
||||
|
||||
void set_hintbar (const char *str);
|
||||
|
||||
|
@ -353,8 +353,8 @@ save_panel_types (void)
|
||||
panel_save_setup (right_panel, right_panel->panel_name);
|
||||
|
||||
mc_config_set_string (mc_panels_config, "Dirs" , "other_dir",
|
||||
get_other_type () == view_listing
|
||||
? other_panel->cwd : ".");
|
||||
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");
|
||||
|
Loading…
Reference in New Issue
Block a user