[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [29702] trunk/blender/source/blender: file operator cleanup
Andrea Weikert
elubie at gmx.net
Sat Jun 26 10:53:30 CEST 2010
Revision: 29702
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=29702
Author: elubie
Date: 2010-06-26 10:53:29 +0200 (Sat, 26 Jun 2010)
Log Message:
-----------
file operator cleanup
* the default properties of the file operator now only contain the "filepath", which means only the complete path to a file is returned.
* "filename" and "directory" has been added to the link/append operator - the only place it was used.
* sequence operators still work on the "files", which was custom property passed to the file operator anyway.
* have tested sequence loading, image loading and append/link - please report if there are any issues
Modified Paths:
--------------
trunk/blender/source/blender/editors/space_file/file_ops.c
trunk/blender/source/blender/windowmanager/intern/wm_operators.c
Modified: trunk/blender/source/blender/editors/space_file/file_ops.c
===================================================================
--- trunk/blender/source/blender/editors/space_file/file_ops.c 2010-06-26 01:34:49 UTC (rev 29701)
+++ trunk/blender/source/blender/editors/space_file/file_ops.c 2010-06-26 08:53:29 UTC (rev 29702)
@@ -545,7 +545,7 @@
int file_exec(bContext *C, wmOperator *exec_op)
{
SpaceFile *sfile= CTX_wm_space_file(C);
- char name[FILE_MAX];
+ char filepath[FILE_MAX];
if(sfile->op) {
wmOperator *op= sfile->op;
@@ -567,16 +567,23 @@
}
sfile->op = NULL;
- RNA_string_set(op->ptr, "filename", sfile->params->file);
- BLI_strncpy(name, sfile->params->dir, sizeof(name));
- RNA_string_set(op->ptr, "directory", name);
- strcat(name, sfile->params->file); // XXX unsafe
- if(RNA_struct_find_property(op->ptr, "relative_path"))
- if(RNA_boolean_get(op->ptr, "relative_path"))
- BLI_path_rel(name, G.sce);
+ BLI_join_dirfile(filepath, sfile->params->dir, sfile->params->file);
+ if(RNA_struct_find_property(op->ptr, "relative_path")) {
+ if(RNA_boolean_get(op->ptr, "relative_path")) {
+ BLI_path_rel(filepath, G.sce);
+ }
+ }
- RNA_string_set(op->ptr, "filepath", name);
+ if(RNA_struct_find_property(op->ptr, "filename")) {
+ RNA_string_set(op->ptr, "filename", sfile->params->file);
+ }
+ if(RNA_struct_find_property(op->ptr, "directory")) {
+ RNA_string_set(op->ptr, "directory", sfile->params->dir);
+ }
+ if(RNA_struct_find_property(op->ptr, "filepath")) {
+ RNA_string_set(op->ptr, "filepath", filepath);
+ }
/* some ops have multiple files to select */
{
@@ -612,8 +619,8 @@
folderlist_free(sfile->folders_next);
fsmenu_insert_entry(fsmenu_get(), FS_CATEGORY_RECENT, sfile->params->dir,0, 1);
- BLI_make_file_string(G.sce, name, BLI_gethome(), ".Bfs");
- fsmenu_write_file(fsmenu_get(), name);
+ BLI_make_file_string(G.sce, filepath, BLI_gethome(), ".Bfs");
+ fsmenu_write_file(fsmenu_get(), filepath);
WM_event_fileselect_event(C, op, EVT_FILESELECT_EXEC);
ED_fileselect_clear(C, sfile);
Modified: trunk/blender/source/blender/windowmanager/intern/wm_operators.c
===================================================================
--- trunk/blender/source/blender/windowmanager/intern/wm_operators.c 2010-06-26 01:34:49 UTC (rev 29701)
+++ trunk/blender/source/blender/windowmanager/intern/wm_operators.c 2010-06-26 08:53:29 UTC (rev 29702)
@@ -789,8 +789,6 @@
PropertyRNA *prop;
RNA_def_string_file_path(ot->srna, "filepath", "", FILE_MAX, "File Path", "Path to file");
- RNA_def_string_file_name(ot->srna, "filename", "", FILE_MAX, "File Name", "Name of the file");
- RNA_def_string_dir_path(ot->srna, "directory", "", FILE_MAX, "Directory", "Directory of the file");
if (action == FILE_SAVE) {
prop= RNA_def_boolean(ot->srna, "check_existing", 1, "Check Existing", "Check and warn on overwriting existing files");
@@ -1653,6 +1651,9 @@
RNA_def_boolean(ot->srna, "active_layer", 1, "Active Layer", "Put the linked objects on the active layer");
RNA_def_boolean(ot->srna, "instance_groups", 1, "Instance Groups", "Create instances for each group as a DupliGroup");
+ RNA_def_string_file_name(ot->srna, "filename", "", FILE_MAX, "File Name", "Name of the file");
+ RNA_def_string_dir_path(ot->srna, "directory", "", FILE_MAX, "Directory", "Directory of the file");
+
RNA_def_collection_runtime(ot->srna, "files", &RNA_OperatorFileListElement, "Files", "");
}
More information about the Bf-blender-cvs
mailing list