From dc2cd2d0dcfdc2e10ccd1f06039390b6293e46ef Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 10 Oct 2019 10:25:46 +1100 Subject: Cleanup: clang-format, spelling --- source/blender/editors/space_file/filesel.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source/blender/editors/space_file') diff --git a/source/blender/editors/space_file/filesel.c b/source/blender/editors/space_file/filesel.c index e2c9bb8d6e5..0b6d5661577 100644 --- a/source/blender/editors/space_file/filesel.c +++ b/source/blender/editors/space_file/filesel.c @@ -362,10 +362,10 @@ void ED_fileselect_set_params_from_userdef(SpaceFile *sfile) /** * Update the user-preference data for the file space. In fact, this also contains some - * non-FileSelectParams data, but it's neglectable. + * non-FileSelectParams data, but we can safely ignore this. * - * \param temp_win_size: If the browser was opened in a temporary window, pass its size here so we - * can store that in the preferences. Otherwise NULL. + * \param temp_win_size: If the browser was opened in a temporary window, + * pass its size here so we can store that in the preferences. Otherwise NULL. */ void ED_fileselect_params_to_userdef(SpaceFile *sfile, int temp_win_size[2]) { -- cgit v1.2.3 From 8825250f5a85c0c16e74ed144dd2b4a7d752042f Mon Sep 17 00:00:00 2001 From: Robert Guetzkow Date: Thu, 10 Oct 2019 10:53:13 +0200 Subject: File Browser: add back Delete, which now moves files to the trash In Blender 2.7 delete would permanently delete files, now this function is back but using more standard behavior. This patch includes code contributed by Kris (Metricity). Differential Revision: https://developer.blender.org/D4585 --- source/blender/editors/space_file/file_ops.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'source/blender/editors/space_file') diff --git a/source/blender/editors/space_file/file_ops.c b/source/blender/editors/space_file/file_ops.c index b4b51de302d..5ea95383892 100644 --- a/source/blender/editors/space_file/file_ops.c +++ b/source/blender/editors/space_file/file_ops.c @@ -2504,23 +2504,29 @@ int file_delete_exec(bContext *C, wmOperator *op) int numfiles = filelist_files_ensure(sfile->files); int i; + const char *error_message = NULL; bool report_error = false; errno = 0; for (i = 0; i < numfiles; i++) { if (filelist_entry_select_index_get(sfile->files, i, CHECK_FILES)) { file = filelist_file(sfile->files, i); BLI_make_file_string(BKE_main_blendfile_path(bmain), str, sfile->params->dir, file->relpath); - if (BLI_delete(str, false, false) != 0 || BLI_exists(str)) { + if (BLI_delete_soft(str, &error_message) != 0 || BLI_exists(str)) { report_error = true; } } } if (report_error) { - BKE_reportf(op->reports, - RPT_ERROR, - "Could not delete file: %s", - errno ? strerror(errno) : "unknown error"); + if (error_message != NULL) { + BKE_reportf(op->reports, RPT_ERROR, "Could not delete file or directory: %s", error_message); + } + else { + BKE_reportf(op->reports, + RPT_ERROR, + "Could not delete file or directory: %s", + errno ? strerror(errno) : "unknown error"); + } } ED_fileselect_clear(wm, sa, sfile); @@ -2533,7 +2539,7 @@ void FILE_OT_delete(struct wmOperatorType *ot) { /* identifiers */ ot->name = "Delete Selected Files"; - ot->description = "Delete selected files"; + ot->description = "Move selected files to the trash or recycle bin"; ot->idname = "FILE_OT_delete"; /* api callbacks */ -- cgit v1.2.3 From 5edfde58fe60ff59b4a689d3a9cfd7ecf83a2f98 Mon Sep 17 00:00:00 2001 From: Julian Eisel Date: Mon, 14 Oct 2019 16:21:17 +0200 Subject: File Browser: Add F2 shortcut to rename files Previously, we used Ctrl+Click for renaming, but since that shortcut is now consistently used to add items to the selection, we can't use that. In other cases we switched to F2 now, so it makes sense for the File Browser too. Further, AFAIK renaming was only possible through the context menu, which makes it hard to discover in the right click select keymap (have to press W). Note that I had to do some internal changes to ensure the context menu always acts on the clicked/hovered item, while the shortcut operates on the active item. William and I agreed that this is likely the behavior expected by most users. --- source/blender/editors/space_file/file_ops.c | 64 ++++++++++++---------------- 1 file changed, 27 insertions(+), 37 deletions(-) (limited to 'source/blender/editors/space_file') diff --git a/source/blender/editors/space_file/file_ops.c b/source/blender/editors/space_file/file_ops.c index 5ea95383892..44f562393d5 100644 --- a/source/blender/editors/space_file/file_ops.c +++ b/source/blender/editors/space_file/file_ops.c @@ -2395,60 +2395,49 @@ void FILE_OT_filenum(struct wmOperatorType *ot) RNA_def_int(ot->srna, "increment", 1, -100, 100, "Increment", "", -100, 100); } -static int file_rename_exec(bContext *C, wmOperator *UNUSED(op)) +static void file_rename_state_activate(SpaceFile *sfile, int file_idx, bool require_selected) { - ScrArea *sa = CTX_wm_area(C); - SpaceFile *sfile = (SpaceFile *)CTX_wm_space_data(C); + const int numfiles = filelist_files_ensure(sfile->files); - if (sfile->params) { - int idx = sfile->params->highlight_file; - int numfiles = filelist_files_ensure(sfile->files); - if ((0 <= idx) && (idx < numfiles)) { - FileDirEntry *file = filelist_file(sfile->files, idx); + if ((file_idx > 0) && (file_idx < numfiles)) { + FileDirEntry *file = filelist_file(sfile->files, file_idx); + + if ((require_selected == false) || + (filelist_entry_select_get(sfile->files, file, CHECK_ALL) & FILE_SEL_SELECTED)) { filelist_entry_select_index_set( - sfile->files, idx, FILE_SEL_ADD, FILE_SEL_EDITING, CHECK_ALL); + sfile->files, file_idx, FILE_SEL_ADD, FILE_SEL_EDITING, CHECK_ALL); BLI_strncpy(sfile->params->renamefile, file->relpath, FILE_MAXFILE); /* We can skip the pending state, * as we can directly set FILE_SEL_EDITING on the expected entry here. */ sfile->params->rename_flag = FILE_PARAMS_RENAME_ACTIVE; } + } +} + +static int file_rename_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent *UNUSED(event)) +{ + ScrArea *sa = CTX_wm_area(C); + SpaceFile *sfile = (SpaceFile *)CTX_wm_space_data(C); + + if (sfile->params) { + file_rename_state_activate(sfile, sfile->params->active_file, true); ED_area_tag_redraw(sa); } return OPERATOR_FINISHED; } -static bool file_rename_poll(bContext *C) +static int file_rename_exec(bContext *C, wmOperator *UNUSED(op)) { - bool poll = ED_operator_file_active(C); - SpaceFile *sfile = CTX_wm_space_file(C); - - if (sfile && sfile->params) { - int idx = sfile->params->highlight_file; - int numfiles = filelist_files_ensure(sfile->files); - - if ((0 <= idx) && (idx < numfiles)) { - FileDirEntry *file = filelist_file(sfile->files, idx); - if (FILENAME_IS_CURRPAR(file->relpath)) { - poll = false; - } - } + ScrArea *sa = CTX_wm_area(C); + SpaceFile *sfile = (SpaceFile *)CTX_wm_space_data(C); - if (sfile->params->highlight_file < 0) { - poll = false; - } - else { - char dir[FILE_MAX_LIBEXTRA]; - if (filelist_islibrary(sfile->files, dir, NULL)) { - poll = false; - } - } - } - else { - poll = false; + if (sfile->params) { + file_rename_state_activate(sfile, sfile->params->highlight_file, false); + ED_area_tag_redraw(sa); } - return poll; + return OPERATOR_FINISHED; } void FILE_OT_rename(struct wmOperatorType *ot) @@ -2459,8 +2448,9 @@ void FILE_OT_rename(struct wmOperatorType *ot) ot->idname = "FILE_OT_rename"; /* api callbacks */ + ot->invoke = file_rename_invoke; ot->exec = file_rename_exec; - ot->poll = file_rename_poll; + ot->poll = ED_operator_file_active; } static bool file_delete_poll(bContext *C) -- cgit v1.2.3 From 9a85592ddea2bf8891eb3eef8e0e69b356c73598 Mon Sep 17 00:00:00 2001 From: Julian Eisel Date: Mon, 14 Oct 2019 21:05:38 +0200 Subject: Fix: First item in File Browser can't be renamed Stupid mistake in 5edfde58fe60. --- source/blender/editors/space_file/file_ops.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/editors/space_file') diff --git a/source/blender/editors/space_file/file_ops.c b/source/blender/editors/space_file/file_ops.c index 44f562393d5..3cdcc07f081 100644 --- a/source/blender/editors/space_file/file_ops.c +++ b/source/blender/editors/space_file/file_ops.c @@ -2399,7 +2399,7 @@ static void file_rename_state_activate(SpaceFile *sfile, int file_idx, bool requ { const int numfiles = filelist_files_ensure(sfile->files); - if ((file_idx > 0) && (file_idx < numfiles)) { + if ((file_idx >= 0) && (file_idx < numfiles)) { FileDirEntry *file = filelist_file(sfile->files, file_idx); if ((require_selected == false) || -- cgit v1.2.3 From 9100982e8097a14ba96f90cf40d5591e1447dd2f Mon Sep 17 00:00:00 2001 From: Dalai Felinto Date: Wed, 9 Oct 2019 16:39:00 -0300 Subject: Fix Filebrowser Blender ID filter When the filtering option was disable we should see all the datablock types. Differential Revision: https://developer.blender.org/D6033 --- source/blender/editors/space_file/filelist.c | 2 +- source/blender/editors/space_file/filesel.c | 8 +------- 2 files changed, 2 insertions(+), 8 deletions(-) (limited to 'source/blender/editors/space_file') diff --git a/source/blender/editors/space_file/filelist.c b/source/blender/editors/space_file/filelist.c index 27cccf6bab1..d29233618de 100644 --- a/source/blender/editors/space_file/filelist.c +++ b/source/blender/editors/space_file/filelist.c @@ -831,7 +831,7 @@ void filelist_setfilter_options(FileList *filelist, } if ((filelist->filter_data.filter != filter) || (filelist->filter_data.filter_id != filter_id)) { filelist->filter_data.filter = filter; - filelist->filter_data.filter_id = filter_id; + filelist->filter_data.filter_id = (filter & FILE_TYPE_BLENDERLIB) ? filter_id : FILTER_ID_ALL; update = true; } if (!STREQ(filelist->filter_data.filter_glob, filter_glob)) { diff --git a/source/blender/editors/space_file/filesel.c b/source/blender/editors/space_file/filesel.c index 0b6d5661577..ba4ccb4fba9 100644 --- a/source/blender/editors/space_file/filesel.c +++ b/source/blender/editors/space_file/filesel.c @@ -247,13 +247,7 @@ short ED_fileselect_set_params(SpaceFile *sfile) } /* For now, always init filterid to 'all true' */ - params->filter_id = FILTER_ID_AC | FILTER_ID_AR | FILTER_ID_BR | FILTER_ID_CA | FILTER_ID_CU | - FILTER_ID_GD | FILTER_ID_GR | FILTER_ID_IM | FILTER_ID_LA | FILTER_ID_LS | - FILTER_ID_LT | FILTER_ID_MA | FILTER_ID_MB | FILTER_ID_MC | FILTER_ID_ME | - FILTER_ID_MSK | FILTER_ID_NT | FILTER_ID_OB | FILTER_ID_PA | - FILTER_ID_PAL | FILTER_ID_PC | FILTER_ID_SCE | FILTER_ID_SPK | - FILTER_ID_SO | FILTER_ID_TE | FILTER_ID_TXT | FILTER_ID_VF | FILTER_ID_WO | - FILTER_ID_CF | FILTER_ID_WS | FILTER_ID_LP; + params->filter_id = FILTER_ID_ALL; if (U.uiflag & USER_HIDE_DOT) { params->flag |= FILE_HIDE_DOT; -- cgit v1.2.3