adding image strips wasnt working, use the 'directory' component of the file selector...
authorCampbell Barton <ideasman42@gmail.com>
Thu, 1 Jul 2010 19:28:45 +0000 (19:28 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Thu, 1 Jul 2010 19:28:45 +0000 (19:28 +0000)
added flags for filename/filepath/directory args to WM_operator_properties_filesel().

14 files changed:
source/blender/editors/curve/editfont.c
source/blender/editors/object/object_modifier.c
source/blender/editors/render/render_shading.c
source/blender/editors/screen/screendump.c
source/blender/editors/sound/sound_ops.c
source/blender/editors/space_buttons/buttons_ops.c
source/blender/editors/space_graph/graph_edit.c
source/blender/editors/space_image/image_ops.c
source/blender/editors/space_info/info_ops.c
source/blender/editors/space_node/node_edit.c
source/blender/editors/space_sequencer/sequencer_add.c
source/blender/editors/space_text/text_ops.c
source/blender/windowmanager/WM_api.h
source/blender/windowmanager/intern/wm_operators.c

index 3a5f185..7d5af54 100644 (file)
@@ -417,7 +417,7 @@ void FONT_OT_file_paste(wmOperatorType *ot)
        ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
 
        /* properties */
-       WM_operator_properties_filesel(ot, FOLDERFILE|TEXTFILE, FILE_SPECIAL, FILE_OPENFILE, 0);
+       WM_operator_properties_filesel(ot, FOLDERFILE|TEXTFILE, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_FILEPATH);
 }
 
 /******************* paste buffer operator ********************/
@@ -1732,7 +1732,7 @@ void FONT_OT_open(wmOperatorType *ot)
        ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
        
        /* properties */
-       WM_operator_properties_filesel(ot, FOLDERFILE|FTFONTFILE, FILE_SPECIAL, FILE_OPENFILE, 0);
+       WM_operator_properties_filesel(ot, FOLDERFILE|FTFONTFILE, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_FILEPATH);
 }
 
 /******************* delete operator *********************/
index 5674241..ec142d2 100644 (file)
@@ -1081,7 +1081,7 @@ void OBJECT_OT_multires_external_save(wmOperatorType *ot)
        /* flags */
        ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
 
-       WM_operator_properties_filesel(ot, FOLDERFILE|BTXFILE, FILE_SPECIAL, FILE_SAVE, FILE_RELPATH);
+       WM_operator_properties_filesel(ot, FOLDERFILE|BTXFILE, FILE_SPECIAL, FILE_SAVE, WM_FILESEL_FILEPATH|WM_FILESEL_RELPATH);
        edit_modifier_properties(ot);
 }
 
index 006d98c..4a94756 100644 (file)
@@ -913,7 +913,7 @@ void TEXTURE_OT_envmap_save(wmOperatorType *ot)
        
        /* properties */
        //RNA_def_enum(ot->srna, "file_type", image_file_type_items, R_PNG, "File Type", "File type to save image as.");
-       WM_operator_properties_filesel(ot, FOLDERFILE|IMAGEFILE|MOVIEFILE, FILE_SPECIAL, FILE_SAVE, FILE_RELPATH);
+       WM_operator_properties_filesel(ot, FOLDERFILE|IMAGEFILE|MOVIEFILE, FILE_SPECIAL, FILE_SAVE, WM_FILESEL_FILEPATH|WM_FILESEL_RELPATH);
 }
 
 static int envmap_clear_exec(bContext *C, wmOperator *op)
index 5f592ae..d5cd828 100644 (file)
@@ -171,7 +171,7 @@ void SCREEN_OT_screenshot(wmOperatorType *ot)
        
        ot->flag= 0;
        
-       WM_operator_properties_filesel(ot, FOLDERFILE|IMAGEFILE, FILE_SPECIAL, FILE_SAVE, 0);
+       WM_operator_properties_filesel(ot, FOLDERFILE|IMAGEFILE, FILE_SPECIAL, FILE_SAVE, WM_FILESEL_FILEPATH);
        RNA_def_boolean(ot->srna, "full", 1, "Full Screen", "");
 }
 
index f362c58..0d2dfd7 100644 (file)
@@ -150,7 +150,7 @@ void SOUND_OT_open(wmOperatorType *ot)
        ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
 
        /* properties */
