[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [29875] trunk/blender/source/blender/ editors/space_file/filesel.c: changes to file selector so 'directory' property from an operator is used when available.

Campbell Barton ideasman42 at gmail.com
Fri Jul 2 19:44:57 CEST 2010


Revision: 29875
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=29875
Author:   campbellbarton
Date:     2010-07-02 19:44:57 +0200 (Fri, 02 Jul 2010)

Log Message:
-----------
changes to file selector so 'directory' property from an operator is used when available.
also made some other changes to the path functions used.

Modified Paths:
--------------
    trunk/blender/source/blender/editors/space_file/filesel.c

Modified: trunk/blender/source/blender/editors/space_file/filesel.c
===================================================================
--- trunk/blender/source/blender/editors/space_file/filesel.c	2010-07-02 17:37:55 UTC (rev 29874)
+++ trunk/blender/source/blender/editors/space_file/filesel.c	2010-07-02 17:44:57 UTC (rev 29875)
@@ -102,7 +102,6 @@
 
 short ED_fileselect_set_params(SpaceFile *sfile)
 {
-	char name[FILE_MAX], dir[FILE_MAX], file[FILE_MAX];
 	FileSelectParams *params;
 	wmOperator *op = sfile->op;
 
@@ -110,10 +109,7 @@
 	if (!sfile->params) {
 		sfile->params= MEM_callocN(sizeof(FileSelectParams), "fileselparams");
 		/* set path to most recently opened .blend */
-		BLI_strncpy(sfile->params->dir, G.sce, sizeof(sfile->params->dir));
-		BLI_split_dirfile(G.sce, dir, file);
-		BLI_strncpy(sfile->params->file, file, sizeof(sfile->params->file));
-		BLI_make_file_string(G.sce, sfile->params->dir, dir, ""); /* XXX needed ? - also solve G.sce */
+		BLI_split_dirfile(G.sce, sfile->params->dir, sfile->params->file);
 	}
 
 	params = sfile->params;
@@ -127,19 +123,27 @@
 		else
 			params->type = FILE_SPECIAL;
 
-		if (RNA_property_is_set(op->ptr, "filepath")) {
+		if (RNA_struct_find_property(op->ptr, "filepath") && RNA_property_is_set(op->ptr, "filepath")) {
+			char name[FILE_MAX];
 			RNA_string_get(op->ptr, "filepath", name);
 			if (params->type == FILE_LOADLIB) {
 				BLI_strncpy(params->dir, name, sizeof(params->dir));
-				BLI_cleanup_dir(G.sce, params->dir);	
-			} else { 
-				/* if operator has path set, use it, otherwise keep the last */
-				BLI_path_abs(name, G.sce);
-				BLI_split_dirfile(name, dir, file);
-				BLI_strncpy(params->file, file, sizeof(params->file));
-				BLI_make_file_string(G.sce, params->dir, dir, ""); /* XXX needed ? - also solve G.sce */
+				sfile->params->file[0]= '\0';
 			}
+			else {
+				BLI_split_dirfile(name, sfile->params->dir, sfile->params->file);
+			}
 		}
+
+		if (RNA_struct_find_property(op->ptr, "directory") && RNA_property_is_set(op->ptr, "directory")) {
+			RNA_string_get(op->ptr, "directory", params->dir);
+		}
+
+		if(params->dir[0]) {
+			BLI_cleanup_dir(G.sce, params->dir);
+			BLI_path_abs(params->dir, G.sce);
+		}
+
 		params->filter = 0;
 		if(RNA_struct_find_property(op->ptr, "filter_blender"))
 			params->filter |= RNA_boolean_get(op->ptr, "filter_blender") ? BLENDERFILE : 0;





More information about the Bf-blender-cvs mailing list