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:
authorCampbell Barton <ideasman42@gmail.com>2010-07-04 14:02:30 +0400
committerCampbell Barton <ideasman42@gmail.com>2010-07-04 14:02:30 +0400
commit8e97e561a9b0a9ab48675699c525410f4ad8a928 (patch)
tree0b10abd975866a7859512d9ac859811d0dacd23e /source/blender/editors/space_buttons
parentce94f52dbc1f18b805436313d26cdcef804622e9 (diff)
convenience functionality for browse button (requested by Colin for the sequence editor, useful for managing files for the final edit)
- Holding Alt while clocking on the browse button opens a file browser with the containing dir. - Holding Shift opens the file its self in the default application. obscure but at least theres a tooltip so its not totally hidden.
Diffstat (limited to 'source/blender/editors/space_buttons')
-rw-r--r--source/blender/editors/space_buttons/buttons_ops.c54
1 files changed, 40 insertions, 14 deletions
diff --git a/source/blender/editors/space_buttons/buttons_ops.c b/source/blender/editors/space_buttons/buttons_ops.c
index 765805aa65d..ebdc0d37b43 100644
--- a/source/blender/editors/space_buttons/buttons_ops.c
+++ b/source/blender/editors/space_buttons/buttons_ops.c
@@ -32,7 +32,10 @@
#include "DNA_userdef_types.h"
+#include "BLI_fileops.h"
+
#include "BKE_context.h"
+#include "BKE_global.h" /* G.sce only */
#include "WM_api.h"
#include "WM_types.h"
@@ -120,30 +123,53 @@ static int file_browse_invoke(bContext *C, wmOperator *op, wmEvent *event)
if(!prop)
return OPERATOR_CANCELLED;
-
- fbo= MEM_callocN(sizeof(FileBrowseOp), "FileBrowseOp");
- fbo->ptr= ptr;
- fbo->prop= prop;
- op->customdata= fbo;
str= RNA_property_string_get_alloc(&ptr, prop, 0, 0);
- RNA_string_set(op->ptr, "filepath", str);
- MEM_freeN(str);
- if(RNA_struct_find_property(op->ptr, "relative_path"))
- if(!RNA_property_is_set(op->ptr, "relative_path"))
- RNA_boolean_set(op->ptr, "relative_path", U.flag & USER_RELPATHS);
+ /* useful yet irritating feature, Shift+Click to open the file
+ * Alt+Click to browse a folder in the OS's browser */
+ if(event->shift || event->alt) {
+ PointerRNA props_ptr;
- WM_event_add_fileselect(C, op);
-
- return OPERATOR_RUNNING_MODAL;
+ if(event->alt) {
+ char *lslash= BLI_last_slash(str);
+ if(lslash)
+ *lslash= '\0';
+ }
+
+
+ WM_operator_properties_create(&props_ptr, "WM_OT_path_open");
+ RNA_string_set(&props_ptr, "filepath", str);
+ WM_operator_name_call(C, "WM_OT_path_open", WM_OP_EXEC_DEFAULT, &props_ptr);
+ WM_operator_properties_free(&props_ptr);
+
+ MEM_freeN(str);
+ return OPERATOR_CANCELLED;
+ }
+ else {
+ fbo= MEM_callocN(sizeof(FileBrowseOp), "FileBrowseOp");
+ fbo->ptr= ptr;
+ fbo->prop= prop;
+ op->customdata= fbo;
+
+ RNA_string_set(op->ptr, "filepath", str);
+ MEM_freeN(str);
+
+ if(RNA_struct_find_property(op->ptr, "relative_path"))
+ if(!RNA_property_is_set(op->ptr, "relative_path"))
+ RNA_boolean_set(op->ptr, "relative_path", U.flag & USER_RELPATHS);
+
+ WM_event_add_fileselect(C, op);
+
+ return OPERATOR_RUNNING_MODAL;
+ }
}
void BUTTONS_OT_file_browse(wmOperatorType *ot)
{
/* identifiers */
ot->name= "Accept";
- ot->description="Open a file browser";
+ ot->description="Open a file browser, Hold Shift to open the file, Alt to browse containing directory";
ot->idname= "BUTTONS_OT_file_browse";
/* api callbacks */