-       WM_operator_properties_filesel(ot, FOLDERFILE|SOUNDFILE|MOVIEFILE, FILE_SPECIAL, FILE_OPENFILE, FILE_RELPATH);
+       WM_operator_properties_filesel(ot, FOLDERFILE|SOUNDFILE|MOVIEFILE, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_RELPATH);
        RNA_def_boolean(ot->srna, "cache", FALSE, "Cache", "Cache the sound in memory.");
 }
 
index 96cf79d..765805a 100644 (file)
@@ -152,6 +152,6 @@ void BUTTONS_OT_file_browse(wmOperatorType *ot)
        ot->cancel= file_browse_cancel;
 
        /* properties */
-       WM_operator_properties_filesel(ot, 0, FILE_SPECIAL, FILE_OPENFILE, FILE_RELPATH);
+       WM_operator_properties_filesel(ot, 0, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_FILEPATH|WM_FILESEL_RELPATH);
 }
 
index a4a72ad..6249edc 100644 (file)
@@ -1117,7 +1117,7 @@ void GRAPH_OT_sound_bake (wmOperatorType *ot)
        ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
 
        /* properties */
-       WM_operator_properties_filesel(ot, FOLDERFILE|SOUNDFILE|MOVIEFILE, FILE_SPECIAL, FILE_OPENFILE, 0);
+       WM_operator_properties_filesel(ot, FOLDERFILE|SOUNDFILE|MOVIEFILE, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_FILEPATH);
        RNA_def_float(ot->srna, "low", 0.0f, 0.0, 100000.0, "Lowest frequency", "", 0.1, 1000.00);
        RNA_def_float(ot->srna, "high", 100000.0, 0.0, 100000.0, "Highest frequency", "", 0.1, 1000.00);
        RNA_def_float(ot->srna, "attack", 0.005, 0.0, 2.0, "Attack time", "", 0.01, 0.1);
index 1787faf..48f9e7e 100644 (file)
@@ -755,7 +755,7 @@ void IMAGE_OT_open(wmOperatorType *ot)
        ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
 
        /* properties */
-       WM_operator_properties_filesel(ot, FOLDERFILE|IMAGEFILE|MOVIEFILE, FILE_SPECIAL, FILE_OPENFILE, FILE_RELPATH);
+       WM_operator_properties_filesel(ot, FOLDERFILE|IMAGEFILE|MOVIEFILE, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_FILEPATH|WM_FILESEL_RELPATH);
 }
 
 /******************** replace image operator ********************/
@@ -810,7 +810,7 @@ void IMAGE_OT_replace(wmOperatorType *ot)
        ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
 
        /* properties */
-       WM_operator_properties_filesel(ot, FOLDERFILE|IMAGEFILE|MOVIEFILE, FILE_SPECIAL, FILE_OPENFILE, FILE_RELPATH);
+       WM_operator_properties_filesel(ot, FOLDERFILE|IMAGEFILE|MOVIEFILE, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_FILEPATH|WM_FILESEL_RELPATH);
 }
 
 /******************** save image as operator ********************/
@@ -998,7 +998,7 @@ void IMAGE_OT_save_as(wmOperatorType *ot)
 
        /* properties */
        RNA_def_enum(ot->srna, "file_type", image_file_type_items, R_PNG, "File Type", "File type to save image as.");
-       WM_operator_properties_filesel(ot, FOLDERFILE|IMAGEFILE|MOVIEFILE, FILE_SPECIAL, FILE_SAVE, FILE_RELPATH);
+       WM_operator_properties_filesel(ot, FOLDERFILE|IMAGEFILE|MOVIEFILE, FILE_SPECIAL, FILE_SAVE, WM_FILESEL_FILEPATH|WM_FILESEL_RELPATH);
 
        RNA_def_boolean(ot->srna, "copy", 0, "Copy", "Create a new image file without modifying the current image in blender");
 }
index 2a1a20a..62e82f8 100644 (file)
@@ -299,7 +299,7 @@ void FILE_OT_find_missing_files(wmOperatorType *ot)
        ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
 
        /* properties */
-       WM_operator_properties_filesel(ot, 0, FILE_SPECIAL, FILE_OPENFILE, 0);
+       WM_operator_properties_filesel(ot, 0, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_FILEPATH);
 }
 
 /********************* report box operator *********************/
