Ticket #3699: patch01-setup.ch-main.c-midnight.c-auto-save-restore-panel.161007.diff

File patch01-setup.ch-main.c-midnight.c-auto-save-restore-panel.161007.diff, 4.3 KB (added by zaytsev, 8 years ago)
  • src/setup.h

    old new extern char *spell_language; 
    119119 
    120120/* Value of "other_dir" key in ini file */ 
    121121extern char *saved_other_dir; 
     122extern char *saved_this_dir; 
    122123 
    123124/* If set, then print to the given file the last directory we were at */ 
    124125extern char *last_wd_string; 
  • src/setup.c

    old new char *spell_language = NULL; 
    194194 
    195195/* Value of "other_dir" key in ini file */ 
    196196char *saved_other_dir = NULL; 
     197char *saved_this_dir = NULL; 
    197198 
    198199/* If set, then print to the given file the last directory we were at */ 
    199200char *last_wd_string = NULL; 
    save_panel_types (void) 
    930931        panel_save_setup (right_panel, right_panel->panel_name); 
    931932 
    932933    { 
    933         char *dirs; 
    934934 
    935         dirs = get_panel_dir_for (other_panel); 
    936         mc_config_set_string (mc_global.panels_config, "Dirs", "other_dir", dirs); 
    937         g_free (dirs); 
     935        WPanel *this_panel = PANEL(get_panel_widget(get_current_index())); 
     936        char *this_dir; 
     937        char *other_dir; 
     938         
     939        this_dir = get_panel_dir_for(this_panel); 
     940        mc_config_set_string (mc_global.panels_config, "Dirs", "this_dir", this_dir); 
     941        g_free (this_dir); 
     942         
     943        other_dir = get_panel_dir_for (other_panel); 
     944        mc_config_set_string (mc_global.panels_config, "Dirs", "other_dir", other_dir); 
     945        g_free (other_dir); 
    938946    } 
    939947 
    940948    if (current_panel != NULL) 
  • src/main.c

    old new main (int argc, char *argv[]) 
    282282    /* Must be done after load_setup because depends on mc_global.vfs.cd_symlinks */ 
    283283    vfs_setup_work_dir (); 
    284284 
    285     /* Resolve the other_dir panel option. Must be done after vfs_setup_work_dir */ 
     285    /* Resolve this_dir/other_dir panel options. Must be done after vfs_setup_work_dir */ 
    286286    { 
    287287        char *buffer; 
    288288        vfs_path_t *vpath; 
    289289 
     290        buffer = mc_config_get_string (mc_global.panels_config, "Dirs", "this_dir", "."); 
     291        vpath = vfs_path_from_str (buffer); 
     292        if (vfs_file_is_local (vpath)) 
     293            saved_this_dir = buffer; 
     294        else 
     295            g_free (buffer); 
     296        vfs_path_free (vpath); 
     297 
    290298        buffer = mc_config_get_string (mc_global.panels_config, "Dirs", "other_dir", "."); 
    291299        vpath = vfs_path_from_str (buffer); 
    292300        if (vfs_file_is_local (vpath)) 
    main (int argc, char *argv[]) 
    305313    { 
    306314        vfs_shut (); 
    307315        done_setup (); 
     316        g_free (saved_this_dir); 
    308317        g_free (saved_other_dir); 
    309318        mc_event_deinit (NULL); 
    310319        goto startup_exit_falure; 
    main (int argc, char *argv[]) 
    481490        g_list_free_full ((GList *) mc_run_param0, (GDestroyNotify) mcedit_arg_free); 
    482491 
    483492    g_free (mc_run_param1); 
     493    g_free (saved_this_dir); 
    484494    g_free (saved_other_dir); 
    485495 
    486496    mc_config_deinit_config_paths (); 
  • src/filemanager/midnight.c

    old new create_panels (void) (this hunk was shorter than expected) 
    598598        current_mode = startup_left_mode; 
    599599        other_mode = startup_right_mode; 
    600600 
    601601        if (mc_run_param0 == NULL && mc_run_param1 == NULL) 
    602602        { 
    603603            /* no arguments */ 
    604             current_dir = NULL; /* assume current dir */ 
     604            if (panels_options.auto_save_setup) { /* check if we should restore active panel */ 
     605                current_dir = saved_this_dir; 
     606            } else { 
     607                current_dir = NULL; /* assume current dir */ 
     608            } 
    605609            other_dir = saved_other_dir;        /* from ini */ 
    606610        } 
    607611        else if (mc_run_param0 != NULL && mc_run_param1 != NULL) 
    create_panels (void) 
    628633        if (mc_run_param0 == NULL && mc_run_param1 == NULL) 
    629634        { 
    630635            /* no arguments */ 
    631             current_dir = NULL; /* assume current dir */ 
     636            if (panels_options.auto_save_setup) { /* check if we should restore active panel */ 
     637                current_dir = saved_this_dir; 
     638            } else { 
     639                current_dir = NULL; /* assume current dir */ 
     640            } 
    632641            other_dir = saved_other_dir;        /* from ini */ 
    633642        } 
    634643        else if (mc_run_param0 != NULL && mc_run_param1 != NULL)