mirror of https://github.com/MidnightCommander/mc
Ticket 38: return from Info panel to wrong directory.
When viewing two file lists, if user presses C-x i for info on a panel's directory or file, the info pops up correctly in the other panel. However, when the user closes the info screen, the directory of the current panel is shown -- NOT the directory which was being viewed before the info panel appeared. Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
parent
8b68cce757
commit
c17ebc96ac
38
src/layout.c
38
src/layout.c
|
@ -119,6 +119,7 @@ int output_start_y = 0;
|
|||
static struct {
|
||||
int type;
|
||||
Widget *widget;
|
||||
char *last_saved_dir; /* last view_list working directory */
|
||||
} panels [MAX_VIEWS];
|
||||
|
||||
/* These variables are used to avoid updating the information unless */
|
||||
|
@ -895,7 +896,7 @@ void set_display_type (int num, int type)
|
|||
|
||||
switch (type){
|
||||
case view_listing:
|
||||
new_widget = (Widget *) panel_new (get_nth_panel_name (num));
|
||||
new_widget = restore_into_right_dir_panel(num, old_widget);
|
||||
break;
|
||||
|
||||
case view_info:
|
||||
|
@ -919,6 +920,12 @@ void set_display_type (int num, int type)
|
|||
view_load ((WView *) new_widget, 0, file_name, 0);
|
||||
break;
|
||||
}
|
||||
|
||||
if (type != view_listing)
|
||||
/* Must save dir, for restoring after change type to */
|
||||
/* view_listing */
|
||||
save_panel_dir(num);
|
||||
|
||||
panels [num].type = type;
|
||||
panels [num].widget = (Widget *) new_widget;
|
||||
|
||||
|
@ -1090,3 +1097,32 @@ int get_other_type (void)
|
|||
return panels [0].type;
|
||||
}
|
||||
|
||||
/* Save current list_view widget directory into panel */
|
||||
void save_panel_dir(int index)
|
||||
{
|
||||
if (get_display_type(index) == view_listing) {
|
||||
WPanel *w = (WPanel *) get_panel_widget(index);
|
||||
char *widget_work_dir = w->cwd;
|
||||
|
||||
g_free(panels [index].last_saved_dir); /* last path no needed */
|
||||
/* Because path can be nonlocal */
|
||||
panels [index].last_saved_dir = vfs_translate_url(widget_work_dir);
|
||||
}
|
||||
}
|
||||
|
||||
/* Save current list_view widget directory into panel */
|
||||
Widget *restore_into_right_dir_panel(int index, Widget *from_widget)
|
||||
{
|
||||
Widget *new_widget = 0;
|
||||
const char *saved_dir = panels [index].last_saved_dir;
|
||||
gboolean last_was_panel = (from_widget &&
|
||||
get_display_type(index) != view_listing);
|
||||
const char *p_name = get_nth_panel_name (index);
|
||||
|
||||
if (last_was_panel) {
|
||||
new_widget = (Widget *) panel_new_with_dir (p_name, saved_dir);
|
||||
} else
|
||||
new_widget = (Widget *) panel_new (p_name);
|
||||
|
||||
return new_widget;
|
||||
}
|
||||
|
|
|
@ -27,6 +27,9 @@ struct Widget *get_panel_widget (int index);
|
|||
|
||||
struct WPanel *get_other_panel (void);
|
||||
|
||||
void save_panel_dir(int index);
|
||||
Widget *restore_into_right_dir_panel(int index, Widget *from_widget);
|
||||
|
||||
void set_hintbar (const char *str);
|
||||
|
||||
/* Clear screen */
|
||||
|
|
|
@ -83,6 +83,7 @@ typedef struct WPanel {
|
|||
} WPanel;
|
||||
|
||||
WPanel *panel_new (const char *panel_name);
|
||||
WPanel *panel_new_with_dir (const char *panel_name, const char *dr);
|
||||
void panel_clean_dir (WPanel *panel);
|
||||
|
||||
extern int torben_fj_mode;
|
||||
|
|
28
src/screen.c
28
src/screen.c
|
@ -1104,10 +1104,21 @@ panel_format_modified (WPanel *panel)
|
|||
/* The parameter specifies the name of the panel for setup retieving */
|
||||
WPanel *
|
||||
panel_new (const char *panel_name)
|
||||
{
|
||||
return panel_new_with_dir(panel_name, NULL);
|
||||
}
|
||||
|
||||
/* Panel creation for specified directory */
|
||||
/* The parameter specifies the name of the panel for setup retieving */
|
||||
/* and the path of working panel directory. If path is NULL then */
|
||||
/* panel will be created for current directory */
|
||||
WPanel *
|
||||
panel_new_with_dir (const char *panel_name, const char *wpath)
|
||||
{
|
||||
WPanel *panel;
|
||||
char *section;
|
||||
int i, err;
|
||||
char curdir[MAXPATHLEN];
|
||||
|
||||
panel = g_new0 (WPanel, 1);
|
||||
|
||||
|
@ -1117,7 +1128,12 @@ panel_new (const char *panel_name)
|
|||
/* We do not want the cursor */
|
||||
widget_want_cursor (panel->widget, 0);
|
||||
|
||||
mc_get_current_wd (panel->cwd, sizeof (panel->cwd) - 2);
|
||||
if (wpath) {
|
||||
g_strlcpy(panel->cwd, wpath, sizeof (panel->cwd));
|
||||
mc_get_current_wd (curdir, sizeof (curdir) - 2);
|
||||
} else
|
||||
mc_get_current_wd (panel->cwd, sizeof (panel->cwd) - 2);
|
||||
|
||||
strcpy (panel->lwd, ".");
|
||||
|
||||
panel->hist_name = g_strconcat ("Dir Hist ", panel_name, (char *) NULL);
|
||||
|
@ -1164,11 +1180,21 @@ panel_new (const char *panel_name)
|
|||
set_panel_formats (panel);
|
||||
}
|
||||
|
||||
|
||||
/* Because do_load_dir lists files in current directory */
|
||||
if (wpath)
|
||||
mc_chdir(wpath);
|
||||
|
||||
/* Load the default format */
|
||||
panel->count =
|
||||
do_load_dir (panel->cwd, &panel->dir, panel->sort_type,
|
||||
panel->reverse, panel->case_sensitive,
|
||||
panel->exec_first, panel->filter);
|
||||
|
||||
/* Restore old right path */
|
||||
if (wpath)
|
||||
mc_chdir(curdir);
|
||||
|
||||
return panel;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue