Fix T42879: File Browser - disable selecting ".." entry (Parent Directory)
This commit is contained in:
parent
703bb0f62d
commit
76b4fad6db
Notes:
blender-bot
2023-06-26 11:58:59 +02:00
Referenced by issue #42879, AFTER 2.73 - The ability to select the go back icon
|
@ -518,6 +518,11 @@ void file_draw_list(const bContext *C, ARegion *ar)
|
|||
if ((params->active_file == i) || (file->selflag & HILITED_FILE) || (file->selflag & SELECTED_FILE)) {
|
||||
int colorid = (file->selflag & SELECTED_FILE) ? TH_HILITE : TH_BACK;
|
||||
int shade = (params->active_file == i) || (file->selflag & HILITED_FILE) ? 20 : 0;
|
||||
|
||||
/* readonly files (".." and ".") must not be drawn as selected - set color back to normal */
|
||||
if (STREQ(file->relname, "..") || STREQ(file->relname, ".")) {
|
||||
colorid = TH_BACK;
|
||||
}
|
||||
draw_tile(sx, sy - 1, layout->tile_w + 4, sfile->layout->tile_h + layout->tile_border_y, colorid, shade);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -341,8 +341,20 @@ static int file_select_invoke(bContext *C, wmOperator *op, const wmEvent *event)
|
|||
if (!BLI_rcti_isect_pt(&ar->v2d.mask, rect.xmin, rect.ymin))
|
||||
return OPERATOR_CANCELLED;
|
||||
|
||||
/* single select, deselect all selected first */
|
||||
if (!extend) file_deselect_all(sfile, SELECTED_FILE);
|
||||
if (sfile && sfile->params) {
|
||||
int idx = sfile->params->active_file;
|
||||
|
||||
if (idx >= 0) {
|
||||
struct direntry *file = filelist_file(sfile->files, idx);
|
||||
if (STREQ(file->relname, "..") || STREQ(file->relname, ".")) {
|
||||
/* skip - If a readonly file (".." or ".") is selected, skip deselect all! */
|
||||
}
|
||||
else {
|
||||
/* 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, do_diropen);
|
||||
if (FILE_SELECT_DIR == ret)
|
||||
|
|
Loading…
Reference in New Issue