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>2011-06-16 19:28:39 +0400
committerCampbell Barton <ideasman42@gmail.com>2011-06-16 19:28:39 +0400
commitdce577ad85e9c3349000143cf4e7647254c01cb9 (patch)
treeb8b55655d65391ad35af1493dea1a76313cecdf4 /source/blender/editors/space_buttons
parentfd24c99b5ddd251ee64f95ae227ba76bcf9cb561 (diff)
use directory selector for properties defined as PROP_DIRPATH, user preferences 'File' buttons for eg.
Diffstat (limited to 'source/blender/editors/space_buttons')
-rw-r--r--source/blender/editors/space_buttons/buttons_intern.h1
-rw-r--r--source/blender/editors/space_buttons/buttons_ops.c24
-rw-r--r--source/blender/editors/space_buttons/space_buttons.c1
3 files changed, 23 insertions, 3 deletions
diff --git a/source/blender/editors/space_buttons/buttons_intern.h b/source/blender/editors/space_buttons/buttons_intern.h
index 925223b43ea..d25bd7940ab 100644
--- a/source/blender/editors/space_buttons/buttons_intern.h
+++ b/source/blender/editors/space_buttons/buttons_intern.h
@@ -71,6 +71,7 @@ extern const char *buttons_context_dir[]; /* doc access */
/* buttons_ops.c */
void BUTTONS_OT_file_browse(struct wmOperatorType *ot);
+void BUTTONS_OT_directory_browse(struct wmOperatorType *ot);
void BUTTONS_OT_toolbox(struct wmOperatorType *ot);
#endif /* ED_BUTTONS_INTERN_H */
diff --git a/source/blender/editors/space_buttons/buttons_ops.c b/source/blender/editors/space_buttons/buttons_ops.c
index 9b914df1b3c..99e5c6d693e 100644
--- a/source/blender/editors/space_buttons/buttons_ops.c
+++ b/source/blender/editors/space_buttons/buttons_ops.c
@@ -104,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) {
@@ -191,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")) {
@@ -227,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);
+}
diff --git a/source/blender/editors/space_buttons/space_buttons.c b/source/blender/editors/space_buttons/space_buttons.c
index 16c4df59420..e2d80e9e775 100644
--- a/source/blender/editors/space_buttons/space_buttons.c
+++ b/source/blender/editors/space_buttons/space_buttons.c
@@ -187,6 +187,7 @@ static void buttons_operatortypes(void)
{
WM_operatortype_append(BUTTONS_OT_toolbox);
WM_operatortype_append(BUTTONS_OT_file_browse);
+ WM_operatortype_append(BUTTONS_OT_directory_browse);
}
static void buttons_keymap(struct wmKeyConfig *keyconf)