operator & splash button to copy over old settings when blender version changes.

This commit is contained in:
Campbell Barton 2011-04-11 15:13:06 +00:00
parent f8c09b37d4
commit 66419dcc12
2 changed files with 61 additions and 0 deletions

@ -909,6 +909,34 @@ class WM_OT_sysinfo(bpy.types.Operator):
return {'FINISHED'}
class WM_OT_copy_prev_settings(bpy.types.Operator):
'''Generate System Info'''
bl_idname = "wm.copy_prev_settings"
bl_label = "Copy Previous Settings"
def execute(self, context):
import os
import shutil
ver = bpy.app.version
ver_prev = ((ver[0] * 100) + ver[1]) - 1
ver_prev = ver_prev // 100, ver_prev % 100
for res in ('USER', 'LOCAL'):
path_src = bpy.utils.resource_path(res, ver_prev[0], ver_prev[1])
path_dst = bpy.utils.resource_path(res)
if os.path.isdir(path_dst):
self.report({'ERROR'}, "Path %r exists" % path_dst)
return {'CANCELLED'}
else:
break
if os.path.isdir(path_src):
shutil.copytree(path_src, path_dst)
bpy.ops.wm.read_homefile()
return {'FINISHED'}
def _webbrowser_bug_fix():
# test for X11
import os

@ -1107,6 +1107,33 @@ static void wm_block_splash_refreshmenu (bContext *UNUSED(C), void *UNUSED(arg_b
*/
}
static int wm_resource_check_prev(void)
{
char *res= BLI_get_folder_version(BLENDER_RESOURCE_PATH_USER, BLENDER_VERSION, TRUE);
// if(res) printf("USER: %s\n", res);
if(res == NULL) {
res= BLI_get_folder_version(BLENDER_RESOURCE_PATH_LOCAL, BLENDER_VERSION, TRUE);
}
// if(res) printf("LOCAL: %s\n", res);
if(res == NULL) {
int res_dir[]= {BLENDER_RESOURCE_PATH_USER, BLENDER_RESOURCE_PATH_LOCAL, -1};
int i= 0;
for(i= 0; res_dir[i] != -1; i++) {
if(BLI_get_folder_version(res_dir[i], BLENDER_VERSION - 1, TRUE)) {
return TRUE;
}
}
}
return FALSE;
}
static uiBlock *wm_block_create_splash(bContext *C, ARegion *ar, void *UNUSED(arg))
{
uiBlock *block;
@ -1183,6 +1210,12 @@ static uiBlock *wm_block_create_splash(bContext *C, ARegion *ar, void *UNUSED(ar
for(recent = G.recent_files.first, i=0; (i<5) && (recent); recent = recent->next, i++) {
uiItemStringO(col, BLI_path_basename(recent->filepath), ICON_FILE_BLEND, "WM_OT_open_mainfile", "filepath", recent->filepath);
}
if(wm_resource_check_prev()) {
uiItemS(col);
uiItemO(col, NULL, ICON_NEW, "WM_OT_copy_prev_settings");
}
uiItemS(col);
uiItemO(col, NULL, ICON_RECOVER_LAST, "WM_OT_recover_last_session");
uiItemL(col, "", ICON_NONE);