Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/space_file/filesel.c
| Show First 20 Lines • Show All 522 Lines • ▼ Show 20 Lines | for (int file_index = 0; file_index < num_files_filtered; ++file_index) { | ||||
| /* Keep looping to deselect the other files. */ | /* Keep looping to deselect the other files. */ | ||||
| } | } | ||||
| WM_main_add_notifier(NC_ASSET | NA_ACTIVATED, NULL); | WM_main_add_notifier(NC_ASSET | NA_ACTIVATED, NULL); | ||||
| WM_main_add_notifier(NC_ASSET | NA_SELECTED, NULL); | WM_main_add_notifier(NC_ASSET | NA_SELECTED, NULL); | ||||
| } | } | ||||
| static void on_reload_select_by_relpath(SpaceFile *sfile, onReloadFnData custom_data) | |||||
| { | |||||
| char *relative_path = (char *)custom_data; | |||||
| ED_fileselect_activate_by_relpath(sfile, relative_path); | |||||
| } | |||||
| void ED_fileselect_activate_by_relpath(SpaceFile *sfile, const char *relative_path) | |||||
| { | |||||
| /* If there are filelist operations running now ("pending" true) or soon ("force reset" true), | |||||
| * there is a fair chance that the to-be-activated file at relative_path will only be present | |||||
Severin: "... that the to-be-activated file at relative_path will only..." | |||||
| * after these operations have completed. Defer activation until then. */ | |||||
| struct FileList *files = sfile->files; | |||||
| if (files == NULL || filelist_pending(files) || filelist_needs_force_reset(files)) { | |||||
| file_on_reload_callback_register(sfile, on_reload_select_by_relpath, relative_path); | |||||
| return; | |||||
| } | |||||
Done Inline ActionsA function called select_file() should not deselect other files. At least not without being very explicit about it. Severin: A function called `select_file()` should not deselect other files. At least not without being… | |||||
| FileSelectParams *params = ED_fileselect_get_active_params(sfile); | |||||
| const int num_files_filtered = filelist_files_ensure(files); | |||||
| for (int file_index = 0; file_index < num_files_filtered; ++file_index) { | |||||
Done Inline ActionsUse WM_main_add_notifier(NC_SPACE | ND_SPACE_FILE_PARAMS, NULL); here, since this is not asset related. Severin: Use `WM_main_add_notifier(NC_SPACE | ND_SPACE_FILE_PARAMS, NULL);` here, since this is not… | |||||
| const FileDirEntry *file = filelist_file(files, file_index); | |||||
Done Inline ActionsWe avoid these empty lines after ifs :) Severin: We avoid these empty lines after `if`s :) | |||||
| if (STREQ(file->relpath, relative_path)) { | |||||
| params->active_file = file_index; | |||||
| filelist_entry_select_set(files, file, FILE_SEL_ADD, FILE_SEL_SELECTED, CHECK_ALL); | |||||
| } | |||||
| } | |||||
| WM_main_add_notifier(NC_SPACE | ND_SPACE_FILE_PARAMS, NULL); | |||||
| } | |||||
| void ED_fileselect_deselect_all(SpaceFile *sfile) | |||||
| { | |||||
| file_select_deselect_all(sfile, FILE_SEL_SELECTED); | |||||
| WM_main_add_notifier(NC_SPACE | ND_SPACE_FILE_PARAMS, NULL); | |||||
| } | |||||
| /* The subset of FileSelectParams.flag items we store into preferences. Note that FILE_SORT_ALPHA | /* The subset of FileSelectParams.flag items we store into preferences. Note that FILE_SORT_ALPHA | ||||
| * may also be remembered, but only conditionally. */ | * may also be remembered, but only conditionally. */ | ||||
| #define PARAMS_FLAGS_REMEMBERED (FILE_HIDE_DOT) | #define PARAMS_FLAGS_REMEMBERED (FILE_HIDE_DOT) | ||||
| void ED_fileselect_window_params_get(const wmWindow *win, int win_size[2], bool *is_maximized) | void ED_fileselect_window_params_get(const wmWindow *win, int win_size[2], bool *is_maximized) | ||||
| { | { | ||||
| /* Get DPI/pixel-size independent size to be stored in preferences. */ | /* Get DPI/pixel-size independent size to be stored in preferences. */ | ||||
| WM_window_set_dpi(win); /* Ensure the DPI is taken from the right window. */ | WM_window_set_dpi(win); /* Ensure the DPI is taken from the right window. */ | ||||
| ▲ Show 20 Lines • Show All 819 Lines • Show Last 20 Lines | |||||
"... that the to-be-activated file at relative_path will only..."