diff --git a/src/layout.c b/src/layout.c
index e801a99..4ec5162 100644
a
|
b
|
int output_start_y = 0; |
117 | 117 | static struct { |
118 | 118 | int type; |
119 | 119 | Widget *widget; |
| 120 | char *last_saved_dir; /* last view_list working directory */ |
120 | 121 | } panels [MAX_VIEWS]; |
121 | 122 | |
122 | 123 | /* These variables are used to avoid updating the information unless */ |
… |
… |
void set_display_type (int num, int type) |
955 | 956 | |
956 | 957 | switch (type){ |
957 | 958 | case view_listing: |
958 | | new_widget = (Widget *) panel_new (get_nth_panel_name (num)); |
| 959 | new_widget = restore_into_right_dir_panel(num, old_widget); |
959 | 960 | break; |
960 | 961 | |
961 | 962 | case view_info: |
… |
… |
void set_display_type (int num, int type) |
979 | 980 | view_load ((WView *) new_widget, 0, file_name, 0); |
980 | 981 | break; |
981 | 982 | } |
| 983 | |
| 984 | if (type != view_listing) |
| 985 | /* Must save dir, for restoring after change type to */ |
| 986 | /* view_listing */ |
| 987 | save_panel_dir(num); |
| 988 | |
982 | 989 | panels [num].type = type; |
983 | 990 | panels [num].widget = (Widget *) new_widget; |
984 | 991 | |
… |
… |
int get_other_type (void) |
1150 | 1157 | return panels [0].type; |
1151 | 1158 | } |
1152 | 1159 | |
| 1160 | /* Save current list_view widget directory into panel */ |
| 1161 | void save_panel_dir(int index) |
| 1162 | { |
| 1163 | if (get_display_type(index) == view_listing) { |
| 1164 | WPanel *w = (WPanel *) get_panel_widget(index); |
| 1165 | char *widget_work_dir = w->cwd; |
| 1166 | |
| 1167 | g_free(panels [index].last_saved_dir); /* last path no needed */ |
| 1168 | panels [index].last_saved_dir = g_strdup(widget_work_dir); |
| 1169 | } |
| 1170 | } |
| 1171 | |
| 1172 | /* Save current list_view widget directory into panel */ |
| 1173 | Widget *restore_into_right_dir_panel(int index, Widget *from_widget) |
| 1174 | { |
| 1175 | Widget *new_widget = 0; |
| 1176 | const char *saved_dir = panels [index].last_saved_dir; |
| 1177 | int last_was_panel = (from_widget && |
| 1178 | get_display_type(index) != view_listing); |
| 1179 | |
| 1180 | const char *p_name = get_nth_panel_name (index); |
| 1181 | |
| 1182 | if (last_was_panel) { |
| 1183 | new_widget = (Widget *) panel_new_with_dir (p_name, saved_dir); |
| 1184 | } else |
| 1185 | new_widget = (Widget *) panel_new (p_name); |
| 1186 | |
| 1187 | return new_widget; |
| 1188 | } |
diff --git a/src/layout.h b/src/layout.h
index 7a14a09..2521c2c 100644
a
|
b
|
struct Widget *get_panel_widget (int index); |
30 | 30 | |
31 | 31 | struct WPanel *get_other_panel (void); |
32 | 32 | |
| 33 | void save_panel_dir(int index); |
| 34 | Widget *restore_into_right_dir_panel(int index, Widget *from_widget); |
| 35 | |
33 | 36 | void set_hintbar (const char *str); |
34 | 37 | |
35 | 38 | /* Clear screen */ |
diff --git a/src/panel.h b/src/panel.h
index bed9e3d..a2adb12 100644
a
|
b
|
typedef struct WPanel { |
83 | 83 | } WPanel; |
84 | 84 | |
85 | 85 | WPanel *panel_new (const char *panel_name); |
| 86 | WPanel *panel_new_with_dir (const char *panel_name, const char *dr); |
86 | 87 | void panel_clean_dir (WPanel *panel); |
87 | 88 | |
88 | 89 | extern int torben_fj_mode; |
diff --git a/src/screen.c b/src/screen.c
index 6f6c403..6e6b62c 100644
a
|
b
|
panel_format_modified (WPanel *panel) |
1096 | 1096 | WPanel * |
1097 | 1097 | panel_new (const char *panel_name) |
1098 | 1098 | { |
| 1099 | return panel_new_with_dir(panel_name, NULL); |
| 1100 | } |
| 1101 | |
| 1102 | /* Panel creation for specified directory */ |
| 1103 | /* The parameter specifies the name of the panel for setup retieving */ |
| 1104 | /* and the path of working panel directory. If path is NULL then */ |
| 1105 | /* panel will be created for current directory */ |
| 1106 | WPanel * |
| 1107 | panel_new_with_dir (const char *panel_name, const char *wpath) |
| 1108 | { |
1099 | 1109 | WPanel *panel; |
1100 | 1110 | char *section; |
1101 | 1111 | int i, err; |
| 1112 | char curdir[MAXPATHLEN]; |
1102 | 1113 | |
1103 | 1114 | panel = g_new0 (WPanel, 1); |
1104 | 1115 | |
… |
… |
panel_new (const char *panel_name) |
1108 | 1119 | /* We do not want the cursor */ |
1109 | 1120 | widget_want_cursor (panel->widget, 0); |
1110 | 1121 | |
1111 | | mc_get_current_wd (panel->cwd, sizeof (panel->cwd) - 2); |
| 1122 | if (wpath) { |
| 1123 | g_strlcpy(panel->cwd, wpath, sizeof (panel->cwd)); |
| 1124 | mc_get_current_wd (curdir, sizeof (curdir) - 2); |
| 1125 | } else |
| 1126 | mc_get_current_wd (panel->cwd, sizeof (panel->cwd) - 2); |
| 1127 | |
1112 | 1128 | strcpy (panel->lwd, "."); |
1113 | 1129 | |
1114 | 1130 | panel->hist_name = g_strconcat ("Dir Hist ", panel_name, (char *) NULL); |
… |
… |
panel_new (const char *panel_name) |
1155 | 1171 | set_panel_formats (panel); |
1156 | 1172 | } |
1157 | 1173 | |
| 1174 | |
| 1175 | /* Because do_load_dir lists files in current directory */ |
| 1176 | if (wpath) |
| 1177 | mc_chdir(wpath); |
| 1178 | |
1158 | 1179 | /* Load the default format */ |
1159 | 1180 | panel->count = |
1160 | 1181 | do_load_dir (panel->cwd, &panel->dir, panel->sort_type, |
1161 | 1182 | panel->reverse, panel->case_sensitive, |
1162 | 1183 | panel->exec_first, panel->filter); |
| 1184 | |
| 1185 | /* Restore old right path */ |
| 1186 | if (wpath) |
| 1187 | mc_chdir(curdir); |
| 1188 | |
1163 | 1189 | return panel; |
1164 | 1190 | } |
1165 | 1191 | |