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:
authorJulian Eisel <julian@blender.org>2021-07-05 14:30:47 +0300
committerJulian Eisel <julian@blender.org>2021-07-05 14:35:41 +0300
commit2eca9c7ed4e9819564a7be474e281e6f3b296107 (patch)
treeac44118a04563893aca51d8b84c150f80721c86d /source/blender/editors/space_file/file_ops.c
parent2c6c1b6cc046558519bb8dcfb8ee60401862d7e0 (diff)
Cleanup: Move common File Browser renaming code into functions
Code would manually do the same things in a couple of places, obvious case of unnecessary code duplication.
Diffstat (limited to 'source/blender/editors/space_file/file_ops.c')
-rw-r--r--source/blender/editors/space_file/file_ops.c27
1 files changed, 12 insertions, 15 deletions
diff --git a/source/blender/editors/space_file/file_ops.c b/source/blender/editors/space_file/file_ops.c
index 60e79a6f563..49c3a29b67b 100644
--- a/source/blender/editors/space_file/file_ops.c
+++ b/source/blender/editors/space_file/file_ops.c
@@ -2059,13 +2059,15 @@ static int file_smoothscroll_invoke(bContext *C, wmOperator *UNUSED(op), const w
}
}
+ wmWindowManager *wm = CTX_wm_manager(C);
+ wmWindow *win = CTX_wm_window(C);
+
/* if we are not editing, we are done */
if (edit_idx == -1) {
/* Do not invalidate timer if filerename is still pending,
* we might still be building the filelist and yet have to find edited entry. */
if (params->rename_flag == 0) {
- WM_event_remove_timer(CTX_wm_manager(C), CTX_wm_window(C), sfile->smoothscroll_timer);
- sfile->smoothscroll_timer = NULL;
+ file_params_smoothscroll_timer_clear(wm, win, sfile);
}
return OPERATOR_PASS_THROUGH;
}
@@ -2073,8 +2075,7 @@ static int file_smoothscroll_invoke(bContext *C, wmOperator *UNUSED(op), const w
/* we need the correct area for scrolling */
region = BKE_area_find_region_type(area, RGN_TYPE_WINDOW);
if (!region || region->regiontype != RGN_TYPE_WINDOW) {
- WM_event_remove_timer(CTX_wm_manager(C), CTX_wm_window(C), sfile->smoothscroll_timer);
- sfile->smoothscroll_timer = NULL;
+ file_params_smoothscroll_timer_clear(wm, win, sfile);
return OPERATOR_PASS_THROUGH;
}
@@ -2131,13 +2132,11 @@ static int file_smoothscroll_invoke(bContext *C, wmOperator *UNUSED(op), const w
(max_middle_offset - middle_offset < items_block_size));
if (is_ready && (is_centered || is_full_start || is_full_end)) {
- WM_event_remove_timer(CTX_wm_manager(C), CTX_wm_window(C), sfile->smoothscroll_timer);
- sfile->smoothscroll_timer = NULL;
+ file_params_smoothscroll_timer_clear(wm, win, sfile);
/* Post-scroll (after rename has been validated by user) is done,
* rename process is totally finished, cleanup. */
if ((params->rename_flag & FILE_PARAMS_RENAME_POSTSCROLL_ACTIVE) != 0) {
- params->renamefile[0] = '\0';
- params->rename_flag = 0;
+ file_params_renamefile_clear(params);
}
return OPERATOR_FINISHED;
}
@@ -2346,18 +2345,16 @@ static int file_directory_new_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
+ eFileSel_Params_RenameFlag rename_flag = params->rename_flag;
+
/* If we don't enter the directory directly, remember file to jump into editing. */
if (do_diropen == false) {
BLI_strncpy(params->renamefile, name, FILE_MAXFILE);
- params->rename_flag = FILE_PARAMS_RENAME_PENDING;
+ rename_flag = FILE_PARAMS_RENAME_PENDING;
}
- /* Set timer to smoothly view newly generated file. */
- if (sfile->smoothscroll_timer != NULL) {
- WM_event_remove_timer(wm, CTX_wm_window(C), sfile->smoothscroll_timer);
- }
- sfile->smoothscroll_timer = WM_event_add_timer(wm, CTX_wm_window(C), TIMER1, 1.0 / 1000.0);
- sfile->scroll_offset = 0;
+ file_params_invoke_rename_postscroll(wm, CTX_wm_window(C), sfile);
+ params->rename_flag = rename_flag;
/* reload dir to make sure we're seeing what's in the directory */
ED_fileselect_clear(wm, sfile);