index dd838a6..b5ed2f4 100644 (file)
@@ -2312,7 +2312,7 @@ void NODE_OT_add_file(wmOperatorType *ot)
        /* flags */
        ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
        
-       WM_operator_properties_filesel(ot, FOLDERFILE|IMAGEFILE, FILE_SPECIAL, FILE_OPENFILE, 0);  //XXX TODO, relative_path
+       WM_operator_properties_filesel(ot, FOLDERFILE|IMAGEFILE, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_FILEPATH);  //XXX TODO, relative_path
        RNA_def_string(ot->srna, "name", "Image", 24, "Name", "Datablock name to assign.");
 }
 
index 9b69cbd..508521c 100644 (file)
@@ -147,7 +147,10 @@ static void seq_load_operator_info(SeqLoadInfo *seq_load, wmOperator *op)
 
        RNA_string_get(op->ptr, "name", seq_load->name+2);
 
-       RNA_string_get(op->ptr, "filepath", seq_load->path); /* full path, file is set by the caller */
+       if(RNA_struct_find_property(op->ptr, "filepath"))
+               RNA_string_get(op->ptr, "filepath", seq_load->path); /* full path, file is set by the caller */
+       else if (RNA_struct_find_property(op->ptr, "filepath"))
+               RNA_string_get(op->ptr, "directory", seq_load->path); /* full path, file is set by the caller */
 
        if (RNA_struct_find_property(op->ptr, "frame_end")) {
                seq_load->end_frame = RNA_int_get(op->ptr, "frame_end");
@@ -354,7 +357,7 @@ void SEQUENCER_OT_movie_strip_add(struct wmOperatorType *ot)
        /* flags */
        ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
        
-       WM_operator_properties_filesel(ot, FOLDERFILE|MOVIEFILE, FILE_SPECIAL, FILE_OPENFILE, FILE_RELPATH);
+       WM_operator_properties_filesel(ot, FOLDERFILE|MOVIEFILE, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_FILEPATH|WM_FILESEL_RELPATH);
        sequencer_generic_props__internal(ot, SEQPROP_STARTFRAME|SEQPROP_FILES);
        RNA_def_boolean(ot->srna, "sound", TRUE, "Sound", "Load sound with the movie");
 }
@@ -402,7 +405,7 @@ void SEQUENCER_OT_sound_strip_add(struct wmOperatorType *ot)
        /* flags */
        ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
        
-       WM_operator_properties_filesel(ot, FOLDERFILE|SOUNDFILE, FILE_SPECIAL, FILE_OPENFILE, FILE_RELPATH);
+       WM_operator_properties_filesel(ot, FOLDERFILE|SOUNDFILE, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_FILEPATH|WM_FILESEL_RELPATH);
        sequencer_generic_props__internal(ot, SEQPROP_STARTFRAME|SEQPROP_FILES);
        RNA_def_boolean(ot->srna, "cache", FALSE, "Cache", "Cache the sound in memory.");
 }
@@ -499,7 +502,7 @@ void SEQUENCER_OT_image_strip_add(struct wmOperatorType *ot)
        /* flags */
        ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
        
-       WM_operator_properties_filesel(ot, FOLDERFILE|IMAGEFILE, FILE_SPECIAL, FILE_OPENFILE, FILE_RELPATH);
+       WM_operator_properties_filesel(ot, FOLDERFILE|IMAGEFILE, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_FILEPATH|WM_FILESEL_RELPATH);
        sequencer_generic_props__internal(ot, SEQPROP_STARTFRAME|SEQPROP_ENDFRAME|SEQPROP_FILES);
 }
 
@@ -651,7 +654,7 @@ void SEQUENCER_OT_effect_strip_add(struct wmOperatorType *ot)
        /* flags */
        ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
        
-       WM_operator_properties_filesel(ot, 0, FILE_SPECIAL, FILE_OPENFILE, FILE_RELPATH);
+       WM_operator_properties_filesel(ot, 0, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_FILEPATH|WM_FILESEL_RELPATH);
        sequencer_generic_props__internal(ot, SEQPROP_STARTFRAME|SEQPROP_ENDFRAME);
        RNA_def_enum(ot->srna, "type", sequencer_prop_effect_types, SEQ_CROSS, "Type", "Sequencer effect type");
        RNA_def_float_vector(ot->srna, "color", 3, NULL, 0.0f, 1.0f, "Color", "Initialize the strip with this color (only used when type='COLOR')", 0.0f, 1.0f);
