diff options
author | Gaia Clary <gaia.clary@machinimatrix.org> | 2015-11-04 16:24:46 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2015-11-04 17:33:50 +0300 |
commit | b566adec5255a0d463dd7d16bc7acbb5d6fdbbaf (patch) | |
tree | 047ea0a4e6d8acf69624e900ccb9983083dfd9ec /source/blender/editors/space_file/space_file.c | |
parent | e43b6e2f9725edd8cbe1ca8538c8a2bbdf1b45cd (diff) |
File Selector, support filepath dropping
This adds support for dropping a filepath on an open file-selector to set that path.
Diffstat (limited to 'source/blender/editors/space_file/space_file.c')
-rw-r--r-- | source/blender/editors/space_file/space_file.c | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/source/blender/editors/space_file/space_file.c b/source/blender/editors/space_file/space_file.c index 97c2d75e469..3202164edbd 100644 --- a/source/blender/editors/space_file/space_file.c +++ b/source/blender/editors/space_file/space_file.c @@ -441,6 +441,7 @@ static void file_operatortypes(void) WM_operatortype_append(FILE_OT_delete); WM_operatortype_append(FILE_OT_rename); WM_operatortype_append(FILE_OT_smoothscroll); + WM_operatortype_append(FILE_OT_filepath_drop); } /* NOTE: do not add .blend file reading on this level */ @@ -661,6 +662,30 @@ static void file_ui_area_listener(bScreen *UNUSED(sc), ScrArea *UNUSED(sa), AReg } } +static int filepath_drop_poll(bContext *C, wmDrag *drag, const wmEvent *UNUSED(event)) +{ + if (drag->type == WM_DRAG_PATH) { + SpaceFile *sfile = CTX_wm_space_file(C); + if (sfile) { + return 1; + } + } + return 0; +} + +static void filepath_drop_copy(wmDrag *drag, wmDropBox *drop) +{ + RNA_string_set(drop->ptr, "filepath", drag->path); +} + +/* region dropbox definition */ +static void file_dropboxes(void) +{ + ListBase *lb = WM_dropboxmap_find("Window", SPACE_EMPTY, RGN_TYPE_WINDOW); + + WM_dropbox_add(lb, "FILE_OT_filepath_drop", filepath_drop_poll, filepath_drop_copy); +} + /* only called once, from space/spacetypes.c */ void ED_spacetype_file(void) { @@ -679,7 +704,8 @@ void ED_spacetype_file(void) st->listener = file_listener; st->operatortypes = file_operatortypes; st->keymap = file_keymap; - + st->dropboxes = file_dropboxes; + /* regions: main window */ art = MEM_callocN(sizeof(ARegionType), "spacetype file region"); art->regionid = RGN_TYPE_WINDOW; |