Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/space_file/file_ops.c
| Show First 20 Lines • Show All 72 Lines • ▼ Show 20 Lines | static FileSelection find_file_mouse_rect(SpaceFile *sfile, ARegion *ar, const rcti *rect_region) | ||||
| View2D *v2d = &ar->v2d; | View2D *v2d = &ar->v2d; | ||||
| rcti rect_view; | rcti rect_view; | ||||
| rctf rect_view_fl; | rctf rect_view_fl; | ||||
| rctf rect_region_fl; | rctf rect_region_fl; | ||||
| BLI_rctf_rcti_copy(&rect_region_fl, rect_region); | BLI_rctf_rcti_copy(&rect_region_fl, rect_region); | ||||
| /* Okay, manipulating v2d rects here is hacky... */ | |||||
| v2d->mask.ymax -= sfile->layout->offset_top; | |||||
| v2d->cur.ymax -= sfile->layout->offset_top; | |||||
| UI_view2d_region_to_view_rctf(v2d, &rect_region_fl, &rect_view_fl); | UI_view2d_region_to_view_rctf(v2d, &rect_region_fl, &rect_view_fl); | ||||
| v2d->mask.ymax += sfile->layout->offset_top; | |||||
| v2d->cur.ymax += sfile->layout->offset_top; | |||||
| BLI_rcti_init(&rect_view, | BLI_rcti_init(&rect_view, | ||||
| (int)(v2d->tot.xmin + rect_view_fl.xmin), | (int)(v2d->tot.xmin + rect_view_fl.xmin), | ||||
| (int)(v2d->tot.xmin + rect_view_fl.xmax), | (int)(v2d->tot.xmin + rect_view_fl.xmax), | ||||
| (int)(v2d->tot.ymax - rect_view_fl.ymin), | (int)(v2d->tot.ymax - rect_view_fl.ymin), | ||||
| (int)(v2d->tot.ymax - rect_view_fl.ymax)); | (int)(v2d->tot.ymax - rect_view_fl.ymax)); | ||||
| sel = ED_fileselect_layout_offset_rect(sfile->layout, &rect_view); | sel = ED_fileselect_layout_offset_rect(sfile->layout, &rect_view); | ||||
| ▲ Show 20 Lines • Show All 95 Lines • ▼ Show 20 Lines | if ((selected_idx >= 0) && (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; | ||||
| params->active_file = selected_idx; | params->active_file = selected_idx; | ||||
| if (file->typeflag & FILE_TYPE_DIR) { | if (file->typeflag & FILE_TYPE_DIR) { | ||||
| const bool is_parent_dir = FILENAME_IS_PARENT(file->relpath); | const bool is_parent_dir = FILENAME_IS_PARENT(file->relpath); | ||||
| if (do_diropen == false) { | if (do_diropen == false) { | ||||
| 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->relpath) >= 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) { | ||||
| ▲ Show 20 Lines • Show All 55 Lines • ▼ Show 20 Lines | static void file_ensure_inside_viewbounds(ARegion *ar, SpaceFile *sfile, const int file) | ||||
| file_tile_boundbox(ar, layout, file, &rect); | file_tile_boundbox(ar, layout, file, &rect); | ||||
| /* down - also use if tile is higher than viewbounds so view is aligned to file name */ | /* down - also use if tile is higher than viewbounds so view is aligned to file name */ | ||||
| if (cur->ymin > rect.ymin || layout->tile_h > ar->winy) { | if (cur->ymin > rect.ymin || layout->tile_h > ar->winy) { | ||||
| cur->ymin = rect.ymin - (2 * layout->tile_border_y); | cur->ymin = rect.ymin - (2 * layout->tile_border_y); | ||||
| cur->ymax = cur->ymin + ar->winy; | cur->ymax = cur->ymin + ar->winy; | ||||
| } | } | ||||
| /* up */ | /* up */ | ||||
| else if (cur->ymax < rect.ymax) { | else if ((cur->ymax - layout->offset_top) < rect.ymax) { | ||||
| cur->ymax = rect.ymax + layout->tile_border_y; | cur->ymax = rect.ymax + layout->tile_border_y + layout->offset_top; | ||||
| cur->ymin = cur->ymax - ar->winy; | cur->ymin = cur->ymax - ar->winy; | ||||
| } | } | ||||
| /* left - also use if tile is wider than viewbounds so view is aligned to file name */ | /* left - also use if tile is wider than viewbounds so view is aligned to file name */ | ||||
| else if (cur->xmin > rect.xmin || layout->tile_w > ar->winx) { | else if (cur->xmin > rect.xmin || layout->tile_w > ar->winx) { | ||||
| cur->xmin = rect.xmin - layout->tile_border_x; | cur->xmin = rect.xmin - layout->tile_border_x; | ||||
| cur->xmax = cur->xmin + ar->winx; | cur->xmax = cur->xmin + ar->winx; | ||||
| } | } | ||||
| /* right */ | /* right */ | ||||
| else if (cur->xmax < rect.xmax) { | else if (cur->xmax < rect.xmax) { | ||||
| cur->xmax = rect.xmax + (2 * layout->tile_border_x); | cur->xmax = rect.xmax + (2 * layout->tile_border_x); | ||||
| cur->xmin = cur->xmax - ar->winx; | cur->xmin = cur->xmax - ar->winx; | ||||
| } | } | ||||
| else { | else { | ||||
| BLI_assert(cur->xmin <= rect.xmin && cur->xmax >= rect.xmax && cur->ymin <= rect.ymin && | BLI_assert(cur->xmin <= rect.xmin && cur->xmax >= rect.xmax && cur->ymin <= rect.ymin && | ||||
| cur->ymax >= rect.ymax); | (cur->ymax - layout->offset_top) >= rect.ymax); | ||||
| changed = false; | changed = false; | ||||
| } | } | ||||
| if (changed) { | if (changed) { | ||||
| UI_view2d_curRect_validate(&ar->v2d); | UI_view2d_curRect_validate(&ar->v2d); | ||||
| } | } | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 89 Lines • ▼ Show 20 Lines | static int file_box_select_modal(bContext *C, wmOperator *op, const wmEvent *event) | ||||
| int result; | int result; | ||||
| result = WM_gesture_box_modal(C, op, event); | result = WM_gesture_box_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); | ED_fileselect_layout_isect_rect(sfile->layout, &ar->v2d, &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_entries_select_index_range_set( | filelist_entries_select_index_range_set( | ||||
| sfile->files, &sel, FILE_SEL_ADD, FILE_SEL_HIGHLIGHTED, CHECK_ALL); | sfile->files, &sel, FILE_SEL_ADD, FILE_SEL_HIGHLIGHTED, CHECK_ALL); | ||||
| Show All 39 Lines | static int file_box_select_exec(bContext *C, wmOperator *op) | ||||
| WM_operator_properties_border_to_rcti(op, &rect); | WM_operator_properties_border_to_rcti(op, &rect); | ||||
| const eSelectOp sel_op = RNA_enum_get(op->ptr, "mode"); | const eSelectOp sel_op = RNA_enum_get(op->ptr, "mode"); | ||||
| const bool select = (sel_op != SEL_OP_SUB); | const bool select = (sel_op != SEL_OP_SUB); | ||||
| if (SEL_OP_USE_PRE_DESELECT(sel_op)) { | if (SEL_OP_USE_PRE_DESELECT(sel_op)) { | ||||
| file_deselect_all(sfile, FILE_SEL_SELECTED); | file_deselect_all(sfile, FILE_SEL_SELECTED); | ||||
| } | } | ||||
| BLI_rcti_isect(&(ar->v2d.mask), &rect, &rect); | ED_fileselect_layout_isect_rect(sfile->layout, &ar->v2d, &rect, &rect); | ||||
| ret = file_select(C, &rect, select ? FILE_SEL_ADD : FILE_SEL_REMOVE, false, false); | ret = file_select(C, &rect, select ? FILE_SEL_ADD : FILE_SEL_REMOVE, false, false); | ||||
| /* unselect '..' parent entry - it's not supposed to be selected if more than | /* unselect '..' parent entry - it's not supposed to be selected if more than | ||||
| * one file is selected */ | * one file is selected */ | ||||
| filelist_entry_select_index_set(sfile->files, 0, FILE_SEL_REMOVE, FILE_SEL_SELECTED, CHECK_ALL); | filelist_entry_select_index_set(sfile->files, 0, FILE_SEL_REMOVE, FILE_SEL_SELECTED, CHECK_ALL); | ||||
| if (FILE_SELECT_DIR == ret) { | if (FILE_SELECT_DIR == ret) { | ||||
| Show All 36 Lines | static int file_select_invoke(bContext *C, wmOperator *op, const wmEvent *event) | ||||
| if (ar->regiontype != RGN_TYPE_WINDOW) { | if (ar->regiontype != RGN_TYPE_WINDOW) { | ||||
| return OPERATOR_CANCELLED; | return OPERATOR_CANCELLED; | ||||
| } | } | ||||
| 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 (!ED_fileselect_layout_is_inside_pt(sfile->layout, &ar->v2d, 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); | int numfiles = filelist_files_ensure(sfile->files); | ||||
| if ((idx >= 0) && (idx < numfiles)) { | if ((idx >= 0) && (idx < numfiles)) { | ||||
| ▲ Show 20 Lines • Show All 181 Lines • ▼ Show 20 Lines | static bool file_walk_select_do(bContext *C, | ||||
| 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 *** */ | ||||
| if (has_selection) { | if (has_selection) { | ||||
| ARegion *ar = CTX_wm_region(C); | ARegion *ar = CTX_wm_region(C); | ||||
| FileLayout *layout = ED_fileselect_get_layout(sfile, ar); | FileLayout *layout = ED_fileselect_get_layout(sfile, ar); | ||||
| const int idx_shift = (layout->flag & FILE_LAYOUT_HOR) ? layout->rows : layout->columns; | const int idx_shift = (layout->flag & FILE_LAYOUT_HOR) ? layout->rows : layout->flow_columns; | ||||
| if ((layout->flag & FILE_LAYOUT_HOR && direction == FILE_SELECT_WALK_UP) || | if ((layout->flag & FILE_LAYOUT_HOR && direction == FILE_SELECT_WALK_UP) || | ||||
| (layout->flag & FILE_LAYOUT_VER && direction == FILE_SELECT_WALK_LEFT)) { | (layout->flag & FILE_LAYOUT_VER && direction == FILE_SELECT_WALK_LEFT)) { | ||||
| active_new = active_old - 1; | active_new = active_old - 1; | ||||
| other_site = active_old + 1; | other_site = active_old + 1; | ||||
| } | } | ||||
| else if ((layout->flag & FILE_LAYOUT_HOR && direction == FILE_SELECT_WALK_DOWN) || | else if ((layout->flag & FILE_LAYOUT_HOR && direction == FILE_SELECT_WALK_DOWN) || | ||||
| (layout->flag & FILE_LAYOUT_VER && direction == FILE_SELECT_WALK_RIGHT)) { | (layout->flag & FILE_LAYOUT_VER && direction == FILE_SELECT_WALK_RIGHT)) { | ||||
| ▲ Show 20 Lines • Show All 477 Lines • ▼ Show 20 Lines | int file_highlight_set(SpaceFile *sfile, ARegion *ar, int mx, int my) | ||||
| numfiles = filelist_files_ensure(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 (ED_fileselect_layout_is_inside_pt(sfile->layout, v2d, mx, my)) { | ||||
| float fx, fy; | float fx, fy; | ||||
| int highlight_file; | int highlight_file; | ||||
| UI_view2d_region_to_view(v2d, mx, my, &fx, &fy); | UI_view2d_region_to_view(v2d, mx, my, &fx, &fy); | ||||
| highlight_file = ED_fileselect_layout_offset( | highlight_file = ED_fileselect_layout_offset( | ||||
| sfile->layout, (int)(v2d->tot.xmin + fx), (int)(v2d->tot.ymax - fy)); | sfile->layout, (int)(v2d->tot.xmin + fx), (int)(v2d->tot.ymax - fy)); | ||||
| Show All 32 Lines | void FILE_OT_highlight(struct wmOperatorType *ot) | ||||
| ot->description = "Highlight selected file(s)"; | ot->description = "Highlight selected file(s)"; | ||||
| ot->idname = "FILE_OT_highlight"; | ot->idname = "FILE_OT_highlight"; | ||||
| /* api callbacks */ | /* api callbacks */ | ||||
| ot->invoke = file_highlight_invoke; | ot->invoke = file_highlight_invoke; | ||||
| ot->poll = ED_operator_file_active; | ot->poll = ED_operator_file_active; | ||||
| } | } | ||||
| static int file_column_sort_ui_context_invoke(bContext *C, | |||||
| wmOperator *UNUSED(op), | |||||
| const wmEvent *event) | |||||
| { | |||||
| const ARegion *ar = CTX_wm_region(C); | |||||
| SpaceFile *sfile = CTX_wm_space_file(C); | |||||
| if (file_attribute_column_header_is_inside( | |||||
| &ar->v2d, sfile->layout, event->mval[0], event->mval[1])) { | |||||
| const FileAttributeColumnType column_type = file_attribute_column_type_find_isect( | |||||
| &ar->v2d, sfile->params, sfile->layout, event->mval[0]); | |||||
| if (column_type != COLUMN_NONE) { | |||||
| const FileAttributeColumn *column = &sfile->layout->attribute_columns[column_type]; | |||||
| if (column->sort_type != FILE_SORT_NONE) { | |||||
| if (sfile->params->sort == column->sort_type) { | |||||
| /* Already sorting by selected column -> toggle sort invert (three state logic). */ | |||||
| sfile->params->flag ^= FILE_SORT_INVERT; | |||||
| } | |||||
| else { | |||||
| sfile->params->sort = column->sort_type; | |||||
| sfile->params->flag &= ~FILE_SORT_INVERT; | |||||
| } | |||||
| WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_PARAMS, NULL); | |||||
| } | |||||
| } | |||||
| } | |||||
| return OPERATOR_PASS_THROUGH; | |||||
| } | |||||
| void FILE_OT_sort_column_ui_context(wmOperatorType *ot) | |||||
| { | |||||
| /* identifiers */ | |||||
| ot->name = "Sort from Column"; | |||||
| ot->description = "Change sorting to use column under cursor"; | |||||
| ot->idname = "FILE_OT_sort_column_ui_context"; | |||||
| /* api callbacks */ | |||||
| ot->invoke = file_column_sort_ui_context_invoke; | |||||
| ot->poll = ED_operator_file_active; | |||||
| ot->flag = OPTYPE_INTERNAL; | |||||
| } | |||||
| int file_cancel_exec(bContext *C, wmOperator *UNUSED(unused)) | int file_cancel_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); | ||||
| wmOperator *op = sfile->op; | wmOperator *op = sfile->op; | ||||
| sfile->op = NULL; | sfile->op = NULL; | ||||
| ▲ Show 20 Lines • Show All 463 Lines • ▼ Show 20 Lines | if (!ar || ar->regiontype != RGN_TYPE_WINDOW) { | ||||
| 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); | ||||
| sfile->smoothscroll_timer = NULL; | sfile->smoothscroll_timer = NULL; | ||||
| return OPERATOR_PASS_THROUGH; | return OPERATOR_PASS_THROUGH; | ||||
| } | } | ||||
| /* Number of items in a block (i.e. lines in a column in horizontal layout, or columns in a line | /* Number of items in a block (i.e. lines in a column in horizontal layout, or columns in a line | ||||
| * in vertical layout). | * in vertical layout). | ||||
| */ | */ | ||||
| const int items_block_size = is_horizontal ? sfile->layout->rows : sfile->layout->columns; | const int items_block_size = is_horizontal ? sfile->layout->rows : sfile->layout->flow_columns; | ||||
| /* Scroll offset is the first file in the row/column we are editing in. */ | /* Scroll offset is the first file in the row/column we are editing in. */ | ||||
| if (sfile->scroll_offset == 0) { | if (sfile->scroll_offset == 0) { | ||||
| sfile->scroll_offset = (edit_idx / items_block_size) * items_block_size; | sfile->scroll_offset = (edit_idx / items_block_size) * items_block_size; | ||||
| } | } | ||||
| const int numfiles_layout = ED_fileselect_layout_numfiles(sfile->layout, ar); | const int numfiles_layout = ED_fileselect_layout_numfiles(sfile->layout, ar); | ||||
| const int first_visible_item = ED_fileselect_layout_offset( | const int first_visible_item = ED_fileselect_layout_offset( | ||||
| ▲ Show 20 Lines • Show All 268 Lines • ▼ Show 20 Lines | void FILE_OT_directory_new(struct wmOperatorType *ot) | ||||
| PropertyRNA *prop; | PropertyRNA *prop; | ||||
| /* identifiers */ | /* identifiers */ | ||||
| ot->name = "Create New Directory"; | ot->name = "Create New Directory"; | ||||
| ot->description = "Create a new directory"; | ot->description = "Create a new directory"; | ||||
| ot->idname = "FILE_OT_directory_new"; | ot->idname = "FILE_OT_directory_new"; | ||||
| /* api callbacks */ | /* api callbacks */ | ||||
| ot->invoke = WM_operator_confirm; | |||||
| ot->exec = file_directory_new_exec; | ot->exec = file_directory_new_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 */ | ||||
| prop = RNA_def_string_dir_path( | prop = RNA_def_string_dir_path( | ||||
| ot->srna, "directory", NULL, FILE_MAX, "Directory", "Name of new directory"); | ot->srna, "directory", NULL, FILE_MAX, "Directory", "Name of new directory"); | ||||
| RNA_def_property_flag(prop, PROP_SKIP_SAVE); | RNA_def_property_flag(prop, PROP_SKIP_SAVE); | ||||
| prop = RNA_def_boolean(ot->srna, "open", false, "Open", "Open new directory"); | prop = RNA_def_boolean(ot->srna, "open", false, "Open", "Open new directory"); | ||||
| RNA_def_property_flag(prop, PROP_SKIP_SAVE); | RNA_def_property_flag(prop, PROP_SKIP_SAVE); | ||||
| ▲ Show 20 Lines • Show All 245 Lines • ▼ Show 20 Lines | if (ar == NULL) { | ||||
| return NULL; | return NULL; | ||||
| } | } | ||||
| arnew = MEM_callocN(sizeof(ARegion), "tools for file"); | arnew = MEM_callocN(sizeof(ARegion), "tools for file"); | ||||
| BLI_insertlinkafter(&sa->regionbase, ar, arnew); | BLI_insertlinkafter(&sa->regionbase, ar, arnew); | ||||
| arnew->regiontype = RGN_TYPE_TOOLS; | arnew->regiontype = RGN_TYPE_TOOLS; | ||||
| arnew->alignment = RGN_ALIGN_LEFT; | arnew->alignment = RGN_ALIGN_LEFT; | ||||
| ar = MEM_callocN(sizeof(ARegion), "tool props for file"); | return arnew; | ||||
| BLI_insertlinkafter(&sa->regionbase, arnew, ar); | } | ||||
| ar->regiontype = RGN_TYPE_TOOL_PROPS; | |||||
| ar->alignment = RGN_ALIGN_BOTTOM | RGN_SPLIT_PREV; | ARegion *file_tool_props_region(ScrArea *sa) | ||||
| { | |||||
| ARegion *ar, *arnew; | |||||
| if ((ar = BKE_area_find_region_type(sa, RGN_TYPE_TOOL_PROPS)) != NULL) { | |||||
| return ar; | |||||
| } | |||||
| /* add subdiv level; after execute region */ | |||||
| ar = BKE_area_find_region_type(sa, RGN_TYPE_EXECUTE); | |||||
| /* is error! */ | |||||
| if (ar == NULL) { | |||||
| return NULL; | |||||
| } | |||||
| arnew = MEM_callocN(sizeof(ARegion), "tool props for file"); | |||||
| BLI_insertlinkafter(&sa->regionbase, ar, arnew); | |||||
| arnew->regiontype = RGN_TYPE_TOOL_PROPS; | |||||
| arnew->alignment = RGN_ALIGN_RIGHT; | |||||
| return arnew; | return arnew; | ||||
| } | } | ||||
| static int file_bookmark_toggle_exec(bContext *C, wmOperator *UNUSED(unused)) | static int file_bookmark_toggle_exec(bContext *C, wmOperator *UNUSED(unused)) | ||||
| { | { | ||||
| ScrArea *sa = CTX_wm_area(C); | ScrArea *sa = CTX_wm_area(C); | ||||
| ARegion *ar = file_tools_region(sa); | ARegion *ar = file_tools_region(sa); | ||||
| Show All 12 Lines | void FILE_OT_bookmark_toggle(struct wmOperatorType *ot) | ||||
| ot->description = "Toggle bookmarks display"; | ot->description = "Toggle bookmarks display"; | ||||
| ot->idname = "FILE_OT_bookmark_toggle"; | ot->idname = "FILE_OT_bookmark_toggle"; | ||||
| /* api callbacks */ | /* api callbacks */ | ||||
| ot->exec = file_bookmark_toggle_exec; | ot->exec = file_bookmark_toggle_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 bool file_filenum_poll(bContext *C) | |||||
| { | |||||
| SpaceFile *sfile = CTX_wm_space_file(C); | |||||
| if (!ED_operator_file_active(C)) { | |||||
| return false; | |||||
| } | |||||
| return sfile->params && (sfile->params->action_type == FILE_SAVE); | |||||
| } | |||||
| /** | /** | ||||
| * Looks for a string of digits within name (using BLI_stringdec) and adjusts it by add. | * Looks for a string of digits within name (using BLI_stringdec) and adjusts it by add. | ||||
| */ | */ | ||||
| static void filenum_newname(char *name, size_t name_size, int add) | static void filenum_newname(char *name, size_t name_size, int add) | ||||
| { | { | ||||
| char head[FILE_MAXFILE], tail[FILE_MAXFILE]; | char head[FILE_MAXFILE], tail[FILE_MAXFILE]; | ||||
| char name_temp[FILE_MAXFILE]; | char name_temp[FILE_MAXFILE]; | ||||
| int pic; | int pic; | ||||
| ▲ Show 20 Lines • Show All 41 Lines • ▼ Show 20 Lines | |||||
| { | { | ||||
| /* identifiers */ | /* identifiers */ | ||||
| ot->name = "Increment Number in Filename"; | ot->name = "Increment Number in Filename"; | ||||
| ot->description = "Increment number in filename"; | ot->description = "Increment number in filename"; | ||||
| ot->idname = "FILE_OT_filenum"; | ot->idname = "FILE_OT_filenum"; | ||||
| /* api callbacks */ | /* api callbacks */ | ||||
| ot->exec = file_filenum_exec; | ot->exec = file_filenum_exec; | ||||
| ot->poll = ED_operator_file_active; /* <- important, handler is on window level */ | ot->poll = file_filenum_poll; | ||||
| /* props */ | /* props */ | ||||
| RNA_def_int(ot->srna, "increment", 1, -100, 100, "Increment", "", -100, 100); | RNA_def_int(ot->srna, "increment", 1, -100, 100, "Increment", "", -100, 100); | ||||
| } | } | ||||
| 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); | ||||
| ▲ Show 20 Lines • Show All 151 Lines • Show Last 20 Lines | |||||