diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-09-12 14:04:09 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-09-12 14:04:09 +0400 |
commit | f637a52272d74f5d074737c1560221ee3ccdb067 (patch) | |
tree | ee62a37607bad05da38271be570fb8de49066c35 /source/blender/editors/space_file | |
parent | 7b15620da05bca40c24f3fc35646a86e03ad8198 (diff) |
fix [#30324] VSE: Right-Click does not select directory
Diffstat (limited to 'source/blender/editors/space_file')
-rw-r--r-- | source/blender/editors/space_file/file_ops.c | 22 | ||||
-rw-r--r-- | source/blender/editors/space_file/space_file.c | 16 |
2 files changed, 28 insertions, 10 deletions
diff --git a/source/blender/editors/space_file/file_ops.c b/source/blender/editors/space_file/file_ops.c index 878858c1acd..040f276940d 100644 --- a/source/blender/editors/space_file/file_ops.c +++ b/source/blender/editors/space_file/file_ops.c @@ -156,7 +156,7 @@ static FileSelection file_selection_get(bContext *C, const rcti *rect, short fil return sel; } -static FileSelect file_select_do(bContext *C, int selected_idx) +static FileSelect file_select_do(bContext *C, int selected_idx, short do_diropen) { FileSelect retval = FILE_SELECT_NOTHING; SpaceFile *sfile = CTX_wm_space_file(C); @@ -172,8 +172,12 @@ static FileSelect file_select_do(bContext *C, int selected_idx) params->active_file = selected_idx; if (S_ISDIR(file->type)) { + if (do_diropen == FALSE) { + params->file[0] = '\0'; + retval = FILE_SELECT_DIR; + } /* the path is too long and we are not going up! */ - if (strcmp(file->relname, "..") && strlen(params->dir) + strlen(file->relname) >= FILE_MAX) { + else if (strcmp(file->relname, "..") && strlen(params->dir) + strlen(file->relname) >= FILE_MAX) { // XXX error("Path too long, cannot enter this directory"); } else { @@ -202,7 +206,7 @@ static FileSelect file_select_do(bContext *C, int selected_idx) } -static FileSelect file_select(bContext *C, const rcti *rect, FileSelType select, short fill) +static FileSelect file_select(bContext *C, const rcti *rect, FileSelType select, short fill, short do_diropen) { SpaceFile *sfile = CTX_wm_space_file(C); FileSelect retval = FILE_SELECT_NOTHING; @@ -219,7 +223,7 @@ static FileSelect file_select(bContext *C, const rcti *rect, FileSelType select, if ((sel.last >= 0) && ((select == FILE_SEL_ADD) || (select == FILE_SEL_TOGGLE))) { /* Check last selection, if selected, act on the file or dir */ if (filelist_is_selected(sfile->files, sel.last, check_type)) { - retval = file_select_do(C, sel.last); + retval = file_select_do(C, sel.last, do_diropen); } } @@ -284,7 +288,7 @@ static int file_border_select_exec(bContext *C, wmOperator *op) BLI_rcti_isect(&(ar->v2d.mask), &rect, &rect); - ret = file_select(C, &rect, select ? FILE_SEL_ADD : FILE_SEL_REMOVE, 0); + ret = file_select(C, &rect, select ? FILE_SEL_ADD : FILE_SEL_REMOVE, FALSE, FALSE); if (FILE_SELECT_DIR == ret) { WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_LIST, NULL); } @@ -320,6 +324,7 @@ static int file_select_invoke(bContext *C, wmOperator *op, wmEvent *event) rcti rect; int extend = RNA_boolean_get(op->ptr, "extend"); int fill = RNA_boolean_get(op->ptr, "fill"); + int do_diropen = RNA_boolean_get(op->ptr, "open"); if (ar->regiontype != RGN_TYPE_WINDOW) return OPERATOR_CANCELLED; @@ -333,7 +338,7 @@ static int file_select_invoke(bContext *C, wmOperator *op, wmEvent *event) /* single select, deselect all selected first */ if (!extend) file_deselect_all(sfile, SELECTED_FILE); - ret = file_select(C, &rect, extend ? FILE_SEL_TOGGLE : FILE_SEL_ADD, fill); + ret = file_select(C, &rect, extend ? FILE_SEL_TOGGLE : FILE_SEL_ADD, fill, do_diropen); if (FILE_SELECT_DIR == ret) WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_LIST, NULL); else if (FILE_SELECT_FILE == ret) @@ -357,8 +362,9 @@ void FILE_OT_select(wmOperatorType *ot) ot->poll = ED_operator_file_active; /* rna */ - RNA_def_boolean(ot->srna, "extend", 0, "Extend", "Extend selection instead of deselecting everything first"); - RNA_def_boolean(ot->srna, "fill", 0, "Fill", "Select everything beginning with the last selection"); + RNA_def_boolean(ot->srna, "extend", FALSE, "Extend", "Extend selection instead of deselecting everything first"); + RNA_def_boolean(ot->srna, "fill", FALSE, "Fill", "Select everything beginning with the last selection"); + RNA_def_boolean(ot->srna, "open", TRUE, "Open", "Open a directory when selecting it"); } static int file_select_all_exec(bContext *C, wmOperator *UNUSED(op)) diff --git a/source/blender/editors/space_file/space_file.c b/source/blender/editors/space_file/space_file.c index fcf6f28b406..4b568b43695 100644 --- a/source/blender/editors/space_file/space_file.c +++ b/source/blender/editors/space_file/space_file.c @@ -284,8 +284,6 @@ static void file_main_area_init(wmWindowManager *wm, ARegion *ar) keymap = WM_keymap_find(wm->defaultconf, "File Browser Main", SPACE_FILE, 0); WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); - - } static void file_main_area_listener(ARegion *ar, wmNotifier *wmn) @@ -418,12 +416,26 @@ static void file_keymap(struct wmKeyConfig *keyconf) keymap = WM_keymap_find(keyconf, "File Browser Main", SPACE_FILE, 0); kmi = WM_keymap_add_item(keymap, "FILE_OT_execute", LEFTMOUSE, KM_DBL_CLICK, 0, 0); RNA_boolean_set(kmi->ptr, "need_active", TRUE); + + /* left mouse selects and opens */ WM_keymap_add_item(keymap, "FILE_OT_select", LEFTMOUSE, KM_CLICK, 0, 0); kmi = WM_keymap_add_item(keymap, "FILE_OT_select", LEFTMOUSE, KM_CLICK, KM_SHIFT, 0); RNA_boolean_set(kmi->ptr, "extend", TRUE); kmi = WM_keymap_add_item(keymap, "FILE_OT_select", LEFTMOUSE, KM_CLICK, KM_ALT, 0); RNA_boolean_set(kmi->ptr, "extend", TRUE); RNA_boolean_set(kmi->ptr, "fill", TRUE); + + /* right mouse selects without opening */ + kmi = WM_keymap_add_item(keymap, "FILE_OT_select", RIGHTMOUSE, KM_CLICK, 0, 0); + RNA_boolean_set(kmi->ptr, "open", FALSE); + kmi = WM_keymap_add_item(keymap, "FILE_OT_select", RIGHTMOUSE, KM_CLICK, KM_SHIFT, 0); + RNA_boolean_set(kmi->ptr, "extend", TRUE); + RNA_boolean_set(kmi->ptr, "open", FALSE); + kmi = WM_keymap_add_item(keymap, "FILE_OT_select", RIGHTMOUSE, KM_CLICK, KM_ALT, 0); + RNA_boolean_set(kmi->ptr, "extend", TRUE); + RNA_boolean_set(kmi->ptr, "fill", TRUE); + RNA_boolean_set(kmi->ptr, "open", FALSE); + WM_keymap_add_item(keymap, "FILE_OT_select_all_toggle", AKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "FILE_OT_refresh", PADPERIOD, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "FILE_OT_select_border", BKEY, KM_PRESS, 0, 0); |