[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [30501] trunk/blender/source/blender/ windowmanager: Add a "copy" option to the save_as_mainfile operator.
Xavier Thomas
xavier.thomas.1980 at gmail.com
Mon Jul 19 17:39:12 CEST 2010
Revision: 30501
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=30501
Author: xat
Date: 2010-07-19 17:39:12 +0200 (Mon, 19 Jul 2010)
Log Message:
-----------
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.
Modified Paths:
--------------
trunk/blender/source/blender/windowmanager/WM_api.h
trunk/blender/source/blender/windowmanager/intern/wm_files.c
trunk/blender/source/blender/windowmanager/intern/wm_operators.c
Modified: trunk/blender/source/blender/windowmanager/WM_api.h
===================================================================
--- trunk/blender/source/blender/windowmanager/WM_api.h 2010-07-19 13:36:10 UTC (rev 30500)
+++ trunk/blender/source/blender/windowmanager/WM_api.h 2010-07-19 15:39:12 UTC (rev 30501)
@@ -78,7 +78,7 @@
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);
Modified: trunk/blender/source/blender/windowmanager/intern/wm_files.c
===================================================================
--- trunk/blender/source/blender/windowmanager/intern/wm_files.c 2010-07-19 13:36:10 UTC (rev 30500)
+++ trunk/blender/source/blender/windowmanager/intern/wm_files.c 2010-07-19 15:39:12 UTC (rev 30501)
@@ -566,7 +566,7 @@
}
}
-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,12 +620,14 @@
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 */
+ 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 */
+ }
- G.save_over = 1; /* disable untitled.blend convention */
-
if(fileflags & G_FILE_COMPRESS) G.fileflags |= G_FILE_COMPRESS;
else G.fileflags &= ~G_FILE_COMPRESS;
Modified: trunk/blender/source/blender/windowmanager/intern/wm_operators.c
===================================================================
--- trunk/blender/source/blender/windowmanager/intern/wm_operators.c 2010-07-19 13:36:10 UTC (rev 30500)
+++ trunk/blender/source/blender/windowmanager/intern/wm_operators.c 2010-07-19 15:39:12 UTC (rev 30501)
@@ -1783,6 +1783,7 @@
{
char path[FILE_MAX];
int fileflags;
+ int copy=0;
save_set_compress(op);
@@ -1793,6 +1794,9 @@
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 @@
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 @@
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 @@
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
More information about the Bf-blender-cvs
mailing list