index c90d257..a684c4d 100644 (file)
@@ -295,7 +295,7 @@ void TEXT_OT_open(wmOperatorType *ot)
        ot->flag= OPTYPE_UNDO;
        
        /* properties */
-       WM_operator_properties_filesel(ot, FOLDERFILE|TEXTFILE|PYSCRIPTFILE, FILE_SPECIAL, FILE_OPENFILE, 0);  //XXX TODO, relative_path
+       WM_operator_properties_filesel(ot, FOLDERFILE|TEXTFILE|PYSCRIPTFILE, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_FILEPATH);  //XXX TODO, relative_path
        RNA_def_boolean(ot->srna, "internal", 0, "Make internal", "Make text file internal after loading");
 }
 
@@ -542,7 +542,7 @@ void TEXT_OT_save_as(wmOperatorType *ot)
        ot->poll= text_edit_poll;
 
        /* properties */
-       WM_operator_properties_filesel(ot, FOLDERFILE|TEXTFILE|PYSCRIPTFILE, FILE_SPECIAL, FILE_SAVE, 0);  //XXX TODO, relative_path
+       WM_operator_properties_filesel(ot, FOLDERFILE|TEXTFILE|PYSCRIPTFILE, FILE_SPECIAL, FILE_SAVE, WM_FILESEL_FILEPATH);  //XXX TODO, relative_path
 }
 
 /******************* run script operator *********************/
index dbbe131..235be83 100644 (file)
@@ -234,6 +234,15 @@ void               WM_operator_properties_select_all(struct wmOperatorType *ot);
 #define SEL_DESELECT   2
 #define SEL_INVERT             3
 
+
+/* flags for WM_operator_properties_filesel */
+#define WM_FILESEL_RELPATH             (1 << 0)
+
+#define WM_FILESEL_DIRECTORY   (1 << 1)
+#define WM_FILESEL_FILENAME            (1 << 2)
+#define WM_FILESEL_FILEPATH            (1 << 3)
+
+
                /* operator as a python command (resultuing string must be free'd) */
 char           *WM_operator_pystring(struct bContext *C, struct wmOperatorType *ot, struct PointerRNA *opptr, int all_args);
 void           WM_operator_bl_idname(char *to, const char *from);
index 058c397..daf1c4e 100644 (file)
@@ -788,7 +788,15 @@ void WM_operator_properties_filesel(wmOperatorType *ot, int filter, short type,
 {
        PropertyRNA *prop;
 
-       RNA_def_string_file_path(ot->srna, "filepath", "", FILE_MAX, "File Path", "Path to file");
+
+       if(flag & WM_FILESEL_FILEPATH)
+               RNA_def_string_file_path(ot->srna, "filepath", "", FILE_MAX, "File Path", "Path to file");
+
+       if(flag & WM_FILESEL_DIRECTORY)
+               RNA_def_string_dir_path(ot->srna, "directory", "", FILE_MAX, "Directory", "Directory of the file");
+
+       if(flag & WM_FILESEL_FILENAME)
+               RNA_def_string_file_name(ot->srna, "filename", "", FILE_MAX, "File Name", "Name 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");
@@ -821,7 +829,7 @@ void WM_operator_properties_filesel(wmOperatorType *ot, int filter, short type,
                FILE_LOADLIB, FILE_SPECIAL);
        RNA_def_property_flag(prop, PROP_HIDDEN);
 
-       if(flag & FILE_RELPATH)
+       if(flag & WM_FILESEL_RELPATH)
                RNA_def_boolean(ot->srna, "relative_path", 0, "Relative Path", "Select the file relative to the blend file");
 }
 
@@ -1473,7 +1481,7 @@ static void WM_OT_open_mainfile(wmOperatorType *ot)
        ot->exec= wm_open_mainfile_exec;
        ot->poll= WM_operator_winactive;
        
-       WM_operator_properties_filesel(ot, FOLDERFILE|BLENDERFILE, FILE_BLENDER, FILE_OPENFILE, 0);
+       WM_operator_properties_filesel(ot, FOLDERFILE|BLENDERFILE, FILE_BLENDER, FILE_OPENFILE, WM_FILESEL_FILEPATH);
 
        RNA_def_boolean(ot->srna, "load_ui", 1, "Load UI", "Load user interface setup in the .blend file");
        RNA_def_boolean(ot->srna, "use_scripts", 1, "Trusted Source", "Allow blend file execute scripts automatically, default available from system preferences");
@@ -1644,16 +1652,13 @@ static void WM_OT_link_append(wmOperatorType *ot)
        
        ot->flag |= OPTYPE_UNDO;
 
-       WM_operator_properties_filesel(ot, FOLDERFILE|BLENDERFILE, FILE_LOADLIB, FILE_OPENFILE, FILE_RELPATH);
+       WM_operator_properties_filesel(ot, FOLDERFILE|BLENDERFILE, FILE_LOADLIB, FILE_OPENFILE, WM_FILESEL_FILEPATH|WM_FILESEL_DIRECTORY|WM_FILESEL_FILENAME| WM_FILESEL_RELPATH);
        
        RNA_def_boolean(ot->srna, "link", 1, "Link", "Link the objects or datablocks rather than appending");
        RNA_def_boolean(ot->srna, "autoselect", 1, "Select", "Select the linked objects");
        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", "");
 }      
 
