diff options
author | Matt Ebb <matt@mke3.net> | 2010-01-20 11:57:26 +0300 |
---|---|---|
committer | Matt Ebb <matt@mke3.net> | 2010-01-20 11:57:26 +0300 |
commit | a50674238683d2db5f4ecd2f889cbc03ee7d43de (patch) | |
tree | 5eb8680d96ae536ee1e82cc9c4f8693e4e41e571 | |
parent | 02ca0fda8ea86c5b5b05b8d1ef6cc81e8f280523 (diff) |
Fix [#20737] Double-click in file dialog opens ".." directory (and fails of course)
-rw-r--r-- | source/blender/editors/space_file/file_ops.c | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/source/blender/editors/space_file/file_ops.c b/source/blender/editors/space_file/file_ops.c index 85068200878..647c1d2be18 100644 --- a/source/blender/editors/space_file/file_ops.c +++ b/source/blender/editors/space_file/file_ops.c @@ -560,7 +560,7 @@ void FILE_OT_cancel(struct wmOperatorType *ot) } /* sends events now, so things get handled on windowqueue level */ -int file_exec(bContext *C, wmOperator *unused) +int file_exec(bContext *C, wmOperator *exec_op) { SpaceFile *sfile= CTX_wm_space_file(C); char name[FILE_MAX]; @@ -568,6 +568,22 @@ int file_exec(bContext *C, wmOperator *unused) if(sfile->op) { wmOperator *op= sfile->op; + /* when used as a macro, for doubleclick, + to prevent closing when doubleclicking on .. item */ + if (RNA_boolean_get(exec_op->ptr, "need_active")) { + int i, active=0; + struct direntry *file; + + for (i=0; i<filelist_numfiles(sfile->files); i++) { + file = filelist_file(sfile->files, i); + if(file->flags & ACTIVE) { + active=1; + } + } + if (active == 0) + return OPERATOR_CANCELLED; + } + sfile->op = NULL; RNA_string_set(op->ptr, "filename", sfile->params->file); BLI_strncpy(name, sfile->params->dir, sizeof(name)); @@ -637,6 +653,8 @@ void FILE_OT_execute(struct wmOperatorType *ot) /* api callbacks */ ot->exec= file_exec; ot->poll= file_operator_poll; + + RNA_def_boolean(ot->srna, "need_active", 0, "Need Active", "Only execute if there's an active selected file in the file list."); } @@ -1094,9 +1112,11 @@ void FILE_OT_delete(struct wmOperatorType *ot) void ED_operatormacros_file(void) { wmOperatorType *ot; + wmOperatorTypeMacro *otmacro; ot= WM_operatortype_append_macro("FILE_OT_select_execute", "Select and Execute", OPTYPE_UNDO|OPTYPE_REGISTER); WM_operatortype_macro_define(ot, "FILE_OT_select"); - WM_operatortype_macro_define(ot, "FILE_OT_execute"); + otmacro= WM_operatortype_macro_define(ot, "FILE_OT_execute"); + RNA_boolean_set(otmacro->ptr, "need_active", 1); } |