Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2011-04-11 19:13:06 +0400
committerCampbell Barton <ideasman42@gmail.com>2011-04-11 19:13:06 +0400
commit66419dcc121ce23aa0ef34eaf1b3480ea6bf82f5 (patch)
tree22d1fc3d9d16e5fc386b69f9f05757eb49a92ebc
parentf8c09b37d4ca2c6a40ee84f5ef89db0f0c8b0c86 (diff)
operator & splash button to copy over old settings when blender version changes.
-rw-r--r--release/scripts/startup/bl_operators/wm.py28
-rw-r--r--source/blender/windowmanager/intern/wm_operators.c33
2 files changed, 61 insertions, 0 deletions
diff --git a/release/scripts/startup/bl_operators/wm.py b/release/scripts/startup/bl_operators/wm.py
index f103d0aaf5e..3ecdb70d2a1 100644
--- a/release/scripts/startup/bl_operators/wm.py
+++ b/release/scripts/startup/bl_operators/wm.py
@@ -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
diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c
index fa4c2456601..171ff239c69 100644
--- a/source/blender/windowmanager/intern/wm_operators.c
+++ b/source/blender/windowmanager/intern/wm_operators.c
@@ -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);