Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/space_file/file_ops.c
| Show First 20 Lines • Show All 93 Lines • ▼ Show 20 Lines | static FileSelection find_file_mouse_rect(SpaceFile *sfile, ARegion *ar, const rcti *rect_region) | ||||
| return sel; | return sel; | ||||
| } | } | ||||
| static void file_deselect_all(SpaceFile *sfile, unsigned int flag) | static void file_deselect_all(SpaceFile *sfile, unsigned int flag) | ||||
| { | { | ||||
| FileSelection sel; | FileSelection sel; | ||||
| sel.first = 0; | sel.first = 0; | ||||
| sel.last = filelist_numfiles(sfile->files) - 1; | sel.last = filelist_files_ensure(sfile->files) - 1; | ||||
| filelist_select(sfile->files, &sel, FILE_SEL_REMOVE, flag, CHECK_ALL); | filelist_entries_select_index_range_set(sfile->files, &sel, FILE_SEL_REMOVE, flag, CHECK_ALL); | ||||
| } | } | ||||
| typedef enum FileSelect { | typedef enum FileSelect { | ||||
| FILE_SELECT_NOTHING = 0, | FILE_SELECT_NOTHING = 0, | ||||
| FILE_SELECT_DIR = 1, | FILE_SELECT_DIR = 1, | ||||
| FILE_SELECT_FILE = 2 | FILE_SELECT_FILE = 2 | ||||
| } FileSelect; | } FileSelect; | ||||
| Show All 21 Lines | if ( (sel->last >= numfiles) ) { | ||||
| sel->last = numfiles - 1; | sel->last = numfiles - 1; | ||||
| } | } | ||||
| } | } | ||||
| static FileSelection file_selection_get(bContext *C, const rcti *rect, bool fill) | static FileSelection file_selection_get(bContext *C, const rcti *rect, bool fill) | ||||
| { | { | ||||
| ARegion *ar = CTX_wm_region(C); | ARegion *ar = CTX_wm_region(C); | ||||
| SpaceFile *sfile = CTX_wm_space_file(C); | SpaceFile *sfile = CTX_wm_space_file(C); | ||||
| int numfiles = filelist_numfiles(sfile->files); | int numfiles = filelist_files_ensure(sfile->files); | ||||
| FileSelection sel; | FileSelection sel; | ||||
| sel = find_file_mouse_rect(sfile, ar, rect); | sel = find_file_mouse_rect(sfile, ar, rect); | ||||
| if (!((sel.first == -1) && (sel.last == -1)) ) { | if (!((sel.first == -1) && (sel.last == -1)) ) { | ||||
| clamp_to_filelist(numfiles, &sel); | clamp_to_filelist(numfiles, &sel); | ||||
| } | } | ||||
| /* if desired, fill the selection up from the last selected file to the current one */ | /* if desired, fill the selection up from the last selected file to the current one */ | ||||
| if (fill && (sel.last >= 0) && (sel.last < numfiles) ) { | if (fill && (sel.last >= 0) && (sel.last < numfiles) ) { | ||||
| int f = sel.last; | int f = sel.last; | ||||
| while (f >= 0) { | while (f >= 0) { | ||||
| if (filelist_is_selected(sfile->files, f, CHECK_ALL) ) | if (filelist_entry_select_index_get(sfile->files, f, CHECK_ALL) ) | ||||
| break; | break; | ||||
| f--; | f--; | ||||
| } | } | ||||
| if (f >= 0) { | if (f >= 0) { | ||||
| sel.first = f + 1; | sel.first = f + 1; | ||||
| } | } | ||||
| } | } | ||||
| return sel; | return sel; | ||||
| } | } | ||||
| static FileSelect file_select_do(bContext *C, int selected_idx, bool do_diropen) | static FileSelect file_select_do(bContext *C, int selected_idx, bool do_diropen) | ||||
| { | { | ||||
| FileSelect retval = FILE_SELECT_NOTHING; | FileSelect retval = FILE_SELECT_NOTHING; | ||||
| SpaceFile *sfile = CTX_wm_space_file(C); | SpaceFile *sfile = CTX_wm_space_file(C); | ||||
| FileSelectParams *params = ED_fileselect_get_params(sfile); | FileSelectParams *params = ED_fileselect_get_params(sfile); | ||||
| int numfiles = filelist_numfiles(sfile->files); | int numfiles = filelist_files_ensure(sfile->files); | ||||
| struct direntry *file; | const FileDirEntry *file; | ||||
campbellbarton: Could be `const`? | |||||
| /* make the selected file active */ | /* make the selected file active */ | ||||
| if ((selected_idx >= 0) && | if ((selected_idx >= 0) && | ||||
| (selected_idx < numfiles) && | (selected_idx < numfiles) && | ||||
| (file = filelist_file(sfile->files, selected_idx))) | (file = filelist_file(sfile->files, selected_idx))) | ||||
| { | { | ||||
| params->highlight_file = selected_idx; | params->highlight_file = selected_idx; | ||||
| sfile->params->active_file = selected_idx; | params->active_file = selected_idx; | ||||
| if (S_ISDIR(file->type)) { | if (file->typeflag & FILE_TYPE_DIR) { | ||||
| const bool is_parent_dir = FILENAME_IS_PARENT(file->relname); | const bool is_parent_dir = FILENAME_IS_PARENT(file->relpath); | ||||
| if (do_diropen == false) { | if (do_diropen == false) { | ||||
| params->file[0] = '\0'; | params->file[0] = '\0'; | ||||
| retval = FILE_SELECT_DIR; | retval = FILE_SELECT_DIR; | ||||
| } | } | ||||
| /* the path is too long and we are not going up! */ | /* the path is too long and we are not going up! */ | ||||
| else if (!is_parent_dir && strlen(params->dir) + strlen(file->relname) >= FILE_MAX) { | else if (!is_parent_dir && strlen(params->dir) + strlen(file->relpath) >= FILE_MAX) { | ||||
| // XXX error("Path too long, cannot enter this directory"); | // XXX error("Path too long, cannot enter this directory"); | ||||
| } | } | ||||
| else { | else { | ||||
| if (is_parent_dir) { | if (is_parent_dir) { | ||||
| /* avoids /../../ */ | /* avoids /../../ */ | ||||
| BLI_parent_dir(params->dir); | BLI_parent_dir(params->dir); | ||||
| if (params->recursion_level > 1) { | |||||
| /* Disable 'dirtree' recursion when going up in tree. */ | |||||
| params->recursion_level = 0; | |||||
| filelist_setrecursion(sfile->files, params->recursion_level); | |||||
| } | |||||
| } | } | ||||
| else { | else { | ||||
| BLI_cleanup_dir(G.main->name, params->dir); | BLI_cleanup_dir(G.main->name, params->dir); | ||||
| strcat(params->dir, file->relname); | strcat(params->dir, file->relpath); | ||||
| BLI_add_slash(params->dir); | BLI_add_slash(params->dir); | ||||
| } | } | ||||
| ED_file_change_dir(C, false); | ED_file_change_dir(C, false); | ||||
| retval = FILE_SELECT_DIR; | retval = FILE_SELECT_DIR; | ||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| if (file->relname) { | if (file->relpath) { | ||||
| BLI_strncpy(params->file, file->relname, FILE_MAXFILE); | BLI_strncpy(params->file, file->relpath, FILE_MAXFILE); | ||||
| } | } | ||||
| retval = FILE_SELECT_FILE; | retval = FILE_SELECT_FILE; | ||||
| } | } | ||||
| } | } | ||||
| return retval; | return retval; | ||||
| } | } | ||||
| /** | /** | ||||
| * \warning: loops over all files so better use cautiously | * \warning: loops over all files so better use cautiously | ||||
| */ | */ | ||||
| static bool file_is_any_selected(struct FileList *files) | static bool file_is_any_selected(struct FileList *files) | ||||
| { | { | ||||
| const int numfiles = filelist_numfiles(files); | const int numfiles = filelist_files_ensure(files); | ||||
| int i; | int i; | ||||
| /* Is any file selected ? */ | |||||
| for (i = 0; i < numfiles; ++i) { | for (i = 0; i < numfiles; ++i) { | ||||
| if (filelist_is_selected(files, i, CHECK_ALL)) { | if (filelist_entry_select_index_get(files, i, CHECK_ALL)) { | ||||
| return true; | return true; | ||||
| } | } | ||||
| } | } | ||||
| return false; | return false; | ||||
| } | } | ||||
| static FileSelect file_select(bContext *C, const rcti *rect, FileSelType select, bool fill, bool do_diropen) | static FileSelect file_select(bContext *C, const rcti *rect, FileSelType select, bool fill, bool do_diropen) | ||||
| { | { | ||||
| SpaceFile *sfile = CTX_wm_space_file(C); | SpaceFile *sfile = CTX_wm_space_file(C); | ||||
| FileSelect retval = FILE_SELECT_NOTHING; | FileSelect retval = FILE_SELECT_NOTHING; | ||||
| FileSelection sel = file_selection_get(C, rect, fill); /* get the selection */ | FileSelection sel = file_selection_get(C, rect, fill); /* get the selection */ | ||||
| const FileCheckType check_type = (sfile->params->flag & FILE_DIRSEL_ONLY) ? CHECK_DIRS : CHECK_ALL; | const FileCheckType check_type = (sfile->params->flag & FILE_DIRSEL_ONLY) ? CHECK_DIRS : CHECK_ALL; | ||||
| /* flag the files as selected in the filelist */ | /* flag the files as selected in the filelist */ | ||||
| filelist_select(sfile->files, &sel, select, FILE_SEL_SELECTED, check_type); | filelist_entries_select_index_range_set(sfile->files, &sel, select, FILE_SEL_SELECTED, check_type); | ||||
| /* Don't act on multiple selected files */ | /* Don't act on multiple selected files */ | ||||
| if (sel.first != sel.last) select = 0; | if (sel.first != sel.last) select = 0; | ||||
| /* Do we have a valid selection and are we actually selecting */ | /* Do we have a valid selection and are we actually selecting */ | ||||
| if ((sel.last >= 0) && (select != FILE_SEL_REMOVE)) { | if ((sel.last >= 0) && (select != FILE_SEL_REMOVE)) { | ||||
| /* Check last selection, if selected, act on the file or dir */ | /* Check last selection, if selected, act on the file or dir */ | ||||
| if (filelist_is_selected(sfile->files, sel.last, check_type)) { | if (filelist_entry_select_index_get(sfile->files, sel.last, check_type)) { | ||||
| retval = file_select_do(C, sel.last, do_diropen); | retval = file_select_do(C, sel.last, do_diropen); | ||||
| } | } | ||||
| } | } | ||||
| if (select != FILE_SEL_ADD && !file_is_any_selected(sfile->files)) { | if (select != FILE_SEL_ADD && !file_is_any_selected(sfile->files)) { | ||||
| sfile->params->active_file = -1; | sfile->params->active_file = -1; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 41 Lines • ▼ Show 20 Lines | static int file_border_select_modal(bContext *C, wmOperator *op, const wmEvent *event) | ||||
| FileSelection sel; | FileSelection sel; | ||||
| rcti rect; | rcti rect; | ||||
| int result; | int result; | ||||
| result = WM_border_select_modal(C, op, event); | result = WM_border_select_modal(C, op, event); | ||||
| if (result == OPERATOR_RUNNING_MODAL) { | if (result == OPERATOR_RUNNING_MODAL) { | ||||
| WM_operator_properties_border_to_rcti(op, &rect); | WM_operator_properties_border_to_rcti(op, &rect); | ||||
| BLI_rcti_isect(&(ar->v2d.mask), &rect, &rect); | BLI_rcti_isect(&(ar->v2d.mask), &rect, &rect); | ||||
| sel = file_selection_get(C, &rect, 0); | sel = file_selection_get(C, &rect, 0); | ||||
| if ( (sel.first != params->sel_first) || (sel.last != params->sel_last) ) { | if ((sel.first != params->sel_first) || (sel.last != params->sel_last)) { | ||||
| int idx; | int idx; | ||||
| file_deselect_all(sfile, FILE_SEL_HIGHLIGHTED); | file_deselect_all(sfile, FILE_SEL_HIGHLIGHTED); | ||||
| filelist_select(sfile->files, &sel, FILE_SEL_ADD, FILE_SEL_HIGHLIGHTED, CHECK_ALL); | filelist_entries_select_index_range_set(sfile->files, &sel, FILE_SEL_ADD, FILE_SEL_HIGHLIGHTED, CHECK_ALL); | ||||
| WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_PARAMS, NULL); | WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_PARAMS, NULL); | ||||
| /* dont highlight readonly file (".." or ".") on border select */ | /* dont highlight readonly file (".." or ".") on border select */ | ||||
| for (idx = sel.last; idx >= 0; idx--) { | for (idx = sel.last; idx >= 0; idx--) { | ||||
| struct direntry *file = filelist_file(sfile->files, idx); | const FileDirEntry *file = filelist_file(sfile->files, idx); | ||||
| if (FILENAME_IS_CURRPAR(file->relname)) { | if (FILENAME_IS_CURRPAR(file->relpath)) { | ||||
Done Inline ActionsCould be const? campbellbarton: Could be `const`? | |||||
| file->selflag &= ~FILE_SEL_HIGHLIGHTED; | filelist_entry_select_set(sfile->files, file, FILE_SEL_REMOVE, FILE_SEL_HIGHLIGHTED, CHECK_ALL); | ||||
| } | } | ||||
| /* make sure highlight_file is no readonly file */ | /* make sure highlight_file is no readonly file */ | ||||
| if (sel.last == idx) { | if (sel.last == idx) { | ||||
| params->highlight_file = idx; | params->highlight_file = idx; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 72 Lines • ▼ Show 20 Lines | static int file_select_invoke(bContext *C, wmOperator *op, const wmEvent *event) | ||||
| rect.xmin = rect.xmax = event->mval[0]; | rect.xmin = rect.xmax = event->mval[0]; | ||||
| rect.ymin = rect.ymax = event->mval[1]; | rect.ymin = rect.ymax = event->mval[1]; | ||||
| if (!BLI_rcti_isect_pt(&ar->v2d.mask, rect.xmin, rect.ymin)) | if (!BLI_rcti_isect_pt(&ar->v2d.mask, rect.xmin, rect.ymin)) | ||||
| return OPERATOR_CANCELLED; | return OPERATOR_CANCELLED; | ||||
| if (sfile && sfile->params) { | if (sfile && sfile->params) { | ||||
| int idx = sfile->params->highlight_file; | int idx = sfile->params->highlight_file; | ||||
| int numfiles = filelist_files_ensure(sfile->files); | |||||
| if (idx >= 0) { | if ((idx >= 0) && (idx < numfiles)) { | ||||
| struct direntry *file = filelist_file(sfile->files, idx); | struct FileDirEntry *file = filelist_file(sfile->files, idx); | ||||
| if (FILENAME_IS_CURRPAR(file->relname)) { | if (FILENAME_IS_CURRPAR(file->relpath)) { | ||||
| /* skip - If a readonly file (".." or ".") is selected, skip deselect all! */ | /* skip - If a readonly file (".." or ".") is selected, skip deselect all! */ | ||||
| } | } | ||||
| else { | else { | ||||
| /* single select, deselect all selected first */ | /* single select, deselect all selected first */ | ||||
| if (!extend) file_deselect_all(sfile, FILE_SEL_SELECTED); | if (!extend) file_deselect_all(sfile, FILE_SEL_SELECTED); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 46 Lines • ▼ Show 20 Lines | static bool file_walk_select_selection_set( | ||||
| const int last_sel = params->active_file; /* store old value */ | const int last_sel = params->active_file; /* store old value */ | ||||
| int active = active_old; /* could use active_old instead, just for readability */ | int active = active_old; /* could use active_old instead, just for readability */ | ||||
| bool deselect = false; | bool deselect = false; | ||||
| BLI_assert(params); | BLI_assert(params); | ||||
| if (has_selection) { | if (has_selection) { | ||||
| if (extend && | if (extend && | ||||
| filelist_is_selected(files, active_old, FILE_SEL_SELECTED) && | filelist_entry_select_index_get(files, active_old, FILE_SEL_SELECTED) && | ||||
| filelist_is_selected(files, active_new, FILE_SEL_SELECTED)) | filelist_entry_select_index_get(files, active_new, FILE_SEL_SELECTED)) | ||||
| { | { | ||||
| /* conditions for deselecting: initial file is selected, new file is | /* conditions for deselecting: initial file is selected, new file is | ||||
| * selected and either other_side isn't selected/found or we use fill */ | * selected and either other_side isn't selected/found or we use fill */ | ||||
| deselect = (fill || other_site == -1 || !filelist_is_selected(files, other_site, FILE_SEL_SELECTED)); | deselect = (fill || other_site == -1 || | ||||
| !filelist_entry_select_index_get(files, other_site, FILE_SEL_SELECTED)); | |||||
| /* don't change active here since we either want to deselect active or we want to | /* don't change active here since we either want to deselect active or we want to | ||||
| * walk through a block of selected files without selecting/deselecting anything */ | * walk through a block of selected files without selecting/deselecting anything */ | ||||
| params->active_file = active_new; | params->active_file = active_new; | ||||
| /* but we want to change active if we use fill (needed to get correct selection bounds) */ | /* but we want to change active if we use fill (needed to get correct selection bounds) */ | ||||
| if (deselect && fill) { | if (deselect && fill) { | ||||
| active = active_new; | active = active_new; | ||||
| } | } | ||||
| Show All 34 Lines | else { | ||||
| WM_event_add_mousemove(C); | WM_event_add_mousemove(C); | ||||
| } | } | ||||
| /* do the actual selection */ | /* do the actual selection */ | ||||
| if (fill) { | if (fill) { | ||||
| FileSelection sel = { MIN2(active, last_sel), MAX2(active, last_sel) }; | FileSelection sel = { MIN2(active, last_sel), MAX2(active, last_sel) }; | ||||
| /* fill selection between last and first selected file */ | /* fill selection between last and first selected file */ | ||||
| filelist_select( | filelist_entries_select_index_range_set( | ||||
| files, &sel, deselect ? FILE_SEL_REMOVE : FILE_SEL_ADD, FILE_SEL_SELECTED, CHECK_ALL); | files, &sel, deselect ? FILE_SEL_REMOVE : FILE_SEL_ADD, FILE_SEL_SELECTED, CHECK_ALL); | ||||
| /* entire sel is cleared here, so select active again */ | /* entire sel is cleared here, so select active again */ | ||||
| if (deselect) { | if (deselect) { | ||||
| filelist_select_file(files, active, FILE_SEL_ADD, FILE_SEL_SELECTED, CHECK_ALL); | filelist_entry_select_index_set(files, active, FILE_SEL_ADD, FILE_SEL_SELECTED, CHECK_ALL); | ||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| filelist_select_file( | filelist_entry_select_index_set( | ||||
| files, active, deselect ? FILE_SEL_REMOVE : FILE_SEL_ADD, FILE_SEL_SELECTED, CHECK_ALL); | files, active, deselect ? FILE_SEL_REMOVE : FILE_SEL_ADD, FILE_SEL_SELECTED, CHECK_ALL); | ||||
| } | } | ||||
| BLI_assert(IN_RANGE(active, 0, numfiles)); | BLI_assert(IN_RANGE(active, 0, numfiles)); | ||||
| /* selection changed */ | /* selection changed */ | ||||
| return true; | return true; | ||||
| } | } | ||||
| /** | /** | ||||
| * \returns true if selection has changed | * \returns true if selection has changed | ||||
| */ | */ | ||||
| static bool file_walk_select_do( | static bool file_walk_select_do( | ||||
| bContext *C, SpaceFile *sfile, | bContext *C, SpaceFile *sfile, | ||||
| FileSelectParams *params, const int direction, | FileSelectParams *params, const int direction, | ||||
| const bool extend, const bool fill) | const bool extend, const bool fill) | ||||
| { | { | ||||
| struct FileList *files = sfile->files; | struct FileList *files = sfile->files; | ||||
| const int numfiles = filelist_numfiles(files); | const int numfiles = filelist_files_ensure(files); | ||||
| const bool has_selection = file_is_any_selected(files); | const bool has_selection = file_is_any_selected(files); | ||||
| const int active_old = params->active_file; | const int active_old = params->active_file; | ||||
| int active_new = -1; | int active_new = -1; | ||||
| int other_site = -1; /* file on the other site of active_old */ | int other_site = -1; /* file on the other site of active_old */ | ||||
| /* *** get all needed files for handling selection *** */ | /* *** get all needed files for handling selection *** */ | ||||
| ▲ Show 20 Lines • Show All 97 Lines • ▼ Show 20 Lines | void FILE_OT_select_walk(wmOperatorType *ot) | ||||
| RNA_def_property_flag(prop, PROP_SKIP_SAVE); | RNA_def_property_flag(prop, PROP_SKIP_SAVE); | ||||
| } | } | ||||
| static int file_select_all_exec(bContext *C, wmOperator *UNUSED(op)) | static int file_select_all_exec(bContext *C, wmOperator *UNUSED(op)) | ||||
| { | { | ||||
| ScrArea *sa = CTX_wm_area(C); | ScrArea *sa = CTX_wm_area(C); | ||||
| SpaceFile *sfile = CTX_wm_space_file(C); | SpaceFile *sfile = CTX_wm_space_file(C); | ||||
| FileSelection sel; | FileSelection sel; | ||||
| const int numfiles = filelist_numfiles(sfile->files); | const int numfiles = filelist_files_ensure(sfile->files); | ||||
| const bool has_selection = file_is_any_selected(sfile->files); | const bool has_selection = file_is_any_selected(sfile->files); | ||||
| sel.first = 0; | sel.first = 0; | ||||
| sel.last = numfiles - 1; | sel.last = numfiles - 1; | ||||
| /* select all only if previously no file was selected */ | /* select all only if previously no file was selected */ | ||||
| if (has_selection) { | if (has_selection) { | ||||
| filelist_select(sfile->files, &sel, FILE_SEL_REMOVE, FILE_SEL_SELECTED, CHECK_ALL); | filelist_entries_select_index_range_set(sfile->files, &sel, FILE_SEL_REMOVE, FILE_SEL_SELECTED, CHECK_ALL); | ||||
| sfile->params->active_file = -1; | sfile->params->active_file = -1; | ||||
| } | } | ||||
| else { | else { | ||||
| const FileCheckType check_type = (sfile->params->flag & FILE_DIRSEL_ONLY) ? CHECK_DIRS : CHECK_FILES; | const FileCheckType check_type = (sfile->params->flag & FILE_DIRSEL_ONLY) ? CHECK_DIRS : CHECK_FILES; | ||||
| int i; | int i; | ||||
| filelist_select(sfile->files, &sel, FILE_SEL_ADD, FILE_SEL_SELECTED, check_type); | filelist_entries_select_index_range_set(sfile->files, &sel, FILE_SEL_ADD, FILE_SEL_SELECTED, check_type); | ||||
| /* set active_file to first selected */ | /* set active_file to first selected */ | ||||
| for (i = 0; i < numfiles; i++) { | for (i = 0; i < numfiles; i++) { | ||||
| if (filelist_is_selected(sfile->files, i, check_type)) { | if (filelist_entry_select_index_get(sfile->files, i, check_type)) { | ||||
| sfile->params->active_file = i; | sfile->params->active_file = i; | ||||
| break; | break; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| file_draw_check(C); | file_draw_check(C); | ||||
| WM_event_add_mousemove(C); | WM_event_add_mousemove(C); | ||||
| ▲ Show 20 Lines • Show All 301 Lines • ▼ Show 20 Lines | |||||
| int file_highlight_set(SpaceFile *sfile, ARegion *ar, int mx, int my) | int file_highlight_set(SpaceFile *sfile, ARegion *ar, int mx, int my) | ||||
| { | { | ||||
| View2D *v2d = &ar->v2d; | View2D *v2d = &ar->v2d; | ||||
| FileSelectParams *params; | FileSelectParams *params; | ||||
| int numfiles, origfile; | int numfiles, origfile; | ||||
| if (sfile == NULL || sfile->files == NULL) return 0; | if (sfile == NULL || sfile->files == NULL) return 0; | ||||
| numfiles = filelist_numfiles(sfile->files); | numfiles = filelist_files_ensure(sfile->files); | ||||
| params = ED_fileselect_get_params(sfile); | params = ED_fileselect_get_params(sfile); | ||||
| origfile = params->highlight_file; | origfile = params->highlight_file; | ||||
| mx -= ar->winrct.xmin; | mx -= ar->winrct.xmin; | ||||
| my -= ar->winrct.ymin; | my -= ar->winrct.ymin; | ||||
| if (BLI_rcti_isect_pt(&ar->v2d.mask, mx, my)) { | if (BLI_rcti_isect_pt(&ar->v2d.mask, mx, my)) { | ||||
| ▲ Show 20 Lines • Show All 97 Lines • ▼ Show 20 Lines | void file_sfile_to_operator(wmOperator *op, SpaceFile *sfile, char *filepath) | ||||
| if ((prop = RNA_struct_find_property(op->ptr, "filepath"))) { | if ((prop = RNA_struct_find_property(op->ptr, "filepath"))) { | ||||
| RNA_property_string_set(op->ptr, prop, filepath); | RNA_property_string_set(op->ptr, prop, filepath); | ||||
| } | } | ||||
| /* some ops have multiple files to select */ | /* some ops have multiple files to select */ | ||||
| /* this is called on operators check() so clear collections first since | /* this is called on operators check() so clear collections first since | ||||
| * they may be already set. */ | * they may be already set. */ | ||||
| { | { | ||||
| int i, numfiles = filelist_numfiles(sfile->files); | int i, numfiles = filelist_files_ensure(sfile->files); | ||||
| if ((prop = RNA_struct_find_property(op->ptr, "files"))) { | if ((prop = RNA_struct_find_property(op->ptr, "files"))) { | ||||
| PointerRNA itemptr; | PointerRNA itemptr; | ||||
| int num_files = 0; | int num_files = 0; | ||||
| RNA_property_collection_clear(op->ptr, prop); | RNA_property_collection_clear(op->ptr, prop); | ||||
| for (i = 0; i < numfiles; i++) { | for (i = 0; i < numfiles; i++) { | ||||
| if (filelist_is_selected(sfile->files, i, CHECK_FILES)) { | if (filelist_entry_select_index_get(sfile->files, i, CHECK_FILES)) { | ||||
| struct direntry *file = filelist_file(sfile->files, i); | FileDirEntry *file = filelist_file(sfile->files, i); | ||||
| RNA_property_collection_add(op->ptr, prop, &itemptr); | RNA_property_collection_add(op->ptr, prop, &itemptr); | ||||
| RNA_string_set(&itemptr, "name", file->relname); | RNA_string_set(&itemptr, "name", file->relpath); | ||||
| num_files++; | num_files++; | ||||
| } | } | ||||
| } | } | ||||
| /* make sure the file specified in the filename button is added even if no files selected */ | /* make sure the file specified in the filename button is added even if no files selected */ | ||||
| if (0 == num_files) { | if (0 == num_files) { | ||||
| RNA_property_collection_add(op->ptr, prop, &itemptr); | RNA_property_collection_add(op->ptr, prop, &itemptr); | ||||
| RNA_string_set(&itemptr, "name", sfile->params->file); | RNA_string_set(&itemptr, "name", sfile->params->file); | ||||
| } | } | ||||
| } | } | ||||
| if ((prop = RNA_struct_find_property(op->ptr, "dirs"))) { | if ((prop = RNA_struct_find_property(op->ptr, "dirs"))) { | ||||
| PointerRNA itemptr; | PointerRNA itemptr; | ||||
| int num_dirs = 0; | int num_dirs = 0; | ||||
| RNA_property_collection_clear(op->ptr, prop); | RNA_property_collection_clear(op->ptr, prop); | ||||
| for (i = 0; i < numfiles; i++) { | for (i = 0; i < numfiles; i++) { | ||||
| if (filelist_is_selected(sfile->files, i, CHECK_DIRS)) { | if (filelist_entry_select_index_get(sfile->files, i, CHECK_DIRS)) { | ||||
| struct direntry *file = filelist_file(sfile->files, i); | FileDirEntry *file = filelist_file(sfile->files, i); | ||||
| RNA_property_collection_add(op->ptr, prop, &itemptr); | RNA_property_collection_add(op->ptr, prop, &itemptr); | ||||
| RNA_string_set(&itemptr, "name", file->relname); | RNA_string_set(&itemptr, "name", file->relpath); | ||||
| num_dirs++; | num_dirs++; | ||||
| } | } | ||||
| } | } | ||||
| /* make sure the directory specified in the button is added even if no directory selected */ | /* make sure the directory specified in the button is added even if no directory selected */ | ||||
| if (0 == num_dirs) { | if (0 == num_dirs) { | ||||
| RNA_property_collection_add(op->ptr, prop, &itemptr); | RNA_property_collection_add(op->ptr, prop, &itemptr); | ||||
| RNA_string_set(&itemptr, "name", sfile->params->dir); | RNA_string_set(&itemptr, "name", sfile->params->dir); | ||||
| ▲ Show 20 Lines • Show All 82 Lines • ▼ Show 20 Lines | int file_exec(bContext *C, wmOperator *exec_op) | ||||
| char filepath[FILE_MAX]; | char filepath[FILE_MAX]; | ||||
| if (sfile->op) { | if (sfile->op) { | ||||
| wmOperator *op = sfile->op; | wmOperator *op = sfile->op; | ||||
| /* when used as a macro, for doubleclick, | /* when used as a macro, for doubleclick, | ||||
| * to prevent closing when doubleclicking on .. item */ | * to prevent closing when doubleclicking on .. item */ | ||||
| if (RNA_boolean_get(exec_op->ptr, "need_active")) { | if (RNA_boolean_get(exec_op->ptr, "need_active")) { | ||||
| const int numfiles = filelist_files_ensure(sfile->files); | |||||
| int i, active = 0; | int i, active = 0; | ||||
| for (i = 0; i < filelist_numfiles(sfile->files); i++) { | for (i = 0; i < numfiles; i++) { | ||||
| if (filelist_is_selected(sfile->files, i, CHECK_ALL)) { | if (filelist_entry_select_index_get(sfile->files, i, CHECK_ALL)) { | ||||
| active = 1; | active = 1; | ||||
| break; | break; | ||||
| } | } | ||||
| } | } | ||||
| if (active == 0) | if (active == 0) | ||||
| return OPERATOR_CANCELLED; | return OPERATOR_CANCELLED; | ||||
| } | } | ||||
| Show All 40 Lines | |||||
| { | { | ||||
| SpaceFile *sfile = CTX_wm_space_file(C); | SpaceFile *sfile = CTX_wm_space_file(C); | ||||
| if (sfile->params) { | if (sfile->params) { | ||||
| if (BLI_parent_dir(sfile->params->dir)) { | if (BLI_parent_dir(sfile->params->dir)) { | ||||
| BLI_cleanup_dir(G.main->name, sfile->params->dir); | BLI_cleanup_dir(G.main->name, sfile->params->dir); | ||||
| /* if not browsing in .blend file, we still want to check whether the path is a directory */ | /* if not browsing in .blend file, we still want to check whether the path is a directory */ | ||||
| if (sfile->params->type == FILE_LOADLIB) { | if (sfile->params->type == FILE_LOADLIB) { | ||||
| char tdir[FILE_MAX], tgroup[FILE_MAX]; | char tdir[FILE_MAX]; | ||||
| if (BLO_is_a_library(sfile->params->dir, tdir, tgroup)) { | if (BLO_library_path_explode(sfile->params->dir, tdir, NULL, NULL)) { | ||||
| ED_file_change_dir(C, false); | ED_file_change_dir(C, false); | ||||
| } | } | ||||
| else { | else { | ||||
| ED_file_change_dir(C, true); | ED_file_change_dir(C, true); | ||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| ED_file_change_dir(C, true); | ED_file_change_dir(C, true); | ||||
| } | } | ||||
| if (sfile->params->recursion_level > 1) { | |||||
| /* Disable 'dirtree' recursion when going up in tree. */ | |||||
Done Inline ActionsUse fullstop insteaod of bangs in comments. sergey: Use fullstop insteaod of bangs in comments. | |||||
| sfile->params->recursion_level = 0; | |||||
| filelist_setrecursion(sfile->files, sfile->params->recursion_level); | |||||
| } | |||||
| WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_LIST, NULL); | WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_LIST, NULL); | ||||
| } | } | ||||
| } | } | ||||
| return OPERATOR_FINISHED; | return OPERATOR_FINISHED; | ||||
| } | } | ||||
| Show All 10 Lines | void FILE_OT_parent(struct wmOperatorType *ot) | ||||
| ot->poll = ED_operator_file_active; /* <- important, handler is on window level */ | ot->poll = ED_operator_file_active; /* <- important, handler is on window level */ | ||||
| } | } | ||||
| static int file_refresh_exec(bContext *C, wmOperator *UNUSED(unused)) | static int file_refresh_exec(bContext *C, wmOperator *UNUSED(unused)) | ||||
| { | { | ||||
| wmWindowManager *wm = CTX_wm_manager(C); | wmWindowManager *wm = CTX_wm_manager(C); | ||||
| SpaceFile *sfile = CTX_wm_space_file(C); | SpaceFile *sfile = CTX_wm_space_file(C); | ||||
| ScrArea *sa = CTX_wm_area(C); | |||||
| struct FSMenu *fsmenu = ED_fsmenu_get(); | struct FSMenu *fsmenu = ED_fsmenu_get(); | ||||
| ED_fileselect_clear(wm, sfile); | ED_fileselect_clear(wm, sa, sfile); | ||||
| /* refresh system directory menu */ | /* refresh system directory menu */ | ||||
| fsmenu_refresh_system_category(fsmenu); | fsmenu_refresh_system_category(fsmenu); | ||||
| WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_LIST, NULL); | WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_LIST, NULL); | ||||
| return OPERATOR_FINISHED; | return OPERATOR_FINISHED; | ||||
| ▲ Show 20 Lines • Show All 73 Lines • ▼ Show 20 Lines | static int file_smoothscroll_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent *event) | ||||
| int numfiles, numfiles_layout; | int numfiles, numfiles_layout; | ||||
| int edit_idx = 0; | int edit_idx = 0; | ||||
| int i; | int i; | ||||
| /* escape if not our timer */ | /* escape if not our timer */ | ||||
| if (sfile->smoothscroll_timer == NULL || sfile->smoothscroll_timer != event->customdata) | if (sfile->smoothscroll_timer == NULL || sfile->smoothscroll_timer != event->customdata) | ||||
| return OPERATOR_PASS_THROUGH; | return OPERATOR_PASS_THROUGH; | ||||
| numfiles = filelist_numfiles(sfile->files); | numfiles = filelist_files_ensure(sfile->files); | ||||
| /* check if we are editing a name */ | /* check if we are editing a name */ | ||||
| for (i = 0; i < numfiles; ++i) { | for (i = 0; i < numfiles; ++i) { | ||||
| if (filelist_is_selected(sfile->files, i, CHECK_ALL) ) { | if (filelist_entry_select_index_get(sfile->files, i, CHECK_ALL) ) { | ||||
| edit_idx = i; | edit_idx = i; | ||||
| break; | break; | ||||
| } | } | ||||
| } | } | ||||
| /* if we are not editing, we are done */ | /* if we are not editing, we are done */ | ||||
| if (0 == edit_idx) { | if (0 == edit_idx) { | ||||
| WM_event_remove_timer(CTX_wm_manager(C), CTX_wm_window(C), sfile->smoothscroll_timer); | WM_event_remove_timer(CTX_wm_manager(C), CTX_wm_window(C), sfile->smoothscroll_timer); | ||||
| ▲ Show 20 Lines • Show All 106 Lines • ▼ Show 20 Lines | |||||
| { | { | ||||
| char name[FILE_MAXFILE]; | char name[FILE_MAXFILE]; | ||||
| char path[FILE_MAX]; | char path[FILE_MAX]; | ||||
| int generate_name = 1; | int generate_name = 1; | ||||
| PropertyRNA *prop; | PropertyRNA *prop; | ||||
| wmWindowManager *wm = CTX_wm_manager(C); | wmWindowManager *wm = CTX_wm_manager(C); | ||||
| SpaceFile *sfile = CTX_wm_space_file(C); | SpaceFile *sfile = CTX_wm_space_file(C); | ||||
| ScrArea *sa = CTX_wm_area(C); | |||||
| if (!sfile->params) { | if (!sfile->params) { | ||||
| BKE_report(op->reports, RPT_WARNING, "No parent directory given"); | BKE_report(op->reports, RPT_WARNING, "No parent directory given"); | ||||
| return OPERATOR_CANCELLED; | return OPERATOR_CANCELLED; | ||||
| } | } | ||||
| path[0] = '\0'; | path[0] = '\0'; | ||||
| Show All 21 Lines | int file_directory_new_exec(bContext *C, wmOperator *op) | ||||
| /* now remember file to jump into editing */ | /* now remember file to jump into editing */ | ||||
| BLI_strncpy(sfile->params->renamefile, name, FILE_MAXFILE); | BLI_strncpy(sfile->params->renamefile, name, FILE_MAXFILE); | ||||
| /* set timer to smoothly view newly generated file */ | /* set timer to smoothly view newly generated file */ | ||||
| sfile->smoothscroll_timer = WM_event_add_timer(wm, CTX_wm_window(C), TIMER1, 1.0 / 1000.0); /* max 30 frs/sec */ | sfile->smoothscroll_timer = WM_event_add_timer(wm, CTX_wm_window(C), TIMER1, 1.0 / 1000.0); /* max 30 frs/sec */ | ||||
| sfile->scroll_offset = 0; | sfile->scroll_offset = 0; | ||||
| /* reload dir to make sure we're seeing what's in the directory */ | /* reload dir to make sure we're seeing what's in the directory */ | ||||
| ED_fileselect_clear(wm, sfile); | ED_fileselect_clear(wm, sa, sfile); | ||||
| if (RNA_boolean_get(op->ptr, "open")) { | if (RNA_boolean_get(op->ptr, "open")) { | ||||
| BLI_strncpy(sfile->params->dir, path, sizeof(sfile->params->dir)); | BLI_strncpy(sfile->params->dir, path, sizeof(sfile->params->dir)); | ||||
| ED_file_change_dir(C, true); | ED_file_change_dir(C, true); | ||||
| } | } | ||||
| WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_LIST, NULL); | WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_LIST, NULL); | ||||
| ▲ Show 20 Lines • Show All 166 Lines • ▼ Show 20 Lines | if (matches == 1) { | ||||
| BLI_cleanup_dir(G.main->name, filepath); | BLI_cleanup_dir(G.main->name, filepath); | ||||
| BLI_strncpy(sfile->params->dir, filepath, sizeof(sfile->params->dir)); | BLI_strncpy(sfile->params->dir, filepath, sizeof(sfile->params->dir)); | ||||
| sfile->params->file[0] = '\0'; | sfile->params->file[0] = '\0'; | ||||
| ED_file_change_dir(C, true); | ED_file_change_dir(C, true); | ||||
| UI_textbutton_activate_but(C, but); | UI_textbutton_activate_but(C, but); | ||||
| WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_PARAMS, NULL); | WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_PARAMS, NULL); | ||||
| } | } | ||||
| else if (sfile->params->type == FILE_LOADLIB) { | else if (sfile->params->type == FILE_LOADLIB) { | ||||
| char tdir[FILE_MAX], tgroup[FILE_MAX]; | char tdir[FILE_MAX]; | ||||
| BLI_add_slash(filepath); | BLI_add_slash(filepath); | ||||
| if (BLO_is_a_library(filepath, tdir, tgroup)) { | if (BLO_library_path_explode(filepath, tdir, NULL, NULL)) { | ||||
| BLI_cleanup_dir(G.main->name, filepath); | BLI_cleanup_dir(G.main->name, filepath); | ||||
| BLI_strncpy(sfile->params->dir, filepath, sizeof(sfile->params->dir)); | BLI_strncpy(sfile->params->dir, filepath, sizeof(sfile->params->dir)); | ||||
| sfile->params->file[0] = '\0'; | sfile->params->file[0] = '\0'; | ||||
| ED_file_change_dir(C, false); | ED_file_change_dir(C, false); | ||||
| UI_textbutton_activate_but(C, but); | UI_textbutton_activate_but(C, but); | ||||
| WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_LIST, NULL); | WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_LIST, NULL); | ||||
| } | } | ||||
| } | } | ||||
| Show All 15 Lines | void FILE_OT_refresh(struct wmOperatorType *ot) | ||||
| ot->exec = file_refresh_exec; | ot->exec = file_refresh_exec; | ||||
| ot->poll = ED_operator_file_active; /* <- important, handler is on window level */ | ot->poll = ED_operator_file_active; /* <- important, handler is on window level */ | ||||
| } | } | ||||
| static int file_hidedot_exec(bContext *C, wmOperator *UNUSED(unused)) | static int file_hidedot_exec(bContext *C, wmOperator *UNUSED(unused)) | ||||
| { | { | ||||
| wmWindowManager *wm = CTX_wm_manager(C); | wmWindowManager *wm = CTX_wm_manager(C); | ||||
| SpaceFile *sfile = CTX_wm_space_file(C); | SpaceFile *sfile = CTX_wm_space_file(C); | ||||
| ScrArea *sa = CTX_wm_area(C); | |||||
| if (sfile->params) { | if (sfile->params) { | ||||
| sfile->params->flag ^= FILE_HIDE_DOT; | sfile->params->flag ^= FILE_HIDE_DOT; | ||||
| ED_fileselect_clear(wm, sfile); | ED_fileselect_clear(wm, sa, sfile); | ||||
| WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_LIST, NULL); | WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_LIST, NULL); | ||||
| } | } | ||||
| return OPERATOR_FINISHED; | return OPERATOR_FINISHED; | ||||
| } | } | ||||
| void FILE_OT_hidedot(struct wmOperatorType *ot) | void FILE_OT_hidedot(struct wmOperatorType *ot) | ||||
| ▲ Show 20 Lines • Show All 93 Lines • ▼ Show 20 Lines | |||||
| static int file_rename_exec(bContext *C, wmOperator *UNUSED(op)) | static int file_rename_exec(bContext *C, wmOperator *UNUSED(op)) | ||||
| { | { | ||||
| ScrArea *sa = CTX_wm_area(C); | ScrArea *sa = CTX_wm_area(C); | ||||
| SpaceFile *sfile = (SpaceFile *)CTX_wm_space_data(C); | SpaceFile *sfile = (SpaceFile *)CTX_wm_space_data(C); | ||||
| if (sfile->params) { | if (sfile->params) { | ||||
| int idx = sfile->params->highlight_file; | int idx = sfile->params->highlight_file; | ||||
| int numfiles = filelist_numfiles(sfile->files); | int numfiles = filelist_files_ensure(sfile->files); | ||||
| if ( (0 <= idx) && (idx < numfiles) ) { | if ( (0 <= idx) && (idx < numfiles) ) { | ||||
| struct direntry *file = filelist_file(sfile->files, idx); | FileDirEntry *file = filelist_file(sfile->files, idx); | ||||
| filelist_select_file(sfile->files, idx, FILE_SEL_ADD, FILE_SEL_EDITING, CHECK_ALL); | filelist_entry_select_index_set(sfile->files, idx, FILE_SEL_ADD, FILE_SEL_EDITING, CHECK_ALL); | ||||
| BLI_strncpy(sfile->params->renameedit, file->relname, FILE_MAXFILE); | BLI_strncpy(sfile->params->renameedit, file->relpath, FILE_MAXFILE); | ||||
| sfile->params->renamefile[0] = '\0'; | sfile->params->renamefile[0] = '\0'; | ||||
| } | } | ||||
| ED_area_tag_redraw(sa); | ED_area_tag_redraw(sa); | ||||
| } | } | ||||
| return OPERATOR_FINISHED; | return OPERATOR_FINISHED; | ||||
| } | } | ||||
| static int file_rename_poll(bContext *C) | static int file_rename_poll(bContext *C) | ||||
| { | { | ||||
| int poll = ED_operator_file_active(C); | bool poll = ED_operator_file_active(C); | ||||
| SpaceFile *sfile = CTX_wm_space_file(C); | SpaceFile *sfile = CTX_wm_space_file(C); | ||||
| if (sfile && sfile->params) { | if (sfile && sfile->params) { | ||||
| int idx = sfile->params->highlight_file; | int idx = sfile->params->highlight_file; | ||||
| int numfiles = filelist_files_ensure(sfile->files); | |||||
| if (idx >= 0) { | if ((0 <= idx) && (idx < numfiles)) { | ||||
| struct direntry *file = filelist_file(sfile->files, idx); | FileDirEntry *file = filelist_file(sfile->files, idx); | ||||
| if (FILENAME_IS_CURRPAR(file->relname)) { | if (FILENAME_IS_CURRPAR(file->relpath)) { | ||||
| poll = 0; | poll = false; | ||||
| } | } | ||||
| } | } | ||||
| if (sfile->params->highlight_file < 0) { | if (sfile->params->highlight_file < 0) { | ||||
| poll = 0; | poll = false; | ||||
| } | } | ||||
| else { | else { | ||||
| char dir[FILE_MAX], group[FILE_MAX]; | char dir[FILE_MAX]; | ||||
| if (filelist_islibrary(sfile->files, dir, group)) poll = 0; | if (filelist_islibrary(sfile->files, dir, NULL)) { | ||||
| poll = false; | |||||
| } | } | ||||
| } | } | ||||
| else | } | ||||
| poll = 0; | else { | ||||
| poll = false; | |||||
| } | |||||
| return poll; | return poll; | ||||
| } | } | ||||
| void FILE_OT_rename(struct wmOperatorType *ot) | void FILE_OT_rename(struct wmOperatorType *ot) | ||||
| { | { | ||||
| /* identifiers */ | /* identifiers */ | ||||
| ot->name = "Rename File or Directory"; | ot->name = "Rename File or Directory"; | ||||
| ot->description = "Rename file or file directory"; | ot->description = "Rename file or file directory"; | ||||
| ot->idname = "FILE_OT_rename"; | ot->idname = "FILE_OT_rename"; | ||||
| /* api callbacks */ | /* api callbacks */ | ||||
| ot->exec = file_rename_exec; | ot->exec = file_rename_exec; | ||||
| ot->poll = file_rename_poll; | ot->poll = file_rename_poll; | ||||
| } | } | ||||
| static int file_delete_poll(bContext *C) | static int file_delete_poll(bContext *C) | ||||
| { | { | ||||
| int poll = ED_operator_file_active(C); | int poll = ED_operator_file_active(C); | ||||
| SpaceFile *sfile = CTX_wm_space_file(C); | SpaceFile *sfile = CTX_wm_space_file(C); | ||||
| if (sfile && sfile->params) { | if (sfile && sfile->params) { | ||||
| char dir[FILE_MAX], group[FILE_MAX]; | char dir[FILE_MAX]; | ||||
| int numfiles = filelist_numfiles(sfile->files); | int numfiles = filelist_files_ensure(sfile->files); | ||||
| int i; | int i; | ||||
| int num_selected = 0; | int num_selected = 0; | ||||
| if (filelist_islibrary(sfile->files, dir, group)) poll = 0; | if (filelist_islibrary(sfile->files, dir, NULL)) poll = 0; | ||||
| for (i = 0; i < numfiles; i++) { | for (i = 0; i < numfiles; i++) { | ||||
| if (filelist_is_selected(sfile->files, i, CHECK_FILES)) { | if (filelist_entry_select_index_get(sfile->files, i, CHECK_FILES)) { | ||||
| num_selected++; | num_selected++; | ||||
| } | } | ||||
| } | } | ||||
| if (num_selected <= 0) { | if (num_selected <= 0) { | ||||
| poll = 0; | poll = 0; | ||||
| } | } | ||||
| } | } | ||||
| else | else | ||||
| poll = 0; | poll = 0; | ||||
| return poll; | return poll; | ||||
| } | } | ||||
| int file_delete_exec(bContext *C, wmOperator *UNUSED(op)) | int file_delete_exec(bContext *C, wmOperator *UNUSED(op)) | ||||
| { | { | ||||
| char str[FILE_MAX]; | char str[FILE_MAX]; | ||||
| wmWindowManager *wm = CTX_wm_manager(C); | wmWindowManager *wm = CTX_wm_manager(C); | ||||
| SpaceFile *sfile = CTX_wm_space_file(C); | SpaceFile *sfile = CTX_wm_space_file(C); | ||||
| struct direntry *file; | ScrArea *sa = CTX_wm_area(C); | ||||
| int numfiles = filelist_numfiles(sfile->files); | FileDirEntry *file; | ||||
| int numfiles = filelist_files_ensure(sfile->files); | |||||
| int i; | int i; | ||||
| for (i = 0; i < numfiles; i++) { | for (i = 0; i < numfiles; i++) { | ||||
| if (filelist_is_selected(sfile->files, i, CHECK_FILES)) { | if (filelist_entry_select_index_get(sfile->files, i, CHECK_FILES)) { | ||||
| file = filelist_file(sfile->files, i); | file = filelist_file(sfile->files, i); | ||||
| BLI_make_file_string(G.main->name, str, sfile->params->dir, file->relname); | BLI_make_file_string(G.main->name, str, sfile->params->dir, file->relpath); | ||||
| BLI_delete(str, false, false); | BLI_delete(str, false, false); | ||||
| } | } | ||||
| } | } | ||||
| ED_fileselect_clear(wm, sfile); | ED_fileselect_clear(wm, sa, sfile); | ||||
| WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_LIST, NULL); | WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_LIST, NULL); | ||||
| return OPERATOR_FINISHED; | return OPERATOR_FINISHED; | ||||
| } | } | ||||
| void FILE_OT_delete(struct wmOperatorType *ot) | void FILE_OT_delete(struct wmOperatorType *ot) | ||||
| { | { | ||||
| Show All 19 Lines | |||||
Could be const?