static FileSelect file_select(bContext *C, const rcti *rect, FileSelType select, bool fill, bool do_diropen) { SpaceFile *sfile = CTX_wm_space_file(C); FileSelect retval = FILE_SELECT_NOTHING; 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; /* flag the files as selected in the filelist */ filelist_select(sfile->files, &sel, select, SELECTED_FILE, check_type); /* Don't act on multiple selected files */ if (sel.first != sel.last) select = 0; /* Do we have a valid selection and are we actually selecting */ if ((sel.last >= 0) && ((select == FILE_SEL_ADD) || (select == FILE_SEL_TOGGLE))) { /* Check last selection, if selected, act on the file or dir */ if (filelist_is_selected(sfile->files, sel.last, check_type)) { retval = file_select_do(C, sel.last, do_diropen); } } /* update operator for name change event */ file_draw_check_cb(C, NULL, NULL); return retval; }
static int file_filenum_exec(bContext *C, wmOperator *op) { SpaceFile *sfile= CTX_wm_space_file(C); ScrArea *sa= CTX_wm_area(C); int inc = RNA_int_get(op->ptr, "increment"); if(sfile->params && (inc != 0)) { BLI_newname(sfile->params->file, inc); ED_area_tag_redraw(sa); file_draw_check_cb(C, NULL, NULL); // WM_event_add_notifier(C, NC_WINDOW, NULL); } return OPERATOR_FINISHED; }
void file_change_dir(bContext *C, int checkdir) { wmWindowManager *wm = CTX_wm_manager(C); SpaceFile *sfile = CTX_wm_space_file(C); if (sfile->params) { ED_fileselect_clear(wm, sfile); if (checkdir && !BLI_is_dir(sfile->params->dir)) { BLI_strncpy(sfile->params->dir, filelist_dir(sfile->files), sizeof(sfile->params->dir)); /* could return but just refresh the current dir */ } filelist_setdir(sfile->files, sfile->params->dir); if (folderlist_clear_next(sfile)) folderlist_free(sfile->folders_next); folderlist_pushdir(sfile->folders_prev, sfile->params->dir); file_draw_check_cb(C, NULL, NULL); } }