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:
authorBastien Montagne <montagne29@wanadoo.fr>2019-03-05 23:01:45 +0300
committerBastien Montagne <montagne29@wanadoo.fr>2019-03-05 23:05:02 +0300
commit4326f8af08c845eeb4eb45800ca047f690044007 (patch)
treecb5ab49dc6f3e33a5f12167dc94cf862cdf29c67 /source/blender/editors/space_file/filesel.c
parent8858311463b7220eef383781d31dde31868fcd7c (diff)
File Editor: Refactor 'new dir' / renaming code.
We really do not need two 256 chars variables to hanlde renaming, a mere pair of flags can handle the situation just as well. Also, scroll to newly renamed item, will help when one want to find again the directory they just added and rename. At some point we'll probably want to refactor scrolling further (to make it fully out of rename code/context e.g.), but for now think this will do.
Diffstat (limited to 'source/blender/editors/space_file/filesel.c')
-rw-r--r--source/blender/editors/space_file/filesel.c24
1 files changed, 19 insertions, 5 deletions
diff --git a/source/blender/editors/space_file/filesel.c b/source/blender/editors/space_file/filesel.c
index 7b642e75eac..5195fa818d6 100644
--- a/source/blender/editors/space_file/filesel.c
+++ b/source/blender/editors/space_file/filesel.c
@@ -738,19 +738,33 @@ void ED_fileselect_exit(wmWindowManager *wm, ScrArea *sa, SpaceFile *sfile)
* params->renamefile name. */
void file_params_renamefile_activate(SpaceFile *sfile, FileSelectParams *params)
{
+ BLI_assert(params->rename_flag != 0);
+
+ if ((params->rename_flag & (FILE_PARAMS_RENAME_ACTIVE | FILE_PARAMS_RENAME_POSTSCROLL_ACTIVE)) != 0) {
+ return;
+ }
+
BLI_assert(params->renamefile[0] != '\0');
const int idx = filelist_file_findpath(sfile->files, params->renamefile);
if (idx >= 0) {
FileDirEntry *file = filelist_file(sfile->files, idx);
- if (file) {
+ BLI_assert(file != NULL);
+
+ if ((params->rename_flag & FILE_PARAMS_RENAME_PENDING) != 0) {
filelist_entry_select_set(sfile->files, file, FILE_SEL_ADD, FILE_SEL_EDITING, CHECK_ALL);
+ params->rename_flag = FILE_PARAMS_RENAME_ACTIVE;
+ }
+ else if ((params->rename_flag & FILE_PARAMS_RENAME_POSTSCROLL_PENDING) != 0) {
+ filelist_entry_select_set(sfile->files, file, FILE_SEL_ADD, FILE_SEL_HIGHLIGHTED, CHECK_ALL);
+ params->renamefile[0] = '\0';
+ params->rename_flag = FILE_PARAMS_RENAME_POSTSCROLL_ACTIVE;
}
}
- BLI_strncpy(sfile->params->renameedit, sfile->params->renamefile, sizeof(sfile->params->renameedit));
- /* File listing is now async, do not clear renamefile if matching entry not found
- * and dirlist is not finished! */
- if (idx >= 0 || filelist_is_ready(sfile->files)) {
+ /* File listing is now async, only reset renaming if matching entry is not found
+ * when file listing is not done. */
+ else if (filelist_is_ready(sfile->files)) {
params->renamefile[0] = '\0';
+ params->rename_flag = 0;
}
}