diff options
author | Xavier Thomas <xavier.thomas.1980@gmail.com> | 2010-07-19 19:39:12 +0400 |
---|---|---|
committer | Xavier Thomas <xavier.thomas.1980@gmail.com> | 2010-07-19 19:39:12 +0400 |
commit | ff83a98a07c3d55eac03ebd903ad7a0c3e6c33b4 (patch) | |
tree | dfde0715052e82d7ff89f1af9ee3e2879aaf78e9 /source/blender/windowmanager | |
parent | f7298287b34f34c120788a456dfc43351467a3cc (diff) |
Add a "copy" option to the save_as_mainfile operator. It saves the current
state but does not make the saved file active, so further save won't use
this filepath.
Diffstat (limited to 'source/blender/windowmanager')
-rw-r--r-- | source/blender/windowmanager/WM_api.h | 2 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_files.c | 14 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_operators.c | 8 |
3 files changed, 15 insertions, 9 deletions
diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h index 78ea0350667..46d42b300bf 100644 --- a/source/blender/windowmanager/WM_api.h +++ b/source/blender/windowmanager/WM_api.h @@ -78,7 +78,7 @@ void WM_window_open_temp (struct bContext *C, struct rcti *position, int type); int WM_read_homefile (struct bContext *C, struct wmOperator *op); int WM_write_homefile (struct bContext *C, struct wmOperator *op); void WM_read_file (struct bContext *C, char *name, struct ReportList *reports); -int WM_write_file (struct bContext *C, char *target, int fileflags, struct ReportList *reports); +int WM_write_file (struct bContext *C, char *target, int fileflags, struct ReportList *reports, int copy); void WM_read_autosavefile(struct bContext *C); void WM_autosave_init (struct wmWindowManager *wm); diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c index 86e08118e54..6457e184066 100644 --- a/source/blender/windowmanager/intern/wm_files.c +++ b/source/blender/windowmanager/intern/wm_files.c @@ -566,7 +566,7 @@ int write_crash_blend(void) } } -int WM_write_file(bContext *C, char *target, int fileflags, ReportList *reports) +int WM_write_file(bContext *C, char *target, int fileflags, ReportList *reports, int copy) { Library *li; int len; @@ -620,11 +620,13 @@ int WM_write_file(bContext *C, char *target, int fileflags, ReportList *reports) do_history(di, reports); if (BLO_write_file(CTX_data_main(C), di, fileflags, reports, thumb)) { - strcpy(G.sce, di); - G.relbase_valid = 1; - strcpy(G.main->name, di); /* is guaranteed current file */ - - G.save_over = 1; /* disable untitled.blend convention */ + if(!copy) { + strcpy(G.sce, di); + G.relbase_valid = 1; + strcpy(G.main->name, di); /* is guaranteed current file */ + + G.save_over = 1; /* disable untitled.blend convention */ + } if(fileflags & G_FILE_COMPRESS) G.fileflags |= G_FILE_COMPRESS; else G.fileflags &= ~G_FILE_COMPRESS; diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index 370dd111936..7d0ff1e44e8 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -1783,6 +1783,7 @@ static int wm_save_as_mainfile_exec(bContext *C, wmOperator *op) { char path[FILE_MAX]; int fileflags; + int copy=0; save_set_compress(op); @@ -1793,6 +1794,9 @@ static int wm_save_as_mainfile_exec(bContext *C, wmOperator *op) untitled(path); } + if(RNA_property_is_set(op->ptr, "copy")) + copy = RNA_boolean_get(op->ptr, "copy"); + fileflags= G.fileflags; /* set compression flag */ @@ -1801,7 +1805,7 @@ static int wm_save_as_mainfile_exec(bContext *C, wmOperator *op) if(RNA_boolean_get(op->ptr, "relative_remap")) fileflags |= G_FILE_RELATIVE_REMAP; else fileflags &= ~G_FILE_RELATIVE_REMAP; - if ( WM_write_file(C, path, fileflags, op->reports) != 0) + if ( WM_write_file(C, path, fileflags, op->reports, copy) != 0) return OPERATOR_CANCELLED; WM_event_add_notifier(C, NC_WM|ND_FILESAVE, NULL); @@ -1822,6 +1826,7 @@ static void WM_OT_save_as_mainfile(wmOperatorType *ot) WM_operator_properties_filesel(ot, FOLDERFILE|BLENDERFILE, FILE_BLENDER, FILE_SAVE, WM_FILESEL_FILEPATH); RNA_def_boolean(ot->srna, "compress", 0, "Compress", "Write compressed .blend file"); RNA_def_boolean(ot->srna, "relative_remap", 1, "Remap Relative", "Remap relative paths when saving in a different directory"); + RNA_def_boolean(ot->srna, "copy", 0, "Save Copy", "Save a copy of the actual working state but does not make saved file active."); } /* *************** save file directly ******** */ @@ -1873,7 +1878,6 @@ static void WM_OT_save_mainfile(wmOperatorType *ot) RNA_def_boolean(ot->srna, "relative_remap", 0, "Remap Relative", "Remap relative paths when saving in a different directory"); } - /* XXX: move these collada operators to a more appropriate place */ #ifdef WITH_COLLADA |