From 4e8faef03e82927796e6b194d22a6990a1e50656 Mon Sep 17 00:00:00 2001 From: Andrew Borodin Date: Mon, 23 Apr 2012 22:29:17 +0400 Subject: [PATCH] Ticket #2783: directories is opened in the wrong panel. mc dir1 dir2 The bug: order of parameters assignment depends on current_is_left option in panels.ini file: if current_is_left=0, then dir1 is opened in the left panel, dir2 in the right one. If current_is_left=1, then dir1 is opened in the right panel, dir2 in the left one. Signed-off-by: Andrew Borodin --- src/filemanager/midnight.c | 61 +++++++++++++++++++------------------- 1 file changed, 31 insertions(+), 30 deletions(-) diff --git a/src/filemanager/midnight.c b/src/filemanager/midnight.c index 577a9ea57..dd9c902ee 100644 --- a/src/filemanager/midnight.c +++ b/src/filemanager/midnight.c @@ -567,60 +567,59 @@ print_vfs_message (const gchar * event_group_name, const gchar * event_name, static void create_panels (void) { - int current_index; - int other_index; + int current_index, other_index; panel_view_mode_t current_mode, other_mode; - vfs_path_t *original_dir = NULL; + char *current_dir, *other_dir; + vfs_path_t *original_dir; if (boot_current_is_left) { + /* left panel is active */ current_index = 0; other_index = 1; current_mode = startup_left_mode; other_mode = startup_right_mode; + current_dir = mc_run_param0; + other_dir = mc_run_param1; } else { + /* right panel is active */ current_index = 1; other_index = 0; current_mode = startup_right_mode; other_mode = startup_left_mode; + current_dir = mc_run_param1; + other_dir = mc_run_param0; } - /* Creates the left panel */ - if (mc_run_param0 != NULL) + + /* 1. Get current dir */ + original_dir = vfs_path_clone (vfs_get_raw_current_dir ()); + + /* 2. Create passive panel */ + if (other_dir != NULL) { vfs_path_t *vpath; - if (mc_run_param1 != NULL) - { - /* Ok, user has specified two dirs, save the original one, - * since we may not be able to chdir to the proper - * second directory later - */ - original_dir = vfs_path_clone (vfs_get_raw_current_dir ()); - } - vpath = vfs_path_from_str (mc_run_param0); + vpath = vfs_path_from_str (other_dir); + mc_chdir (vpath); + vfs_path_free (vpath); + } + set_display_type (other_index, other_mode); + + /* 3. Create active panel */ + if (current_dir == NULL) + mc_chdir (original_dir); + else + { + vfs_path_t *vpath; + + vpath = vfs_path_from_str (current_dir); mc_chdir (vpath); vfs_path_free (vpath); } set_display_type (current_index, current_mode); - /* The other panel */ - if (mc_run_param1 != NULL) - { - vfs_path_t *vpath; - - if (original_dir != NULL) - mc_chdir (original_dir); - - vpath = vfs_path_from_str (mc_run_param1); - mc_chdir (vpath); - vfs_path_free (vpath); - } - vfs_path_free (original_dir); - - set_display_type (other_index, other_mode); - if (startup_left_mode == view_listing) current_panel = left_panel; else if (right_panel != NULL) @@ -628,6 +627,8 @@ create_panels (void) else current_panel = left_panel; + vfs_path_free (original_dir); + #ifdef ENABLE_VFS mc_event_add (MCEVENT_GROUP_CORE, "vfs_timestamp", check_other_panel_timestamp, NULL, NULL); mc_event_add (MCEVENT_GROUP_CORE, "vfs_timestamp", check_current_panel_timestamp, NULL, NULL);