Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/editors/space_buttons/buttons_ops.c')
-rw-r--r--source/blender/editors/space_buttons/buttons_ops.c37
1 files changed, 34 insertions, 3 deletions
diff --git a/source/blender/editors/space_buttons/buttons_ops.c b/source/blender/editors/space_buttons/buttons_ops.c
index 9190d5aff54..99e5c6d693e 100644
--- a/source/blender/editors/space_buttons/buttons_ops.c
+++ b/source/blender/editors/space_buttons/buttons_ops.c
@@ -51,6 +51,7 @@
#include "WM_types.h"
#include "ED_screen.h"
+#include "ED_util.h"
#include "RNA_access.h"
@@ -103,11 +104,12 @@ static int file_browse_exec(bContext *C, wmOperator *op)
FileBrowseOp *fbo= op->customdata;
ID *id;
char *base, *str, path[FILE_MAX];
+ const char *path_prop= RNA_struct_find_property(op->ptr, "directory") ? "directory" : "filepath";
- if (RNA_property_is_set(op->ptr, "filepath")==0 || fbo==NULL)
+ if (RNA_property_is_set(op->ptr, path_prop)==0 || fbo==NULL)
return OPERATOR_CANCELLED;
- str= RNA_string_get_alloc(op->ptr, "filepath", NULL, 0);
+ str= RNA_string_get_alloc(op->ptr, path_prop, NULL, 0);
/* add slash for directories, important for some properties */
if(RNA_property_subtype(fbo->prop) == PROP_DIRPATH) {
@@ -131,7 +133,19 @@ static int file_browse_exec(bContext *C, wmOperator *op)
RNA_property_update(C, &fbo->ptr, fbo->prop);
MEM_freeN(str);
+
+ /* special, annoying exception, filesel on redo panel [#26618] */
+ {
+ wmOperator *redo_op= WM_operator_last_redo(C);
+ if(redo_op) {
+ if(fbo->ptr.data == redo_op->ptr->data) {
+ ED_undo_operator_repeat(C, redo_op);
+ }
+ }
+ }
+
MEM_freeN(op->customdata);
+
return OPERATOR_FINISHED;
}
@@ -178,12 +192,13 @@ static int file_browse_invoke(bContext *C, wmOperator *op, wmEvent *event)
return OPERATOR_CANCELLED;
}
else {
+ const char *path_prop= RNA_struct_find_property(op->ptr, "directory") ? "directory" : "filepath";
fbo= MEM_callocN(sizeof(FileBrowseOp), "FileBrowseOp");
fbo->ptr= ptr;
fbo->prop= prop;
op->customdata= fbo;
- RNA_string_set(op->ptr, "filepath", str);
+ RNA_string_set(op->ptr, path_prop, str);
MEM_freeN(str);
if(RNA_struct_find_property(op->ptr, "relative_path")) {
@@ -214,3 +229,19 @@ void BUTTONS_OT_file_browse(wmOperatorType *ot)
WM_operator_properties_filesel(ot, 0, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_FILEPATH|WM_FILESEL_RELPATH);
}
+/* second operator, only difference from BUTTONS_OT_file_browse is WM_FILESEL_DIRECTORY */
+void BUTTONS_OT_directory_browse(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name= "Accept";
+ ot->description="Open a directory browser, Hold Shift to open the file, Alt to browse containing directory";
+ ot->idname= "BUTTONS_OT_directory_browse";
+
+ /* api callbacks */
+ ot->invoke= file_browse_invoke;
+ ot->exec= file_browse_exec;
+ ot->cancel= file_browse_cancel;
+
+ /* properties */
+ WM_operator_properties_filesel(ot, 0, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_DIRECTORY|WM_FILESEL_RELPATH);
+}