diff options
author | Campbell Barton <ideasman42@gmail.com> | 2018-06-04 10:39:04 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2018-06-04 10:39:04 +0300 |
commit | 95011f6d484b369db92ae13c674a6522d664ea8f (patch) | |
tree | 91ba2719c9f3096fad0f1f768aa7b1c4d79aa32a /source/blender/editors/space_file | |
parent | 0911acb5cf49c5ba05b1df045b41697704aa288a (diff) | |
parent | 44505b38df557a5711703613685a1dec9fc2c3d9 (diff) |
Merge branch 'master' into blender2.8
Diffstat (limited to 'source/blender/editors/space_file')
-rw-r--r-- | source/blender/editors/space_file/file_draw.c | 24 | ||||
-rw-r--r-- | source/blender/editors/space_file/file_ops.c | 160 | ||||
-rw-r--r-- | source/blender/editors/space_file/filelist.c | 32 | ||||
-rw-r--r-- | source/blender/editors/space_file/filesel.c | 30 | ||||
-rw-r--r-- | source/blender/editors/space_file/fsmenu.c | 26 | ||||
-rw-r--r-- | source/blender/editors/space_file/fsmenu.h | 2 | ||||
-rw-r--r-- | source/blender/editors/space_file/space_file.c | 44 |
7 files changed, 159 insertions, 159 deletions
diff --git a/source/blender/editors/space_file/file_draw.c b/source/blender/editors/space_file/file_draw.c index 75763b53d7f..fcfe745546e 100644 --- a/source/blender/editors/space_file/file_draw.c +++ b/source/blender/editors/space_file/file_draw.c @@ -86,7 +86,7 @@ static char *file_draw_tooltip_func(bContext *UNUSED(C), void *argN, const char return BLI_strdup(dyn_tooltip); } -/* Note: This function uses pixelspace (0, 0, winx, winy), not view2d. +/* Note: This function uses pixelspace (0, 0, winx, winy), not view2d. * The controls are laid out as follows: * * ------------------------------------------- @@ -121,14 +121,14 @@ void file_draw_buttons(const bContext *C, ARegion *ar) int available_w = max_x - min_x; int line1_w = available_w; int line2_w = available_w; - + uiBut *but; uiBlock *block; SpaceFile *sfile = CTX_wm_space_file(C); FileSelectParams *params = ED_fileselect_get_params(sfile); ARegion *artmp; const bool is_browse_only = (sfile->op == NULL); - + /* Initialize UI block. */ BLI_snprintf(uiblockstr, sizeof(uiblockstr), "win %p", (void *)ar); block = UI_block_begin(C, ar, uiblockstr, UI_EMBOSS); @@ -212,11 +212,11 @@ void file_draw_buttons(const bContext *C, ARegion *ar) UI_but_flag_enable(but, UI_BUT_REDALERT); } } - + /* clear func */ UI_block_func_set(block, NULL, NULL, NULL); } - + /* Filename number increment / decrement buttons. */ if (fnumbuttons && (params->flag & FILE_DIRSEL_ONLY) == 0) { UI_block_align_begin(block); @@ -233,7 +233,7 @@ void file_draw_buttons(const bContext *C, ARegion *ar) RNA_int_set(UI_but_operator_ptr_get(but), "increment", 1); UI_block_align_end(block); } - + /* Execute / cancel buttons. */ if (loadbutton) { const struct FileDirEntry *file = sfile->files ? filelist_file(sfile->files, params->active_file) : NULL; @@ -254,7 +254,7 @@ void file_draw_buttons(const bContext *C, ARegion *ar) uiDefButO(block, UI_BTYPE_BUT, "FILE_OT_cancel", WM_OP_EXEC_REGION_WIN, IFACE_("Cancel"), max_x - loadbutton, line2_y, loadbutton, btn_h, ""); } - + UI_block_end(C, block); UI_block_draw(C, block); } @@ -274,10 +274,10 @@ static void file_draw_icon(uiBlock *block, const char *path, int sx, int sy, int uiBut *but; int x, y; // float alpha = 1.0f; - + x = sx; y = sy - height; - + /*if (icon == ICON_FILE_BLANK) alpha = 0.375f;*/ but = uiDefIconBut(block, UI_BTYPE_LABEL, 0, icon, x, y, width, height, NULL, 0.0f, 0.0f, 0.0f, 0.0f, NULL); @@ -323,7 +323,7 @@ void file_calc_previews(const bContext *C, ARegion *ar) { SpaceFile *sfile = CTX_wm_space_file(C); View2D *v2d = &ar->v2d; - + ED_fileselect_init_layout(sfile, ar); UI_view2d_totRect_set(v2d, sfile->layout->width, sfile->layout->height); } @@ -556,11 +556,11 @@ void file_draw_list(const bContext *C, ARegion *ar) const float thumb_icon_aspect = sqrtf(64.0f / (float)(params->thumbnail_size)); numfiles = filelist_files_ensure(files); - + if (params->display != FILE_IMGDISPLAY) { draw_background(layout, v2d); - + draw_dividers(layout, v2d); } diff --git a/source/blender/editors/space_file/file_ops.c b/source/blender/editors/space_file/file_ops.c index e5abab12c23..828cca53012 100644 --- a/source/blender/editors/space_file/file_ops.c +++ b/source/blender/editors/space_file/file_ops.c @@ -75,7 +75,7 @@ static FileSelection find_file_mouse_rect(SpaceFile *sfile, ARegion *ar, const rcti *rect_region) { FileSelection sel; - + View2D *v2d = &ar->v2d; rcti rect_view; rctf rect_view_fl; @@ -92,7 +92,7 @@ static FileSelection find_file_mouse_rect(SpaceFile *sfile, ARegion *ar, const r (int)(v2d->tot.ymax - rect_view_fl.ymax)); sel = ED_fileselect_layout_offset_rect(sfile->layout, &rect_view); - + return sel; } @@ -101,14 +101,14 @@ static void file_deselect_all(SpaceFile *sfile, unsigned int flag) FileSelection sel; sel.first = 0; sel.last = filelist_files_ensure(sfile->files) - 1; - + filelist_entries_select_index_range_set(sfile->files, &sel, FILE_SEL_REMOVE, flag, CHECK_ALL); } typedef enum FileSelect { FILE_SELECT_NOTHING = 0, - FILE_SELECT_DIR = 1, - FILE_SELECT_FILE = 2 + FILE_SELECT_DIR = 1, + FILE_SELECT_FILE = 2 } FileSelect; static void clamp_to_filelist(int numfiles, FileSelection *sel) @@ -122,7 +122,7 @@ static void clamp_to_filelist(int numfiles, FileSelection *sel) sel->first = -1; sel->last = -1; } - + /* fix if last file invalid */ if ( (sel->first > 0) && (sel->last < 0) ) sel->last = numfiles - 1; @@ -298,10 +298,10 @@ static FileSelect file_select(bContext *C, const rcti *rect, FileSelType select, 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_entries_select_index_range_set(sfile->files, &sel, select, FILE_SEL_SELECTED, check_type); - + /* Don't act on multiple selected files */ if (sel.first != sel.last) select = 0; @@ -333,7 +333,7 @@ static FileSelect file_select(bContext *C, const rcti *rect, FileSelType select, /* update operator for name change event */ file_draw_check(C); - + return retval; } @@ -460,7 +460,7 @@ void FILE_OT_select_border(wmOperatorType *ot) ot->name = "Activate/Select File"; ot->description = "Activate/select the file(s) contained in the border"; ot->idname = "FILE_OT_select_border"; - + /* api callbacks */ ot->invoke = WM_gesture_border_invoke; ot->exec = file_border_select_exec; @@ -529,7 +529,7 @@ void FILE_OT_select(wmOperatorType *ot) ot->name = "Activate/Select File"; ot->description = "Activate/select file"; ot->idname = "FILE_OT_select"; - + /* api callbacks */ ot->invoke = file_select_invoke; ot->poll = ED_operator_file_active; @@ -777,7 +777,7 @@ static int file_select_all_exec(bContext *C, wmOperator *UNUSED(op)) const int numfiles = filelist_files_ensure(sfile->files); const bool has_selection = file_is_any_selected(sfile->files); - sel.first = 0; + sel.first = 0; sel.last = numfiles - 1; /* select all only if previously no file was selected */ @@ -813,7 +813,7 @@ void FILE_OT_select_all_toggle(wmOperatorType *ot) ot->name = "(De)select All Files"; ot->description = "Select or deselect all files"; ot->idname = "FILE_OT_select_all_toggle"; - + /* api callbacks */ ot->exec = file_select_all_exec; ot->poll = ED_operator_file_active; @@ -840,7 +840,7 @@ static int bookmark_select_exec(bContext *C, wmOperator *op) WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_LIST, NULL); } - + return OPERATOR_FINISHED; } @@ -852,7 +852,7 @@ void FILE_OT_select_bookmark(wmOperatorType *ot) ot->name = "Select Directory"; ot->description = "Select a bookmarked directory"; ot->idname = "FILE_OT_select_bookmark"; - + /* api callbacks */ ot->exec = bookmark_select_exec; ot->poll = ED_operator_file_active; @@ -871,7 +871,7 @@ static int bookmark_add_exec(bContext *C, wmOperator *UNUSED(op)) if (params->dir[0] != '\0') { char name[FILE_MAX]; - + fsmenu_insert_entry(fsmenu, FS_CATEGORY_BOOKMARKS, params->dir, NULL, FS_INSERT_SAVE); BLI_make_file_string("/", name, BKE_appdir_folder_id_create(BLENDER_USER_CONFIG, NULL), BLENDER_BOOKMARK_FILE); fsmenu_write_file(fsmenu, name); @@ -888,7 +888,7 @@ void FILE_OT_bookmark_add(wmOperatorType *ot) ot->name = "Add Bookmark"; ot->description = "Add a bookmark for the selected/active directory"; ot->idname = "FILE_OT_bookmark_add"; - + /* api callbacks */ ot->exec = bookmark_add_exec; ot->poll = ED_operator_file_active; @@ -913,7 +913,7 @@ static int bookmark_delete_exec(bContext *C, wmOperator *op) } if ((index > -1) && (index < nentries)) { char name[FILE_MAX]; - + fsmenu_remove_entry(fsmenu, FS_CATEGORY_BOOKMARKS, index); BLI_make_file_string("/", name, BKE_appdir_folder_id_create(BLENDER_USER_CONFIG, NULL), BLENDER_BOOKMARK_FILE); fsmenu_write_file(fsmenu, name); @@ -933,7 +933,7 @@ void FILE_OT_bookmark_delete(wmOperatorType *ot) ot->name = "Delete Bookmark"; ot->description = "Delete selected bookmark"; ot->idname = "FILE_OT_bookmark_delete"; - + /* api callbacks */ ot->exec = bookmark_delete_exec; ot->poll = ED_operator_file_active; @@ -1080,7 +1080,7 @@ static int reset_recent_exec(bContext *C, wmOperator *UNUSED(op)) ScrArea *sa = CTX_wm_area(C); char name[FILE_MAX]; struct FSMenu *fsmenu = ED_fsmenu_get(); - + while (ED_fsmenu_get_entry(fsmenu, FS_CATEGORY_RECENT, 0) != NULL) { fsmenu_remove_entry(fsmenu, FS_CATEGORY_RECENT, 0); } @@ -1097,7 +1097,7 @@ void FILE_OT_reset_recent(wmOperatorType *ot) ot->name = "Reset Recent"; ot->description = "Reset Recent files"; ot->idname = "FILE_OT_reset_recent"; - + /* api callbacks */ ot->exec = reset_recent_exec; ot->poll = ED_operator_file_active; @@ -1148,7 +1148,7 @@ static int file_highlight_invoke(bContext *C, wmOperator *UNUSED(op), const wmEv return OPERATOR_CANCELLED; ED_area_tag_redraw(CTX_wm_area(C)); - + return OPERATOR_FINISHED; } @@ -1158,7 +1158,7 @@ void FILE_OT_highlight(struct wmOperatorType *ot) ot->name = "Highlight File"; ot->description = "Highlight selected file(s)"; ot->idname = "FILE_OT_highlight"; - + /* api callbacks */ ot->invoke = file_highlight_invoke; ot->poll = ED_operator_file_active; @@ -1169,11 +1169,11 @@ int file_cancel_exec(bContext *C, wmOperator *UNUSED(unused)) wmWindowManager *wm = CTX_wm_manager(C); SpaceFile *sfile = CTX_wm_space_file(C); wmOperator *op = sfile->op; - + sfile->op = NULL; WM_event_fileselect_event(wm, op, EVT_FILESELECT_CANCEL); - + return OPERATOR_FINISHED; } @@ -1193,7 +1193,7 @@ void FILE_OT_cancel(struct wmOperatorType *ot) ot->name = "Cancel File Load"; ot->description = "Cancel loading of selected file"; ot->idname = "FILE_OT_cancel"; - + /* api callbacks */ ot->exec = file_cancel_exec; ot->poll = file_operator_poll; @@ -1221,7 +1221,7 @@ void file_sfile_to_operator_ex(wmOperator *op, SpaceFile *sfile, char *filepath) if ((prop = RNA_struct_find_property(op->ptr, "filepath"))) { RNA_property_string_set(op->ptr, prop, filepath); } - + /* some ops have multiple files to select */ /* this is called on operators check() so clear collections first since * they may be already set. */ @@ -1259,7 +1259,7 @@ void file_sfile_to_operator_ex(wmOperator *op, SpaceFile *sfile, char *filepath) num_dirs++; } } - + /* make sure the directory specified in the button is added even if no directory selected */ if (0 == num_dirs) { RNA_property_collection_add(op->ptr, prop, &itemptr); @@ -1295,7 +1295,7 @@ void file_operator_to_sfile(SpaceFile *sfile, wmOperator *op) RNA_property_string_get(op->ptr, prop, sfile->params->dir); } } - + /* we could check for relative_path property which is used when converting * in the other direction but doesnt hurt to do this every time */ BLI_path_abs(sfile->params->dir, G.main->name); @@ -1331,11 +1331,11 @@ void file_draw_check(bContext *C) if (op) { /* fail on reload */ if (op->type->check) { file_sfile_to_operator(op, sfile); - + /* redraw */ if (op->type->check(C, op)) { file_operator_to_sfile(sfile, op); - + /* redraw, else the changed settings wont get updated */ ED_area_tag_redraw(CTX_wm_area(C)); } @@ -1394,13 +1394,13 @@ int file_exec(bContext *C, wmOperator *exec_op) /* opening file - sends events now, so things get handled on windowqueue level */ else if (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 */ if (RNA_boolean_get(exec_op->ptr, "need_active")) { const int numfiles = filelist_files_ensure(sfile->files); int i, active = 0; - + for (i = 0; i < numfiles; i++) { if (filelist_entry_select_index_get(sfile->files, i, CHECK_ALL)) { active = 1; @@ -1410,7 +1410,7 @@ int file_exec(bContext *C, wmOperator *exec_op) if (active == 0) return OPERATOR_CANCELLED; } - + sfile->op = NULL; file_sfile_to_operator_ex(op, sfile, filepath); @@ -1438,10 +1438,10 @@ void FILE_OT_execute(struct wmOperatorType *ot) ot->name = "Execute File Window"; ot->description = "Execute selected file"; ot->idname = "FILE_OT_execute"; - + /* api callbacks */ ot->exec = file_exec; - ot->poll = file_operator_poll; + ot->poll = file_operator_poll; /* properties */ prop = RNA_def_boolean(ot->srna, "need_active", 0, "Need Active", @@ -1453,7 +1453,7 @@ void FILE_OT_execute(struct wmOperatorType *ot) int file_parent_exec(bContext *C, wmOperator *UNUSED(unused)) { SpaceFile *sfile = CTX_wm_space_file(C); - + if (sfile->params) { if (BLI_parent_dir(sfile->params->dir)) { BLI_cleanup_dir(G.main->name, sfile->params->dir); @@ -1466,7 +1466,7 @@ int file_parent_exec(bContext *C, wmOperator *UNUSED(unused)) WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_LIST, NULL); } } - + return OPERATOR_FINISHED; } @@ -1478,7 +1478,7 @@ void FILE_OT_parent(struct wmOperatorType *ot) ot->name = "Parent File"; ot->description = "Move to parent directory"; ot->idname = "FILE_OT_parent"; - + /* api callbacks */ ot->exec = file_parent_exec; ot->poll = ED_operator_file_active; /* <- important, handler is on window level */ @@ -1509,7 +1509,7 @@ void FILE_OT_previous(struct wmOperatorType *ot) ot->name = "Previous Folder"; ot->description = "Move to previous folder"; ot->idname = "FILE_OT_previous"; - + /* api callbacks */ ot->exec = file_previous_exec; ot->poll = ED_operator_file_active; /* <- important, handler is on window level */ @@ -1540,7 +1540,7 @@ void FILE_OT_next(struct wmOperatorType *ot) ot->name = "Next Folder"; ot->description = "Move to next folder"; ot->idname = "FILE_OT_next"; - + /* api callbacks */ ot->exec = file_next_exec; ot->poll = ED_operator_file_active; /* <- important, handler is on window level */ @@ -1581,7 +1581,7 @@ static int file_smoothscroll_invoke(bContext *C, wmOperator *UNUSED(op), const w /* escape if not our timer */ if (sfile->smoothscroll_timer == NULL || sfile->smoothscroll_timer != event->customdata) return OPERATOR_PASS_THROUGH; - + numfiles = filelist_files_ensure(sfile->files); /* check if we are editing a name */ @@ -1621,9 +1621,9 @@ static int file_smoothscroll_invoke(bContext *C, wmOperator *UNUSED(op), const w if (sfile->scroll_offset <= offset) sfile->scroll_offset -= sfile->layout->columns; } } - + numfiles_layout = ED_fileselect_layout_numfiles(sfile->layout, ar); - + /* check if we have reached our final scroll position */ if ( (sfile->scroll_offset >= offset) && (sfile->scroll_offset < offset + numfiles_layout) ) { WM_event_remove_timer(CTX_wm_manager(C), CTX_wm_window(C), sfile->smoothscroll_timer); @@ -1631,10 +1631,10 @@ static int file_smoothscroll_invoke(bContext *C, wmOperator *UNUSED(op), const w return OPERATOR_FINISHED; } - /* temporarily set context to the main window region, + /* temporarily set context to the main window region, * so the scroll operators work */ CTX_wm_region_set(C, ar); - + /* scroll one step in the desired direction */ if (sfile->scroll_offset < offset) { if (sfile->layout->flag & FILE_LAYOUT_HOR) { @@ -1643,7 +1643,7 @@ static int file_smoothscroll_invoke(bContext *C, wmOperator *UNUSED(op), const w else { WM_operator_name_call(C, "VIEW2D_OT_scroll_up", 0, NULL); } - + } else { if (sfile->layout->flag & FILE_LAYOUT_HOR) { @@ -1653,27 +1653,27 @@ static int file_smoothscroll_invoke(bContext *C, wmOperator *UNUSED(op), const w WM_operator_name_call(C, "VIEW2D_OT_scroll_down", 0, NULL); } } - + ED_region_tag_redraw(ar); - + /* and restore context */ CTX_wm_region_set(C, oldar); - + return OPERATOR_FINISHED; } void FILE_OT_smoothscroll(wmOperatorType *ot) { - + /* identifiers */ ot->name = "Smooth Scroll"; ot->idname = "FILE_OT_smoothscroll"; ot->description = "Smooth scroll to make editable file visible"; - + /* api callbacks */ ot->invoke = file_smoothscroll_invoke; - + ot->poll = ED_operator_file_active; } @@ -1749,12 +1749,12 @@ int file_directory_new_exec(bContext *C, wmOperator *op) wmWindowManager *wm = CTX_wm_manager(C); SpaceFile *sfile = CTX_wm_space_file(C); ScrArea *sa = CTX_wm_area(C); - + if (!sfile->params) { BKE_report(op->reports, RPT_WARNING, "No parent directory given"); return OPERATOR_CANCELLED; } - + path[0] = '\0'; if ((prop = RNA_struct_find_property(op->ptr, "directory"))) { @@ -1824,7 +1824,7 @@ void FILE_OT_directory_new(struct wmOperatorType *ot) ot->name = "Create New Directory"; ot->description = "Create a new directory"; ot->idname = "FILE_OT_directory_new"; - + /* api callbacks */ ot->invoke = WM_operator_confirm; ot->exec = file_directory_new_exec; @@ -1841,7 +1841,7 @@ void FILE_OT_directory_new(struct wmOperatorType *ot) static void file_expand_directory(bContext *C) { SpaceFile *sfile = CTX_wm_space_file(C); - + if (sfile->params) { if (BLI_path_is_rel(sfile->params->dir)) { /* Use of 'default' folder here is just to avoid an error message on '//' prefix. */ @@ -1899,7 +1899,7 @@ static bool can_create_dir(const char *dir) void file_directory_enter_handle(bContext *C, void *UNUSED(arg_unused), void *UNUSED(arg_but)) { SpaceFile *sfile = CTX_wm_space_file(C); - + if (sfile->params) { file_expand_directory(C); @@ -1995,7 +1995,7 @@ void file_filename_enter_handle(bContext *C, void *UNUSED(arg_unused), void *arg if (matches) { /* replace the pattern (or filename that the user typed in, with the first selected file of the match */ BLI_strncpy(sfile->params->file, matched_file, sizeof(sfile->params->file)); - + WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_PARAMS, NULL); } @@ -2024,7 +2024,7 @@ void FILE_OT_refresh(struct wmOperatorType *ot) ot->name = "Refresh Filelist"; ot->description = "Refresh the file list"; ot->idname = "FILE_OT_refresh"; - + /* api callbacks */ ot->exec = file_refresh_exec; ot->poll = ED_operator_file_active; /* <- important, handler is on window level */ @@ -2035,13 +2035,13 @@ static int file_hidedot_exec(bContext *C, wmOperator *UNUSED(unused)) wmWindowManager *wm = CTX_wm_manager(C); SpaceFile *sfile = CTX_wm_space_file(C); ScrArea *sa = CTX_wm_area(C); - + if (sfile->params) { sfile->params->flag ^= FILE_HIDE_DOT; ED_fileselect_clear(wm, sa, sfile); WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_LIST, NULL); } - + return OPERATOR_FINISHED; } @@ -2052,7 +2052,7 @@ void FILE_OT_hidedot(struct wmOperatorType *ot) ot->name = "Toggle Hide Dot Files"; ot->description = "Toggle hide hidden dot files"; ot->idname = "FILE_OT_hidedot"; - + /* api callbacks */ ot->exec = file_hidedot_exec; ot->poll = ED_operator_file_active; /* <- important, handler is on window level */ @@ -2067,11 +2067,11 @@ ARegion *file_tools_region(ScrArea *sa) /* add subdiv level; after header */ ar = BKE_area_find_region_type(sa, RGN_TYPE_HEADER); - + /* is error! */ if (ar == NULL) return NULL; - + arnew = MEM_callocN(sizeof(ARegion), "tools for file"); BLI_insertlinkafter(&sa->regionbase, ar, arnew); arnew->regiontype = RGN_TYPE_TOOLS; @@ -2089,7 +2089,7 @@ static int file_bookmark_toggle_exec(bContext *C, wmOperator *UNUSED(unused)) { ScrArea *sa = CTX_wm_area(C); ARegion *ar = file_tools_region(sa); - + if (ar) ED_region_toggle_hidden(C, ar); @@ -2102,7 +2102,7 @@ void FILE_OT_bookmark_toggle(struct wmOperatorType *ot) ot->name = "Toggle Bookmarks"; ot->description = "Toggle bookmarks display"; ot->idname = "FILE_OT_bookmark_toggle"; - + /* api callbacks */ ot->exec = file_bookmark_toggle_exec; ot->poll = ED_operator_file_active; /* <- important, handler is on window level */ @@ -2144,7 +2144,7 @@ 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)) { filenum_newname(sfile->params->file, sizeof(sfile->params->file), inc); @@ -2152,7 +2152,7 @@ static int file_filenum_exec(bContext *C, wmOperator *op) file_draw_check(C); // WM_event_add_notifier(C, NC_WINDOW, NULL); } - + return OPERATOR_FINISHED; } @@ -2163,7 +2163,7 @@ void FILE_OT_filenum(struct wmOperatorType *ot) ot->name = "Increment Number in Filename"; ot->description = "Increment number in filename"; ot->idname = "FILE_OT_filenum"; - + /* api callbacks */ ot->exec = file_filenum_exec; ot->poll = ED_operator_file_active; /* <- important, handler is on window level */ @@ -2176,7 +2176,7 @@ static int file_rename_exec(bContext *C, wmOperator *UNUSED(op)) { ScrArea *sa = CTX_wm_area(C); SpaceFile *sfile = (SpaceFile *)CTX_wm_space_data(C); - + if (sfile->params) { int idx = sfile->params->highlight_file; int numfiles = filelist_files_ensure(sfile->files); @@ -2188,7 +2188,7 @@ static int file_rename_exec(bContext *C, wmOperator *UNUSED(op)) } ED_area_tag_redraw(sa); } - + return OPERATOR_FINISHED; } @@ -2232,10 +2232,10 @@ void FILE_OT_rename(struct wmOperatorType *ot) ot->name = "Rename File or Directory"; ot->description = "Rename file or file directory"; ot->idname = "FILE_OT_rename"; - + /* api callbacks */ ot->exec = file_rename_exec; - ot->poll = file_rename_poll; + ot->poll = file_rename_poll; } @@ -2262,7 +2262,7 @@ static int file_delete_poll(bContext *C) } else poll = 0; - + return poll; } @@ -2289,7 +2289,7 @@ int file_delete_exec(bContext *C, wmOperator *op) } } } - + if (report_error) { BKE_reportf(op->reports, RPT_ERROR, "Could not delete file: %s", @@ -2298,7 +2298,7 @@ int file_delete_exec(bContext *C, wmOperator *op) ED_fileselect_clear(wm, sa, sfile); WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_LIST, NULL); - + return OPERATOR_FINISHED; } @@ -2309,7 +2309,7 @@ void FILE_OT_delete(struct wmOperatorType *ot) ot->name = "Delete Selected Files"; ot->description = "Delete selected files"; ot->idname = "FILE_OT_delete"; - + /* api callbacks */ ot->invoke = WM_operator_confirm; ot->exec = file_delete_exec; @@ -2321,6 +2321,6 @@ void ED_operatormacros_file(void) { // wmOperatorType *ot; // wmOperatorTypeMacro *otmacro; - + /* future macros */ } diff --git a/source/blender/editors/space_file/filelist.c b/source/blender/editors/space_file/filelist.c index 343d09bd81c..c975479e402 100644 --- a/source/blender/editors/space_file/filelist.c +++ b/source/blender/editors/space_file/filelist.c @@ -43,7 +43,7 @@ #else # include <io.h> # include <direct.h> -#endif +#endif #include "MEM_guardedalloc.h" #include "BLI_blenlib.h" @@ -188,13 +188,13 @@ void folderlist_free(ListBase *folderlist) ListBase *folderlist_duplicate(ListBase *folderlist) { - + if (folderlist) { ListBase *folderlistn = MEM_callocN(sizeof(*folderlistn), __func__); FolderList *folder; - + BLI_duplicatelist(folderlistn, folderlist); - + for (folder = folderlistn->first; folder; folder = folder->next) { folder->foldername = MEM_dupallocN(folder->foldername); } @@ -404,7 +404,7 @@ static int compare_direntry_generic(const FileListInternEntry *entry1, const Fil if (FILENAME_IS_CURRENT(entry2->relpath)) return 1; if (FILENAME_IS_PARENT(entry1->relpath)) return -1; if (FILENAME_IS_PARENT(entry2->relpath)) return 1; - + return 0; } @@ -436,7 +436,7 @@ static int compare_date(void *UNUSED(user_data), const void *a1, const void *a2) if ((ret = compare_direntry_generic(entry1, entry2))) { return ret; } - + time1 = (int64_t)entry1->st.st_mtime; time2 = (int64_t)entry2->st.st_mtime; if (time1 < time2) return 1; @@ -459,7 +459,7 @@ static int compare_size(void *UNUSED(user_data), const void *a1, const void *a2) if ((ret = compare_direntry_generic(entry1, entry2))) { return ret; } - + size1 = entry1->st.st_size; size2 = entry2->st.st_size; if (size1 < size2) return 1; @@ -1347,7 +1347,7 @@ void filelist_free(struct FileList *filelist) printf("Attempting to delete empty filelist.\n"); return; } - + filelist_clear_ex(filelist, false, false); /* No need to clear cache & selection_state, we free them anyway. */ filelist_cache_free(&filelist->filelist_cache); @@ -1555,7 +1555,7 @@ FileDirEntry *filelist_file(struct FileList *filelist, int index) int filelist_file_findpath(struct FileList *filelist, const char *filename) { int fidx = -1; - + if (filelist->filelist.nbr_entries_filtered < 0) { return fidx; } @@ -1950,17 +1950,17 @@ static bool file_is_blend_backup(const char *str) } else { const char *loc; - + if (a > b + 1) b++; - + /* allow .blend1 .blend2 .blend32 */ loc = BLI_strcasestr(str + a - b, ".blend"); - + if (loc) retval = 1; } - + return (retval); } @@ -2024,7 +2024,7 @@ static int file_extension_type(const char *dir, const char *relpath) int ED_file_extension_icon(const char *path) { const int type = ED_path_extension_type(path); - + switch (type) { case FILE_TYPE_BLENDER: return ICON_FILE_BLEND; @@ -2319,7 +2319,7 @@ static void filelist_readjob_main_rec(struct FileList *filelist) FileDirEntry *files, *firstlib = NULL; ListBase *lb; int a, fake, idcode, ok, totlib, totbl; - + // filelist->type = FILE_MAIN; // XXX TODO: add modes to filebrowser BLI_assert(filelist->filelist.entries == NULL); @@ -2394,7 +2394,7 @@ static void filelist_readjob_main_rec(struct FileList *filelist) } files = filelist->filelist.entries; - + if (!(filelist->filter_data.flags & FLF_HIDE_PARENT)) { files->entry->relpath = BLI_strdup(FILENAME_PARENT); files->typeflag |= FILE_TYPE_DIR; diff --git a/source/blender/editors/space_file/filesel.c b/source/blender/editors/space_file/filesel.c index 6536dc77f77..9ba3c788daf 100644 --- a/source/blender/editors/space_file/filesel.c +++ b/source/blender/editors/space_file/filesel.c @@ -224,7 +224,7 @@ short ED_fileselect_set_params(SpaceFile *sfile) else { params->flag &= ~FILE_HIDE_DOT; } - + if (params->type == FILE_LOADLIB) { params->flag |= RNA_boolean_get(op->ptr, "link") ? FILE_LINK : 0; @@ -366,12 +366,12 @@ FileSelection ED_fileselect_layout_offset_rect(FileLayout *layout, const rcti *r if (layout == NULL) return sel; - + colmin = (rect->xmin) / (layout->tile_w + 2 * layout->tile_border_x); rowmin = (rect->ymin) / (layout->tile_h + 2 * layout->tile_border_y); colmax = (rect->xmax) / (layout->tile_w + 2 * layout->tile_border_x); rowmax = (rect->ymax) / (layout->tile_h + 2 * layout->tile_border_y); - + if (is_inside(colmin, rowmin, layout->columns, layout->rows) || is_inside(colmax, rowmax, layout->columns, layout->rows) ) { @@ -380,12 +380,12 @@ FileSelection ED_fileselect_layout_offset_rect(FileLayout *layout, const rcti *r CLAMP(colmax, 0, layout->columns - 1); CLAMP(rowmax, 0, layout->rows - 1); } - + if ((colmin > layout->columns - 1) || (rowmin > layout->rows - 1)) { sel.first = -1; } else { - if (layout->flag & FILE_LAYOUT_HOR) + if (layout->flag & FILE_LAYOUT_HOR) sel.first = layout->rows * colmin + rowmin; else sel.first = colmin + layout->columns * rowmin; @@ -394,7 +394,7 @@ FileSelection ED_fileselect_layout_offset_rect(FileLayout *layout, const rcti *r sel.last = -1; } else { - if (layout->flag & FILE_LAYOUT_HOR) + if (layout->flag & FILE_LAYOUT_HOR) sel.last = layout->rows * colmax + rowmax; else sel.last = colmax + layout->columns * rowmax; @@ -410,14 +410,14 @@ int ED_fileselect_layout_offset(FileLayout *layout, int x, int y) if (layout == NULL) return -1; - + offsetx = (x) / (layout->tile_w + 2 * layout->tile_border_x); offsety = (y) / (layout->tile_h + 2 * layout->tile_border_y); - + if (offsetx > layout->columns - 1) return -1; if (offsety > layout->rows - 1) return -1; - - if (layout->flag & FILE_LAYOUT_HOR) + + if (layout->flag & FILE_LAYOUT_HOR) active_file = layout->rows * offsetx + offsety; else active_file = offsetx + layout->columns * offsety; @@ -611,12 +611,12 @@ void ED_file_change_dir(bContext *C) int file_select_match(struct SpaceFile *sfile, const char *pattern, char *matched_file) { int match = 0; - + int i; FileDirEntry *file; int n = filelist_files_ensure(sfile->files); - /* select any file that matches the pattern, this includes exact match + /* select any file that matches the pattern, this includes exact match * if the user selects a single file by entering the filename */ for (i = 0; i < n; i++) { @@ -645,7 +645,7 @@ int autocomplete_directory(struct bContext *C, char *str, void *UNUSED(arg_v)) DIR *dir; struct dirent *de; - + BLI_split_dir_part(str, dirname, sizeof(dirname)); dir = opendir(dirname); @@ -660,7 +660,7 @@ int autocomplete_directory(struct bContext *C, char *str, void *UNUSED(arg_v)) else { char path[FILE_MAX]; BLI_stat_t status; - + BLI_join_dirfile(path, sizeof(path), dirname, de->d_name); if (BLI_stat(path, &status) == 0) { @@ -726,7 +726,7 @@ void ED_fileselect_exit(wmWindowManager *wm, ScrArea *sa, SpaceFile *sfile) folderlist_free(sfile->folders_prev); folderlist_free(sfile->folders_next); - + if (sfile->files) { ED_fileselect_clear(wm, sa, sfile); filelist_free(sfile->files); diff --git a/source/blender/editors/space_file/fsmenu.c b/source/blender/editors/space_file/fsmenu.c index ea251f2018c..5ecb95bf61b 100644 --- a/source/blender/editors/space_file/fsmenu.c +++ b/source/blender/editors/space_file/fsmenu.c @@ -350,7 +350,7 @@ void fsmenu_remove_entry(struct FSMenu *fsmenu, FSMenuCategory category, int idx idx--; if (fsm_iter) { - /* you should only be able to remove entries that were + /* you should only be able to remove entries that were * not added by default, like windows drives. * also separators (where path == NULL) shouldn't be removed */ if (fsm_iter->save && fsm_iter->path) { @@ -510,18 +510,18 @@ void fsmenu_read_system(struct FSMenu *fsmenu, int read_bookmarks) /* Get mounted volumes better method OSX 10.6 and higher, see: */ /*https://developer.apple.com/library/mac/#documentation/CoreFOundation/Reference/CFURLRef/Reference/reference.html*/ /* we get all volumes sorted including network and do not relay on user-defined finder visibility, less confusing */ - + CFURLRef cfURL = NULL; CFURLEnumeratorResult result = kCFURLEnumeratorSuccess; CFURLEnumeratorRef volEnum = CFURLEnumeratorCreateForMountedVolumes(NULL, kCFURLEnumeratorSkipInvisibles, NULL); - + while (result != kCFURLEnumeratorEnd) { char defPath[FILE_MAX]; result = CFURLEnumeratorGetNextURL(volEnum, &cfURL, NULL); if (result != kCFURLEnumeratorSuccess) continue; - + CFURLGetFileSystemRepresentation(cfURL, false, (UInt8 *)defPath, FILE_MAX); /* Add end slash for consistency with other platforms */ @@ -529,29 +529,29 @@ void fsmenu_read_system(struct FSMenu *fsmenu, int read_bookmarks) fsmenu_insert_entry(fsmenu, FS_CATEGORY_SYSTEM, defPath, NULL, FS_INSERT_SORTED); } - + CFRelease(volEnum); - + /* Finally get user favorite places */ if (read_bookmarks) { UInt32 seed; LSSharedFileListRef list = LSSharedFileListCreate(NULL, kLSSharedFileListFavoriteItems, NULL); CFArrayRef pathesArray = LSSharedFileListCopySnapshot(list, &seed); CFIndex pathesCount = CFArrayGetCount(pathesArray); - + for (CFIndex i = 0; i < pathesCount; i++) { LSSharedFileListItemRef itemRef = (LSSharedFileListItemRef)CFArrayGetValueAtIndex(pathesArray, i); - + CFURLRef cfURL = NULL; - OSErr err = LSSharedFileListItemResolve(itemRef, + OSErr err = LSSharedFileListItemResolve(itemRef, kLSSharedFileListNoUserInteraction | kLSSharedFileListDoNotMountVolumes, &cfURL, NULL); if (err != noErr || !cfURL) continue; - + CFStringRef pathString = CFURLCopyFileSystemPath(cfURL, kCFURLPOSIXPathStyle); - + if (pathString == NULL || !CFStringGetCString(pathString, line, sizeof(line), kCFStringEncodingUTF8)) continue; @@ -563,11 +563,11 @@ void fsmenu_read_system(struct FSMenu *fsmenu, int read_bookmarks) if (!strstr(line, "myDocuments.cannedSearch") && (*line != '\0')) { fsmenu_insert_entry(fsmenu, FS_CATEGORY_SYSTEM_BOOKMARKS, line, NULL, FS_INSERT_LAST); } - + CFRelease(pathString); CFRelease(cfURL); } - + CFRelease(pathesArray); CFRelease(list); } diff --git a/source/blender/editors/space_file/fsmenu.h b/source/blender/editors/space_file/fsmenu.h index 83ce4776a66..85804538e19 100644 --- a/source/blender/editors/space_file/fsmenu.h +++ b/source/blender/editors/space_file/fsmenu.h @@ -60,7 +60,7 @@ void fsmenu_remove_entry(struct FSMenu *fsmenu, enum FSMenuCategory category, /** saves the 'bookmarks' to the specified file */ void fsmenu_write_file(struct FSMenu *fsmenu, const char *filename); - + /** reads the 'bookmarks' from the specified file */ void fsmenu_read_bookmarks(struct FSMenu *fsmenu, const char *filename); diff --git a/source/blender/editors/space_file/space_file.c b/source/blender/editors/space_file/space_file.c index c647ec78270..62e7c7923e8 100644 --- a/source/blender/editors/space_file/space_file.c +++ b/source/blender/editors/space_file/space_file.c @@ -115,9 +115,9 @@ static SpaceLink *file_new(const ScrArea *UNUSED(area), const Scene *UNUSED(scen /* not spacelink itself */ static void file_free(SpaceLink *sl) -{ +{ SpaceFile *sfile = (SpaceFile *) sl; - + BLI_assert(sfile->previews_timer == NULL); if (sfile->files) { @@ -185,7 +185,7 @@ static SpaceLink *file_duplicate(SpaceLink *sl) { SpaceFile *sfileo = (SpaceFile *)sl; SpaceFile *sfilen = MEM_dupallocN(sl); - + /* clear or remove stuff from old */ sfilen->op = NULL; /* file window doesn't own operators */ @@ -203,7 +203,7 @@ static SpaceLink *file_duplicate(SpaceLink *sl) if (sfileo->folders_next) sfilen->folders_next = folderlist_duplicate(sfileo->folders_next); - + if (sfileo->layout) { sfilen->layout = MEM_dupallocN(sfileo->layout); } @@ -326,9 +326,9 @@ static void file_listener(bScreen *UNUSED(sc), ScrArea *sa, wmNotifier *wmn, Sce static void file_main_region_init(wmWindowManager *wm, ARegion *ar) { wmKeyMap *keymap; - + UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_LIST, ar->winx, ar->winy); - + /* own keymaps */ keymap = WM_keymap_find(wm->defaultconf, "File Browser", SPACE_FILE, 0); WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); @@ -410,9 +410,9 @@ static void file_main_region_draw(const bContext *C, ARegion *ar) UI_GetThemeColor3fv(TH_BACK, col); glClearColor(col[0], col[1], col[2], 0.0); glClear(GL_COLOR_BUFFER_BIT); - + /* Allow dynamically sliders to be set, saves notifiers etc. */ - + if (params->display == FILE_IMGDISPLAY) { v2d->scroll = V2D_SCROLL_RIGHT; v2d->keepofs &= ~V2D_LOCKOFS_Y; @@ -422,7 +422,7 @@ static void file_main_region_draw(const bContext *C, ARegion *ar) v2d->scroll = V2D_SCROLL_BOTTOM; v2d->keepofs &= ~V2D_LOCKOFS_X; v2d->keepofs |= V2D_LOCKOFS_Y; - + /* XXX this happens on scaling down Screen (like from startup.blend) */ /* view2d has no type specific for filewindow case, which doesnt scroll vertically */ if (v2d->cur.ymax < 0) { @@ -438,18 +438,18 @@ static void file_main_region_draw(const bContext *C, ARegion *ar) /* set view */ UI_view2d_view_ortho(v2d); - + /* on first read, find active file */ if (params->highlight_file == -1) { wmEvent *event = CTX_wm_window(C)->eventstate; file_highlight_set(sfile, ar, event->x, event->y); } - + file_draw_list(C, ar); - + /* reset view matrix */ UI_view2d_view_restore(C); - + /* scrollers */ scrollers = UI_view2d_scrollers_calc(C, v2d, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY); UI_view2d_scrollers_draw(C, v2d, scrollers); @@ -603,8 +603,8 @@ static void file_keymap(struct wmKeyConfig *keyconf) RNA_int_set(kmi->ptr, "increment", -10); kmi = WM_keymap_add_item(keymap, "FILE_OT_filenum", PADMINUS, KM_PRESS, KM_CTRL, 0); RNA_int_set(kmi->ptr, "increment", -100); - - + + /* keys for button region (top) */ keymap = WM_keymap_find(keyconf, "File Browser Buttons", SPACE_FILE, 0); kmi = WM_keymap_add_item(keymap, "FILE_OT_filenum", PADPLUSKEY, KM_PRESS, 0, 0); @@ -655,9 +655,9 @@ static void file_tools_region_listener( static void file_header_region_init(wmWindowManager *wm, ARegion *ar) { wmKeyMap *keymap; - + ED_region_header_init(ar); - + keymap = WM_keymap_find(wm->defaultconf, "File Browser", SPACE_FILE, 0); WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); } @@ -748,10 +748,10 @@ void ED_spacetype_file(void) { SpaceType *st = MEM_callocN(sizeof(SpaceType), "spacetype file"); ARegionType *art; - + st->spaceid = SPACE_FILE; strncpy(st->name, "File", BKE_ST_MAXNAME); - + st->new = file_new; st->free = file_free; st->init = file_init; @@ -772,7 +772,7 @@ void ED_spacetype_file(void) art->message_subscribe = file_main_region_message_subscribe; art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D; BLI_addhead(&st->regiontypes, art); - + /* regions: header */ art = MEM_callocN(sizeof(ARegionType), "spacetype file region"); art->regionid = RGN_TYPE_HEADER; @@ -782,7 +782,7 @@ void ED_spacetype_file(void) art->draw = file_header_region_draw; // art->listener = file_header_region_listener; BLI_addhead(&st->regiontypes, art); - + /* regions: ui */ art = MEM_callocN(sizeof(ARegionType), "spacetype file region"); art->regionid = RGN_TYPE_UI; @@ -843,7 +843,7 @@ void ED_file_exit(void) void ED_file_read_bookmarks(void) { const char * const cfgdir = BKE_appdir_folder_id(BLENDER_USER_CONFIG, NULL); - + fsmenu_free(); fsmenu_read_system(ED_fsmenu_get(), true); |