@@ -1674,7 +1679,6 @@ static int wm_recover_last_session_exec(bContext *C, wmOperator *op)
        WM_read_file(C, filename, op->reports);
 
        G.fileflags &= ~G_FILE_RECOVER;
-
        return OPERATOR_FINISHED;
 }
 
@@ -1731,7 +1735,7 @@ static void WM_OT_recover_auto_save(wmOperatorType *ot)
        ot->invoke= wm_recover_auto_save_invoke;
        ot->poll= WM_operator_winactive;
 
-       WM_operator_properties_filesel(ot, BLENDERFILE, FILE_BLENDER, FILE_OPENFILE, 0);
+       WM_operator_properties_filesel(ot, BLENDERFILE, FILE_BLENDER, FILE_OPENFILE, WM_FILESEL_FILEPATH);
 }
 
 /* *************** save file as **************** */
@@ -1814,7 +1818,7 @@ static void WM_OT_save_as_mainfile(wmOperatorType *ot)
        ot->exec= wm_save_as_mainfile_exec;
        ot->poll= WM_operator_winactive;
        
-       WM_operator_properties_filesel(ot, FOLDERFILE|BLENDERFILE, FILE_BLENDER, FILE_SAVE, 0);
+       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", 0, "Remap Relative", "Remap relative paths when saving in a different directory");
 }
@@ -1863,7 +1867,7 @@ static void WM_OT_save_mainfile(wmOperatorType *ot)
        ot->exec= wm_save_as_mainfile_exec;
        ot->poll= NULL;
        
-       WM_operator_properties_filesel(ot, FOLDERFILE|BLENDERFILE, FILE_BLENDER, FILE_SAVE, 0);
+       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", 0, "Remap Relative", "Remap relative paths when saving in a different directory");
 }
@@ -1912,7 +1916,7 @@ static void WM_OT_collada_export(wmOperatorType *ot)
        ot->exec= wm_collada_export_exec;
        ot->poll= WM_operator_winactive;
        
-       WM_operator_properties_filesel(ot, FOLDERFILE|COLLADAFILE, FILE_BLENDER, FILE_SAVE, 0);
+       WM_operator_properties_filesel(ot, FOLDERFILE|COLLADAFILE, FILE_BLENDER, FILE_SAVE, WM_FILESEL_FILEPATH);
 }
 
 /* function used for WM_OT_save_mainfile too */
@@ -1940,7 +1944,7 @@ static void WM_OT_collada_import(wmOperatorType *ot)
        ot->exec= wm_collada_import_exec;
        ot->poll= WM_operator_winactive;
        
-       WM_operator_properties_filesel(ot, FOLDERFILE|COLLADAFILE, FILE_BLENDER, FILE_OPENFILE, 0);
+       WM_operator_properties_filesel(ot, FOLDERFILE|COLLADAFILE, FILE_BLENDER, FILE_OPENFILE, WM_FILESEL_FILEPATH);
 }
 
 #endif