diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-03-24 10:38:07 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-03-24 10:38:07 +0400 |
commit | ab4a2aaf4a4b2b4e416aa1f113b30362cbe0dec3 (patch) | |
tree | 81af4c18519181490074508dbe9a8d515eab634f /source/blender/editors/space_file | |
parent | 5a90ea77bc1333efe4e1e54984a080550ed3f707 (diff) |
style cleanup: follow style guide for formatting of if/for/while loops, and else if's
Diffstat (limited to 'source/blender/editors/space_file')
-rw-r--r-- | source/blender/editors/space_file/file_draw.c | 28 | ||||
-rw-r--r-- | source/blender/editors/space_file/file_ops.c | 122 | ||||
-rw-r--r-- | source/blender/editors/space_file/file_panels.c | 16 | ||||
-rw-r--r-- | source/blender/editors/space_file/filelist.c | 246 | ||||
-rw-r--r-- | source/blender/editors/space_file/filesel.c | 90 | ||||
-rw-r--r-- | source/blender/editors/space_file/fsmenu.c | 27 | ||||
-rw-r--r-- | source/blender/editors/space_file/space_file.c | 33 |
7 files changed, 316 insertions, 246 deletions
diff --git a/source/blender/editors/space_file/file_draw.c b/source/blender/editors/space_file/file_draw.c index 1faa69d60e0..4d764bff311 100644 --- a/source/blender/editors/space_file/file_draw.c +++ b/source/blender/editors/space_file/file_draw.c @@ -157,7 +157,8 @@ void file_draw_buttons(const bContext *C, ARegion *ar) if (available_w <= loadbutton + separator + input_minw || params->title[0] == 0) { loadbutton = 0; - } else { + } + else { line1_w -= (loadbutton + separator); line2_w = line1_w; } @@ -166,7 +167,8 @@ void file_draw_buttons(const bContext *C, ARegion *ar) fnumbuttons = 2 * btn_fn_w; if (!loadbutton || line2_w <= fnumbuttons + separator + input_minw) { fnumbuttons = 0; - } else { + } + else { line2_w -= (fnumbuttons + separator); } @@ -183,7 +185,7 @@ void file_draw_buttons(const bContext *C, ARegion *ar) uiButSetCompleteFunc(but, autocomplete_directory, NULL); uiButSetFlag(but, UI_BUT_NO_UTF8); - if((params->flag & FILE_DIRSEL_ONLY) == 0) { + if ((params->flag & FILE_DIRSEL_ONLY) == 0) { but = uiDefBut(block, TEX, B_FS_FILENAME, "", min_x, line2_y, line2_w-chan_offs, btn_h, params->file, 0.0, (float)FILE_MAXFILE, 0, 0, @@ -193,7 +195,7 @@ void file_draw_buttons(const bContext *C, ARegion *ar) uiButClearFlag(but, UI_BUT_UNDO); /* operator button above does this automatic */ /* check if this overrides a file and if the operator option is used */ - if(overwrite_alert) { + if (overwrite_alert) { uiButSetFlag(but, UI_BUT_REDALERT); } } @@ -220,7 +222,7 @@ void file_draw_buttons(const bContext *C, ARegion *ar) } /* Execute / cancel buttons. */ - if(loadbutton) { + if (loadbutton) { uiDefButO(block, BUT, "FILE_OT_execute", WM_OP_EXEC_REGION_WIN, IFACE_(params->title), max_x - loadbutton, line1_y, loadbutton, btn_h, TIP_(params->title)); @@ -247,7 +249,7 @@ static int get_file_icon(struct direntry *file) if ( strcmp(file->relname, "..") == 0) { return ICON_FILE_PARENT; } - if(file->flags & BLENDERFILE) { + if (file->flags & BLENDERFILE) { return ICON_FILE_BLEND; } return ICON_FILE_FOLDER; @@ -343,7 +345,8 @@ static void file_draw_preview(uiBlock *block, struct direntry *file, int sx, int scaledx = ( (float)imb->x/(float)imb->y )*layout->prv_h; scale = scaledy/imb->y; } - } else { + } + else { scaledx = (float)imb->x; scaledy = (float)imb->y; scale = 1.0; @@ -396,7 +399,7 @@ static void renamebutton_cb(bContext *C, void *UNUSED(arg1), char *oldname) BLI_strncpy(filename, sfile->params->renameedit, sizeof(filename)); BLI_make_file_string(G.main->name, newname, sfile->params->dir, filename); - if( strcmp(orgname, newname) != 0 ) { + if ( strcmp(orgname, newname) != 0 ) { if (!BLI_exists(newname)) { BLI_rename(orgname, newname); /* to make sure we show what is on disk */ @@ -477,7 +480,8 @@ void file_draw_list(const bContext *C, ARegion *ar) /* adjust, so the next row is already drawn when scrolling */ if (layout->flag & FILE_LAYOUT_HOR) { numfiles_layout += layout->rows; - } else { + } + else { numfiles_layout += layout->columns; } @@ -515,7 +519,8 @@ void file_draw_list(const bContext *C, ARegion *ar) } file_draw_preview(block, file, sx, sy, imb, layout, !is_icon && (file->flags & IMAGEFILE)); - } else { + } + else { file_draw_icon(block, file->path, sx, sy-(UI_UNIT_Y / 6), get_file_icon(file), ICON_DEFAULT_WIDTH_SCALE, ICON_DEFAULT_HEIGHT_SCALE); sx += ICON_DEFAULT_WIDTH_SCALE + 4; } @@ -544,7 +549,8 @@ void file_draw_list(const bContext *C, ARegion *ar) file_draw_string(sx, sy, file->size, layout->column_widths[COLUMN_SIZE], layout->tile_h, align); sx += (int)layout->column_widths[COLUMN_SIZE] + 12; } - } else if (params->display == FILE_LONGDISPLAY) { + } + else if (params->display == FILE_LONGDISPLAY) { sx += (int)layout->column_widths[COLUMN_NAME] + 12; #ifndef WIN32 diff --git a/source/blender/editors/space_file/file_ops.c b/source/blender/editors/space_file/file_ops.c index 269a3a8fa0d..62b7aafb187 100644 --- a/source/blender/editors/space_file/file_ops.c +++ b/source/blender/editors/space_file/file_ops.c @@ -170,7 +170,7 @@ static FileSelect file_select_do(bContext* C, int selected_idx) { params->active_file = selected_idx; - if(S_ISDIR(file->type)) { + if (S_ISDIR(file->type)) { /* the path is too long and we are not going up! */ if (strcmp(file->relname, "..") && strlen(params->dir) + strlen(file->relname) >= FILE_MAX ) { // XXX error("Path too long, cannot enter this directory"); @@ -240,7 +240,7 @@ static int file_border_select_modal(bContext *C, wmOperator *op, wmEvent *event) result= WM_border_select_modal(C, op, event); - if(result==OPERATOR_RUNNING_MODAL) { + if (result==OPERATOR_RUNNING_MODAL) { rect.xmin = RNA_int_get(op->ptr, "xmin"); rect.ymin = RNA_int_get(op->ptr, "ymin"); @@ -257,7 +257,8 @@ static int file_border_select_modal(bContext *C, wmOperator *op, wmEvent *event) } params->sel_first = sel.first; params->sel_last = sel.last; - }else { + } + else { params->active_file = -1; params->sel_first = params->sel_last = -1; file_deselect_all(sfile, HILITED_FILE); @@ -280,7 +281,7 @@ static int file_border_select_exec(bContext *C, wmOperator *op) rect.xmax = RNA_int_get(op->ptr, "xmax"); rect.ymax = RNA_int_get(op->ptr, "ymax"); - if(!extend) { + if (!extend) { SpaceFile *sfile= CTX_wm_space_file(C); file_deselect_all(sfile, SELECTED_FILE); @@ -291,7 +292,8 @@ static int file_border_select_exec(bContext *C, wmOperator *op) ret = file_select(C, &rect, select ? FILE_SEL_ADD : FILE_SEL_REMOVE, 0); if (FILE_SELECT_DIR == ret) { WM_event_add_notifier(C, NC_SPACE|ND_SPACE_FILE_LIST, NULL); - } else if (FILE_SELECT_FILE == ret) { + } + else if (FILE_SELECT_FILE == ret) { WM_event_add_notifier(C, NC_SPACE|ND_SPACE_FILE_PARAMS, NULL); } return OPERATOR_FINISHED; @@ -324,13 +326,13 @@ static int file_select_invoke(bContext *C, wmOperator *op, wmEvent *event) int extend = RNA_boolean_get(op->ptr, "extend"); int fill = RNA_boolean_get(op->ptr, "fill"); - if(ar->regiontype != RGN_TYPE_WINDOW) + if (ar->regiontype != RGN_TYPE_WINDOW) return OPERATOR_CANCELLED; rect.xmin = rect.xmax = event->mval[0]; rect.ymin = rect.ymax = event->mval[1]; - if(!BLI_in_rcti(&ar->v2d.mask, rect.xmin, rect.ymin)) + if (!BLI_in_rcti(&ar->v2d.mask, rect.xmin, rect.ymin)) return OPERATOR_CANCELLED; /* single select, deselect all selected first */ @@ -417,7 +419,7 @@ static int bookmark_select_exec(bContext *C, wmOperator *op) { SpaceFile *sfile= CTX_wm_space_file(C); - if(RNA_struct_find_property(op->ptr, "dir")) { + if (RNA_struct_find_property(op->ptr, "dir")) { char entry[256]; FileSelectParams* params = sfile->params; @@ -483,7 +485,7 @@ static int bookmark_delete_exec(bContext *C, wmOperator *op) struct FSMenu* fsmenu = fsmenu_get(); int nentries = fsmenu_get_nentries(fsmenu, FS_CATEGORY_BOOKMARKS); - if(RNA_struct_find_property(op->ptr, "index")) { + if (RNA_struct_find_property(op->ptr, "index")) { int index = RNA_int_get(op->ptr, "index"); if ( (index >-1) && (index < nentries)) { char name[FILE_MAX]; @@ -518,7 +520,7 @@ int file_hilight_set(SpaceFile *sfile, ARegion *ar, int mx, int my) FileSelectParams* params; int numfiles, origfile; - if(sfile==NULL || sfile->files==NULL) return 0; + if (sfile==NULL || sfile->files==NULL) return 0; numfiles = filelist_numfiles(sfile->files); params = ED_fileselect_get_params(sfile); @@ -528,7 +530,7 @@ int file_hilight_set(SpaceFile *sfile, ARegion *ar, int mx, int my) mx -= ar->winrct.xmin; my -= ar->winrct.ymin; - if(BLI_in_rcti(&ar->v2d.mask, mx, my)) { + if (BLI_in_rcti(&ar->v2d.mask, mx, my)) { float fx, fy; int active_file; @@ -536,7 +538,7 @@ int file_hilight_set(SpaceFile *sfile, ARegion *ar, int mx, int my) active_file = ED_fileselect_layout_offset(sfile->layout, (int)(v2d->tot.xmin + fx), (int)(v2d->tot.ymax - fy)); - if((active_file >= 0) && (active_file < numfiles)) + if ((active_file >= 0) && (active_file < numfiles)) params->active_file=active_file; else params->active_file= -1; @@ -552,7 +554,7 @@ static int file_highlight_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *e ARegion *ar= CTX_wm_region(C); SpaceFile *sfile= CTX_wm_space_file(C); - if(!file_hilight_set(sfile, ar, event->x, event->y)) + if (!file_hilight_set(sfile, ar, event->x, event->y)) return OPERATOR_CANCELLED; ED_area_tag_redraw(CTX_wm_area(C)); @@ -610,19 +612,19 @@ void FILE_OT_cancel(struct wmOperatorType *ot) void file_sfile_to_operator(wmOperator *op, SpaceFile *sfile, char *filepath) { BLI_join_dirfile(filepath, FILE_MAX, sfile->params->dir, sfile->params->file); /* XXX, not real length */ - if(RNA_struct_find_property(op->ptr, "relative_path")) { - if(RNA_boolean_get(op->ptr, "relative_path")) { + if (RNA_struct_find_property(op->ptr, "relative_path")) { + if (RNA_boolean_get(op->ptr, "relative_path")) { BLI_path_rel(filepath, G.main->name); } } - if(RNA_struct_find_property(op->ptr, "filename")) { + if (RNA_struct_find_property(op->ptr, "filename")) { RNA_string_set(op->ptr, "filename", sfile->params->file); } - if(RNA_struct_find_property(op->ptr, "directory")) { + if (RNA_struct_find_property(op->ptr, "directory")) { RNA_string_set(op->ptr, "directory", sfile->params->dir); } - if(RNA_struct_find_property(op->ptr, "filepath")) { + if (RNA_struct_find_property(op->ptr, "filepath")) { RNA_string_set(op->ptr, "filepath", filepath); } @@ -635,7 +637,7 @@ void file_sfile_to_operator(wmOperator *op, SpaceFile *sfile, char *filepath) PropertyRNA *prop_dirs= RNA_struct_find_property(op->ptr, "dirs"); int i, numfiles = filelist_numfiles(sfile->files); - if(prop_files) { + if (prop_files) { RNA_property_collection_clear(op->ptr, prop_files); for (i=0; i<numfiles; i++) { if (filelist_is_selected(sfile->files, i, CHECK_FILES)) { @@ -646,7 +648,7 @@ void file_sfile_to_operator(wmOperator *op, SpaceFile *sfile, char *filepath) } } - if(prop_dirs) { + if (prop_dirs) { RNA_property_collection_clear(op->ptr, prop_dirs); for (i=0; i<numfiles; i++) { if (filelist_is_selected(sfile->files, i, CHECK_DIRS)) { @@ -666,16 +668,16 @@ void file_operator_to_sfile(SpaceFile *sfile, wmOperator *op) PropertyRNA *prop; /* If neither of the above are set, split the filepath back */ - if((prop= RNA_struct_find_property(op->ptr, "filepath"))) { + if ((prop= RNA_struct_find_property(op->ptr, "filepath"))) { char filepath[FILE_MAX]; RNA_property_string_get(op->ptr, prop, filepath); BLI_split_dirfile(filepath, sfile->params->dir, sfile->params->file, sizeof(sfile->params->dir), sizeof(sfile->params->file)); } else { - if((prop= RNA_struct_find_property(op->ptr, "filename"))) { + if ((prop= RNA_struct_find_property(op->ptr, "filename"))) { RNA_property_string_get(op->ptr, prop, sfile->params->file); } - if((prop= RNA_struct_find_property(op->ptr, "directory"))) { + if ((prop= RNA_struct_find_property(op->ptr, "directory"))) { RNA_property_string_get(op->ptr, prop, sfile->params->dir); } } @@ -691,13 +693,13 @@ void file_draw_check_cb(bContext *C, void *UNUSED(arg1), void *UNUSED(arg2)) { SpaceFile *sfile= CTX_wm_space_file(C); wmOperator *op= sfile->op; - if(op) { /* fail on reload */ - if(op->type->check) { + if (op) { /* fail on reload */ + if (op->type->check) { char filepath[FILE_MAX]; file_sfile_to_operator(op, sfile, filepath); /* redraw */ - if(op->type->check(C, op)) { + if (op->type->check(C, op)) { file_operator_to_sfile(sfile, op); /* redraw, else the changed settings wont get updated */ @@ -709,12 +711,12 @@ void file_draw_check_cb(bContext *C, void *UNUSED(arg1), void *UNUSED(arg2)) int file_draw_check_exists(SpaceFile *sfile) { - if(sfile->op) { /* fails on reload */ - if(RNA_struct_find_property(sfile->op->ptr, "check_existing")) { - if(RNA_boolean_get(sfile->op->ptr, "check_existing")) { + if (sfile->op) { /* fails on reload */ + if (RNA_struct_find_property(sfile->op->ptr, "check_existing")) { + if (RNA_boolean_get(sfile->op->ptr, "check_existing")) { char filepath[FILE_MAX]; BLI_join_dirfile(filepath, sizeof(filepath), sfile->params->dir, sfile->params->file); - if(BLI_is_file(filepath)) { + if (BLI_is_file(filepath)) { return TRUE; } } @@ -730,7 +732,7 @@ int file_exec(bContext *C, wmOperator *exec_op) SpaceFile *sfile= CTX_wm_space_file(C); char filepath[FILE_MAX]; - if(sfile->op) { + if (sfile->op) { wmOperator *op= sfile->op; /* when used as a macro, for doubleclick, @@ -739,7 +741,7 @@ int file_exec(bContext *C, wmOperator *exec_op) int i, active=0; for (i=0; i<filelist_numfiles(sfile->files); i++) { - if(filelist_is_selected(sfile->files, i, CHECK_ALL)) { + if (filelist_is_selected(sfile->files, i, CHECK_ALL)) { active=1; break; } @@ -787,7 +789,7 @@ int file_parent_exec(bContext *C, wmOperator *UNUSED(unused)) { SpaceFile *sfile= CTX_wm_space_file(C); - if(sfile->params) { + if (sfile->params) { if (BLI_has_parent(sfile->params->dir)) { BLI_parent_dir(sfile->params->dir); BLI_cleanup_dir(G.main->name, sfile->params->dir); @@ -842,7 +844,7 @@ int file_previous_exec(bContext *C, wmOperator *UNUSED(unused)) { SpaceFile *sfile= CTX_wm_space_file(C); - if(sfile->params) { + if (sfile->params) { if (!sfile->folders_next) sfile->folders_next = folderlist_new(); @@ -872,7 +874,7 @@ void FILE_OT_next(struct wmOperatorType *ot) int file_next_exec(bContext *C, wmOperator *UNUSED(unused)) { SpaceFile *sfile= CTX_wm_space_file(C); - if(sfile->params) { + if (sfile->params) { if (!sfile->folders_next) sfile->folders_next = folderlist_new(); @@ -902,7 +904,7 @@ static int file_smoothscroll_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent int i; /* 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; numfiles = filelist_numfiles(sfile->files); @@ -939,7 +941,8 @@ static int file_smoothscroll_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent if (sfile->layout->flag & FILE_LAYOUT_HOR) { sfile->scroll_offset = (edit_idx/sfile->layout->rows)*sfile->layout->rows; if (sfile->scroll_offset <= offset) sfile->scroll_offset -= sfile->layout->rows; - } else { + } + else { sfile->scroll_offset = (edit_idx/sfile->layout->columns)*sfile->layout->columns; if (sfile->scroll_offset <= offset) sfile->scroll_offset -= sfile->layout->columns; } @@ -962,14 +965,17 @@ static int file_smoothscroll_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent if (sfile->scroll_offset < offset) { if (sfile->layout->flag & FILE_LAYOUT_HOR) { WM_operator_name_call(C, "VIEW2D_OT_scroll_left", 0, NULL); - } else { + } + else { WM_operator_name_call(C, "VIEW2D_OT_scroll_up", 0, NULL); } - } else { + } + else { if (sfile->layout->flag & FILE_LAYOUT_HOR) { WM_operator_name_call(C, "VIEW2D_OT_scroll_right", 0, NULL); - } else { + } + else { WM_operator_name_call(C, "VIEW2D_OT_scroll_down", 0, NULL); } } @@ -1028,14 +1034,14 @@ int file_directory_new_exec(bContext *C, wmOperator *op) SpaceFile *sfile= CTX_wm_space_file(C); - if(!sfile->params) { + if (!sfile->params) { BKE_report(op->reports,RPT_WARNING, "No parent directory given"); return OPERATOR_CANCELLED; } path[0] = '\0'; - if(RNA_struct_find_property(op->ptr, "directory")) { + if (RNA_struct_find_property(op->ptr, "directory")) { RNA_string_get(op->ptr, "directory", path); if (path[0] != '\0') generate_name= 0; } @@ -1092,7 +1098,7 @@ static void file_expand_directory(bContext *C) { SpaceFile *sfile= CTX_wm_space_file(C); - if(sfile->params) { + if (sfile->params) { if ( sfile->params->dir[0] == '~' ) { char tmpstr[sizeof(sfile->params->dir)-1]; BLI_strncpy(tmpstr, sfile->params->dir+1, sizeof(tmpstr)); @@ -1126,7 +1132,7 @@ static int file_directory_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(ev { SpaceFile *sfile= CTX_wm_space_file(C); - if(sfile->params) { + if (sfile->params) { file_expand_directory(C); if (!BLI_exists(sfile->params->dir)) { @@ -1145,7 +1151,7 @@ int file_directory_exec(bContext *C, wmOperator *UNUSED(unused)) { SpaceFile *sfile= CTX_wm_space_file(C); - if(sfile->params) { + if (sfile->params) { file_expand_directory(C); if (!BLI_exists(sfile->params->dir)) { @@ -1153,7 +1159,7 @@ int file_directory_exec(bContext *C, wmOperator *UNUSED(unused)) } /* special case, user may have pasted a filepath into the directory */ - if(BLI_is_file(sfile->params->dir)) { + if (BLI_is_file(sfile->params->dir)) { char path[sizeof(sfile->params->dir)]; BLI_strncpy(path, sfile->params->dir, sizeof(path)); BLI_split_dirfile(path, sfile->params->dir, sfile->params->file, sizeof(sfile->params->dir), sizeof(sfile->params->file)); @@ -1222,7 +1228,7 @@ static int file_hidedot_exec(bContext *C, wmOperator *UNUSED(unused)) { SpaceFile *sfile= CTX_wm_space_file(C); - if(sfile->params) { + if (sfile->params) { sfile->params->flag ^= FILE_HIDE_DOT; ED_fileselect_clear(C, sfile); WM_event_add_notifier(C, NC_SPACE|ND_SPACE_FILE_LIST, NULL); @@ -1248,17 +1254,17 @@ struct ARegion *file_buttons_region(struct ScrArea *sa) { ARegion *ar, *arnew; - for(ar= sa->regionbase.first; ar; ar= ar->next) - if(ar->regiontype==RGN_TYPE_CHANNELS) + for (ar= sa->regionbase.first; ar; ar= ar->next) + if (ar->regiontype==RGN_TYPE_CHANNELS) return ar; /* add subdiv level; after header */ - for(ar= sa->regionbase.first; ar; ar= ar->next) - if(ar->regiontype==RGN_TYPE_HEADER) + for (ar= sa->regionbase.first; ar; ar= ar->next) + if (ar->regiontype==RGN_TYPE_HEADER) break; /* is error! */ - if(ar==NULL) return NULL; + if (ar==NULL) return NULL; arnew= MEM_callocN(sizeof(ARegion), "buttons for file panels"); @@ -1276,7 +1282,7 @@ static int file_bookmark_toggle_exec(bContext *C, wmOperator *UNUSED(unused)) ScrArea *sa= CTX_wm_area(C); ARegion *ar= file_buttons_region(sa); - if(ar) + if (ar) ED_region_toggle_hidden(C, ar); return OPERATOR_FINISHED; @@ -1301,7 +1307,7 @@ static int file_filenum_exec(bContext *C, wmOperator *op) ScrArea *sa= CTX_wm_area(C); int inc = RNA_int_get(op->ptr, "increment"); - if(sfile->params && (inc != 0)) { + if (sfile->params && (inc != 0)) { BLI_newname(sfile->params->file, inc); ED_area_tag_redraw(sa); file_draw_check_cb(C, NULL, NULL); @@ -1332,7 +1338,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) { + if (sfile->params) { int idx = sfile->params->active_file; int numfiles = filelist_numfiles(sfile->files); if ( (0<=idx) && (idx<numfiles) ) { @@ -1356,7 +1362,8 @@ static int file_rename_poll(bContext *C) if (sfile && sfile->params) { if (sfile->params->active_file < 0) { poll= 0; - } else { + } + else { char dir[FILE_MAX], group[FILE_MAX]; if (filelist_islibrary(sfile->files, dir, group)) poll= 0; } @@ -1388,7 +1395,8 @@ static int file_delete_poll(bContext *C) if (sfile && sfile->params) { if (sfile->params->active_file < 0) { poll= 0; - } else { + } + else { char dir[FILE_MAX], group[FILE_MAX]; if (filelist_islibrary(sfile->files, dir, group)) poll= 0; file = filelist_file(sfile->files, sfile->params->active_file); diff --git a/source/blender/editors/space_file/file_panels.c b/source/blender/editors/space_file/file_panels.c index ca0e7646a85..596721bff07 100644 --- a/source/blender/editors/space_file/file_panels.c +++ b/source/blender/editors/space_file/file_panels.c @@ -80,7 +80,7 @@ static void file_panel_category(const bContext *C, Panel *pa, FSMenuCategory cat *nr= -1; /* hide if no entries */ - if(nentries == 0) + if (nentries == 0) return; /* layout */ @@ -100,8 +100,8 @@ static void file_panel_category(const bContext *C, Panel *pa, FSMenuCategory cat entry = fsmenu_get_entry(fsmenu, category, i); /* set this list item as active if we have a match */ - if(sfile->params) { - if(BLI_path_cmp(sfile->params->dir, entry) == 0) { + if (sfile->params) { + if (BLI_path_cmp(sfile->params->dir, entry) == 0) { *nr= i; } } @@ -112,7 +112,7 @@ static void file_panel_category(const bContext *C, Panel *pa, FSMenuCategory cat BLI_getlastdir(temp, dir, FILE_MAX); BLI_del_slash(dir); - if(dir[0] == 0) + if (dir[0] == 0) BLI_strncpy(dir, entry, FILE_MAX); /* create list item */ @@ -121,7 +121,7 @@ static void file_panel_category(const bContext *C, Panel *pa, FSMenuCategory cat uiButSetFlag(but, UI_ICON_LEFT|UI_TEXT_LEFT); /* create delete button */ - if(allow_delete && fsmenu_can_save(fsmenu, category, i)) { + if (allow_delete && fsmenu_can_save(fsmenu, category, i)) { uiBlockSetEmboss(block, UI_EMBOSSN); uiItemIntO(layout, "", ICON_X, "FILE_OT_delete_bookmark", "index", i); uiBlockSetEmboss(block, UI_EMBOSS); @@ -133,7 +133,7 @@ static void file_panel_system(const bContext *C, Panel *pa) { SpaceFile *sfile= CTX_wm_space_file(C); - if(sfile) + if (sfile) file_panel_category(C, pa, FS_CATEGORY_SYSTEM, &sfile->systemnr, ICON_DISK_DRIVE, 0, 0); } @@ -142,7 +142,7 @@ static void file_panel_bookmarks(const bContext *C, Panel *pa) SpaceFile *sfile= CTX_wm_space_file(C); uiLayout *row; - if(sfile) { + if (sfile) { row= uiLayoutRow(pa->layout, 0); uiItemO(row, IFACE_("Add"), ICON_ZOOMIN, "file.bookmark_add"); uiItemL(row, NULL, ICON_NONE); @@ -155,7 +155,7 @@ static void file_panel_recent(const bContext *C, Panel *pa) { SpaceFile *sfile= CTX_wm_space_file(C); - if(sfile) { + if (sfile) { if ( !(U.uiflag & USER_HIDE_RECENT) ) { file_panel_category(C, pa, FS_CATEGORY_RECENT, &sfile->recentnr, ICON_FILE_FOLDER, 0, 1); } diff --git a/source/blender/editors/space_file/filelist.c b/source/blender/editors/space_file/filelist.c index 5bc62620dfa..202a82be4b4 100644 --- a/source/blender/editors/space_file/filelist.c +++ b/source/blender/editors/space_file/filelist.c @@ -158,24 +158,26 @@ static int compare_name(const void *a1, const void *a2) /* type is equal to stat.st_mode */ - if (S_ISDIR(entry1->type)){ + if (S_ISDIR(entry1->type)) { if (S_ISDIR(entry2->type)==0) return (-1); - } else{ + } + else { if (S_ISDIR(entry2->type)) return (1); } - if (S_ISREG(entry1->type)){ + if (S_ISREG(entry1->type)) { if (S_ISREG(entry2->type)==0) return (-1); - } else{ + } + else { if (S_ISREG(entry2->type)) return (1); } if ((entry1->type & S_IFMT) < (entry2->type & S_IFMT)) return (-1); if ((entry1->type & S_IFMT) > (entry2->type & S_IFMT)) return (1); /* make sure "." and ".." are always first */ - if( strcmp(entry1->relname, ".")==0 ) return (-1); - if( strcmp(entry2->relname, ".")==0 ) return (1); - if( strcmp(entry1->relname, "..")==0 ) return (-1); - if( strcmp(entry2->relname, "..")==0 ) return (1); + if ( strcmp(entry1->relname, ".")==0 ) return (-1); + if ( strcmp(entry2->relname, ".")==0 ) return (1); + if ( strcmp(entry1->relname, "..")==0 ) return (-1); + if ( strcmp(entry2->relname, "..")==0 ) return (1); return (BLI_natstrcmp(entry1->relname,entry2->relname)); } @@ -186,24 +188,26 @@ static int compare_date(const void *a1, const void *a2) /* type is equal to stat.st_mode */ - if (S_ISDIR(entry1->type)){ + if (S_ISDIR(entry1->type)) { if (S_ISDIR(entry2->type)==0) return (-1); - } else{ + } + else { if (S_ISDIR(entry2->type)) return (1); } - if (S_ISREG(entry1->type)){ + if (S_ISREG(entry1->type)) { if (S_ISREG(entry2->type)==0) return (-1); - } else{ + } + else { if (S_ISREG(entry2->type)) return (1); } if ((entry1->type & S_IFMT) < (entry2->type & S_IFMT)) return (-1); if ((entry1->type & S_IFMT) > (entry2->type & S_IFMT)) return (1); /* make sure "." and ".." are always first */ - if( strcmp(entry1->relname, ".")==0 ) return (-1); - if( strcmp(entry2->relname, ".")==0 ) return (1); - if( strcmp(entry1->relname, "..")==0 ) return (-1); - if( strcmp(entry2->relname, "..")==0 ) return (1); + if ( strcmp(entry1->relname, ".")==0 ) return (-1); + if ( strcmp(entry2->relname, ".")==0 ) return (1); + if ( strcmp(entry1->relname, "..")==0 ) return (-1); + if ( strcmp(entry2->relname, "..")==0 ) return (1); if ( entry1->s.st_mtime < entry2->s.st_mtime) return 1; if ( entry1->s.st_mtime > entry2->s.st_mtime) return -1; @@ -217,24 +221,26 @@ static int compare_size(const void *a1, const void *a2) /* type is equal to stat.st_mode */ - if (S_ISDIR(entry1->type)){ + if (S_ISDIR(entry1->type)) { if (S_ISDIR(entry2->type)==0) return (-1); - } else{ + } + else { if (S_ISDIR(entry2->type)) return (1); } - if (S_ISREG(entry1->type)){ + if (S_ISREG(entry1->type)) { if (S_ISREG(entry2->type)==0) return (-1); - } else{ + } + else { if (S_ISREG(entry2->type)) return (1); } if ((entry1->type & S_IFMT) < (entry2->type & S_IFMT)) return (-1); if ((entry1->type & S_IFMT) > (entry2->type & S_IFMT)) return (1); /* make sure "." and ".." are always first */ - if( strcmp(entry1->relname, ".")==0 ) return (-1); - if( strcmp(entry2->relname, ".")==0 ) return (1); - if( strcmp(entry1->relname, "..")==0 ) return (-1); - if( strcmp(entry2->relname, "..")==0 ) return (1); + if ( strcmp(entry1->relname, ".")==0 ) return (-1); + if ( strcmp(entry2->relname, ".")==0 ) return (1); + if ( strcmp(entry1->relname, "..")==0 ) return (-1); + if ( strcmp(entry2->relname, "..")==0 ) return (1); if ( entry1->s.st_size < entry2->s.st_size) return 1; if ( entry1->s.st_size > entry2->s.st_size) return -1; @@ -256,24 +262,26 @@ static int compare_extension(const void *a1, const void *a2) /* type is equal to stat.st_mode */ - if (S_ISDIR(entry1->type)){ + if (S_ISDIR(entry1->type)) { if (S_ISDIR(entry2->type)==0) return (-1); - } else{ + } + else { if (S_ISDIR(entry2->type)) return (1); } - if (S_ISREG(entry1->type)){ + if (S_ISREG(entry1->type)) { if (S_ISREG(entry2->type)==0) return (-1); - } else{ + } + else { if (S_ISREG(entry2->type)) return (1); } if ((entry1->type & S_IFMT) < (entry2->type & S_IFMT)) return (-1); if ((entry1->type & S_IFMT) > (entry2->type & S_IFMT)) return (1); /* make sure "." and ".." are always first */ - if( strcmp(entry1->relname, ".")==0 ) return (-1); - if( strcmp(entry2->relname, ".")==0 ) return (1); - if( strcmp(entry1->relname, "..")==0 ) return (-1); - if( strcmp(entry2->relname, "..")==0 ) return (1); + if ( strcmp(entry1->relname, ".")==0 ) return (-1); + if ( strcmp(entry2->relname, ".")==0 ) return (1); + if ( strcmp(entry1->relname, "..")==0 ) return (-1); + if ( strcmp(entry2->relname, "..")==0 ) return (1); return (BLI_strcasecmp(sufix1, sufix2)); } @@ -283,17 +291,20 @@ static int is_hidden_file(const char* filename, short hide_dot) int is_hidden=0; if (hide_dot) { - if(filename[0]=='.' && filename[1]!='.' && filename[1]!=0) { + if (filename[0]=='.' && filename[1]!='.' && filename[1]!=0) { is_hidden=1; /* ignore .file */ - } else if (((filename[0] == '.') && (filename[1] == 0) )) { + } + else if (((filename[0] == '.') && (filename[1] == 0) )) { is_hidden=1; /* ignore . */ - } else { + } + else { int len=strlen(filename); - if( (len>0) && (filename[len-1]=='~') ) { + if ( (len>0) && (filename[len-1]=='~') ) { is_hidden=1; /* ignore file~ */ } } - } else { + } + else { if (((filename[0] == '.') && (filename[1] == 0) )) { is_hidden=1; /* ignore . */ } @@ -307,12 +318,14 @@ static int is_filtered_file(struct direntry* file, const char* UNUSED(dir), unsi if (filter) { if (file->flags & filter) { is_filtered=1; - } else if (file->type & S_IFDIR) { + } + else if (file->type & S_IFDIR) { if (filter & FOLDERFILE) { is_filtered = 1; } } - } else { + } + else { is_filtered = 1; } return is_filtered && !is_hidden_file(file->relname, hide_dot); @@ -324,7 +337,8 @@ static int is_filtered_lib(struct direntry* file, const char* dir, unsigned int char tdir[FILE_MAX], tgroup[GROUP_MAX]; if (BLO_is_a_library(dir, tdir, tgroup)) { is_filtered = !is_hidden_file(file->relname, hide_dot); - } else { + } + else { is_filtered = is_filtered_file(file, dir, filter, hide_dot); } return is_filtered; @@ -415,13 +429,13 @@ void folderlist_popdir(struct ListBase* folderlist, char *dir) struct FolderList *folder; folder = folderlist->last; - if(folder){ + if (folder) { // remove the current directory MEM_freeN(folder->foldername); BLI_freelinkN(folderlist, folder); folder = folderlist->last; - if(folder){ + if (folder) { prev_dir = folder->foldername; BLI_strncpy(dir, prev_dir, FILE_MAXDIR); } @@ -435,8 +449,8 @@ void folderlist_pushdir(ListBase* folderlist, const char *dir) previous_folder = folderlist->last; // check if already exists - if(previous_folder && previous_folder->foldername){ - if(BLI_path_cmp(previous_folder->foldername, dir)==0){ + if (previous_folder && previous_folder->foldername) { + if (BLI_path_cmp(previous_folder->foldername, dir)==0) { return; } } @@ -472,9 +486,9 @@ int folderlist_clear_next(struct SpaceFile *sfile) /* not listbase itself */ void folderlist_free(ListBase* folderlist) { - if (folderlist){ + if (folderlist) { FolderList *folder; - for(folder= folderlist->first; folder; folder= folder->next) + for (folder= folderlist->first; folder; folder= folder->next) MEM_freeN(folder->foldername); BLI_freelistN(folderlist); } @@ -489,7 +503,7 @@ ListBase *folderlist_duplicate(ListBase* folderlist) BLI_duplicatelist(folderlistn, folderlist); - for(folder= folderlistn->first; folder; folder= folder->next) { + for (folder= folderlistn->first; folder; folder= folder->next) { folder->foldername= MEM_dupallocN(folder->foldername); } return folderlistn; @@ -564,7 +578,7 @@ void filelist_free(struct FileList* filelist) void filelist_freelib(struct FileList* filelist) { - if(filelist->libfiledata) + if (filelist->libfiledata) BLO_blendhandle_close(filelist->libfiledata); filelist->libfiledata= NULL; } @@ -626,28 +640,37 @@ struct ImBuf * filelist_geticon(struct FileList* filelist, int index) if (file->type & S_IFDIR) { if ( strcmp(filelist->filelist[fidx].relname, "..") == 0) { ibuf = gSpecialFileImages[SPECIAL_IMG_PARENT]; - } else if ( strcmp(filelist->filelist[fidx].relname, ".") == 0) { + } + else if ( strcmp(filelist->filelist[fidx].relname, ".") == 0) { ibuf = gSpecialFileImages[SPECIAL_IMG_REFRESH]; - } else { + } + else { ibuf = gSpecialFileImages[SPECIAL_IMG_FOLDER]; } - } else { + } + else { ibuf = gSpecialFileImages[SPECIAL_IMG_UNKNOWNFILE]; } if (file->flags & BLENDERFILE) { ibuf = gSpecialFileImages[SPECIAL_IMG_BLENDFILE]; - } else if ( (file->flags & MOVIEFILE) || (file->flags & MOVIEFILE_ICON) ) { + } + else if ( (file->flags & MOVIEFILE) || (file->flags & MOVIEFILE_ICON) ) { ibuf = gSpecialFileImages[SPECIAL_IMG_MOVIEFILE]; - } else if (file->flags & SOUNDFILE) { + } + else if (file->flags & SOUNDFILE) { ibuf = gSpecialFileImages[SPECIAL_IMG_SOUNDFILE]; - } else if (file->flags & PYSCRIPTFILE) { + } + else if (file->flags & PYSCRIPTFILE) { ibuf = gSpecialFileImages[SPECIAL_IMG_PYTHONFILE]; - } else if (file->flags & FTFONTFILE) { + } + else if (file->flags & FTFONTFILE) { ibuf = gSpecialFileImages[SPECIAL_IMG_FONTFILE]; - } else if (file->flags & TEXTFILE) { + } + else if (file->flags & TEXTFILE) { ibuf = gSpecialFileImages[SPECIAL_IMG_TEXTFILE]; - } else if (file->flags & IMAGEFILE) { + } + else if (file->flags & IMAGEFILE) { ibuf = gSpecialFileImages[SPECIAL_IMG_LOADING]; } @@ -715,17 +738,17 @@ static int file_is_blend_backup(const char *str) a= strlen(str); b= 7; - if(a==0 || b>=a); + if (a==0 || b>=a); else { char *loc; - if(a > b+1) + if (a > b+1) b++; /* allow .blend1 .blend2 .blend32 */ loc= BLI_strcasestr(str+a-b, ".blend"); - if(loc) + if (loc) retval= 1; } @@ -735,32 +758,41 @@ static int file_is_blend_backup(const char *str) static int file_extension_type(const char *relname) { - if(BLO_has_bfile_extension(relname)) { + if (BLO_has_bfile_extension(relname)) { return BLENDERFILE; - } else if(file_is_blend_backup(relname)) { + } + else if (file_is_blend_backup(relname)) { return BLENDERFILE_BACKUP; - } else if(BLI_testextensie(relname, ".py")) { + } + else if (BLI_testextensie(relname, ".py")) { return PYSCRIPTFILE; - } else if(BLI_testextensie(relname, ".txt") + } + else if (BLI_testextensie(relname, ".txt") || BLI_testextensie(relname, ".glsl") || BLI_testextensie(relname, ".data")) { return TEXTFILE; - } else if( BLI_testextensie(relname, ".ttf") + } + else if ( BLI_testextensie(relname, ".ttf") || BLI_testextensie(relname, ".ttc") || BLI_testextensie(relname, ".pfb") || BLI_testextensie(relname, ".otf") || BLI_testextensie(relname, ".otc")) { return FTFONTFILE; - } else if(BLI_testextensie(relname, ".btx")) { + } + else if (BLI_testextensie(relname, ".btx")) { return BTXFILE; - } else if(BLI_testextensie(relname, ".dae")) { + } + else if (BLI_testextensie(relname, ".dae")) { return COLLADAFILE; - } else if(BLI_testextensie_array(relname, imb_ext_image) + } + else if (BLI_testextensie_array(relname, imb_ext_image) || (G.have_quicktime && BLI_testextensie_array(relname, imb_ext_image_qt))) { return IMAGEFILE; - } else if(BLI_testextensie_array(relname, imb_ext_movie)) { + } + else if (BLI_testextensie_array(relname, imb_ext_movie)) { return MOVIEFILE; - } else if(BLI_testextensie_array(relname, imb_ext_audio)) { + } + else if (BLI_testextensie_array(relname, imb_ext_audio)) { return SOUNDFILE; } return 0; @@ -797,7 +829,7 @@ static void filelist_setfiletypes(struct FileList* filelist) file= filelist->filelist; - for(num=0; num<filelist->numfiles; num++, file++) { + for (num=0; num<filelist->numfiles; num++, file++) { file->type= file->s.st_mode; /* restore the mess below */ /* Don't check extensions for directories */ @@ -806,7 +838,7 @@ static void filelist_setfiletypes(struct FileList* filelist) } file->flags = file_extension_type(file->relname); - if(filelist->filter_glob + if (filelist->filter_glob && BLI_testextensie_glob(file->relname, filelist->filter_glob)) { file->flags= OPERATORFILE; } @@ -827,7 +859,7 @@ static void filelist_read_dir(struct FileList* filelist) BLI_cleanup_dir(G.main->name, filelist->dir); filelist->numfiles = BLI_dir_contents(filelist->dir, &(filelist->filelist)); - if(!chdir(wdir)) {} /* fix warning about not checking return value */ + if (!chdir(wdir)) {} /* fix warning about not checking return value */ filelist_setfiletypes(filelist); filelist_filter(filelist); } @@ -843,15 +875,15 @@ static void filelist_read_library(struct FileList* filelist) if (!filelist) return; BLI_cleanup_dir(G.main->name, filelist->dir); filelist_from_library(filelist); - if(!filelist->libfiledata) { + if (!filelist->libfiledata) { int num; struct direntry *file; BLI_make_exist(filelist->dir); filelist_read_dir(filelist); file = filelist->filelist; - for(num=0; num<filelist->numfiles; num++, file++) { - if(BLO_has_bfile_extension(file->relname)) { + for (num=0; num<filelist->numfiles; num++, file++) { + if (BLO_has_bfile_extension(file->relname)) { char name[FILE_MAX]; BLI_join_dirfile(name, sizeof(name), filelist->dir, file->relname); @@ -994,7 +1026,7 @@ void filelist_from_library(struct FileList* filelist) ok= filelist_islibrary(filelist, dir, group); if (!ok) { /* free */ - if(filelist->libfiledata) BLO_blendhandle_close(filelist->libfiledata); + if (filelist->libfiledata) BLO_blendhandle_close(filelist->libfiledata); filelist->libfiledata= NULL; return; } @@ -1005,7 +1037,7 @@ void filelist_from_library(struct FileList* filelist) /* for the time being only read filedata when libfiledata==0 */ if (filelist->libfiledata == NULL) { filelist->libfiledata= BLO_blendhandle_from_file(dir, NULL); - if(filelist->libfiledata == NULL) return; + if (filelist->libfiledata == NULL) return; } idcode= groupname_to_code(group); @@ -1019,7 +1051,8 @@ void filelist_from_library(struct FileList* filelist) BLO_blendhandle_close(filelist->libfiledata); filelist->libfiledata= BLO_blendhandle_from_file(dir, NULL); - } else { + } + else { previews= NULL; nprevs= 0; names= BLO_blendhandle_get_linkable_groups(filelist->libfiledata); @@ -1039,15 +1072,16 @@ void filelist_from_library(struct FileList* filelist) filelist->filelist[i + 1].relname= BLI_strdup(blockname); if (idcode) { filelist->filelist[i + 1].type |= S_IFREG; - } else { + } + else { filelist->filelist[i + 1].type |= S_IFDIR; } } - if(previews && (nnames != nprevs)) { + if (previews && (nnames != nprevs)) { printf("filelist_from_library: error, found %d items, %d previews\n", nnames, nprevs); } - else if(previews) { + else if (previews) { for (i=0, l= previews; i<nnames; i++, l= l->next) { PreviewImage *img= l->link; @@ -1092,20 +1126,20 @@ void filelist_from_main(struct FileList *filelist) // filelist->type = FILE_MAIN; // XXXXX TODO: add modes to filebrowser - if(filelist->dir[0]=='/') filelist->dir[0]= 0; + if (filelist->dir[0]=='/') filelist->dir[0]= 0; - if(filelist->dir[0]) { + if (filelist->dir[0]) { idcode= groupname_to_code(filelist->dir); - if(idcode==0) filelist->dir[0]= 0; + if (idcode==0) filelist->dir[0]= 0; } - if( filelist->dir[0]==0) { + if ( filelist->dir[0]==0) { /* make directories */ filelist->numfiles= 24; filelist->filelist= (struct direntry *)malloc(filelist->numfiles * sizeof(struct direntry)); - for(a=0; a<filelist->numfiles; a++) { + for (a=0; a<filelist->numfiles; a++) { memset( &(filelist->filelist[a]), 0 , sizeof(struct direntry)); filelist->filelist[a].type |= S_IFDIR; } @@ -1141,7 +1175,7 @@ void filelist_from_main(struct FileList *filelist) idcode= groupname_to_code(filelist->dir); lb= which_libbase(G.main, idcode ); - if(lb == NULL) return; + if (lb == NULL) return; id= lb->first; filelist->numfiles= 0; @@ -1172,10 +1206,10 @@ void filelist_from_main(struct FileList *filelist) while(id) { ok = 1; - if(ok) { + if (ok) { if (!filelist->hide_dot || id->name[2] != '.') { memset( files, 0 , sizeof(struct direntry)); - if(id->lib==NULL) + if (id->lib==NULL) files->relname= BLI_strdup(id->name+2); else { files->relname= MEM_mallocN(FILE_MAX+32, "filename for lib"); @@ -1183,28 +1217,28 @@ void filelist_from_main(struct FileList *filelist) } files->type |= S_IFREG; #if 0 // XXXXX TODO show the selection status of the objects - if(!filelist->has_func) { /* F4 DATA BROWSE */ - if(idcode==ID_OB) { - if( ((Object *)id)->flag & SELECT) files->selflag |= SELECTED_FILE; + if (!filelist->has_func) { /* F4 DATA BROWSE */ + if (idcode==ID_OB) { + if ( ((Object *)id)->flag & SELECT) files->selflag |= SELECTED_FILE; } - else if(idcode==ID_SCE) { - if( ((Scene *)id)->r.scemode & R_BG_RENDER) files->selflag |= SELECTED_FILE; + else if (idcode==ID_SCE) { + if ( ((Scene *)id)->r.scemode & R_BG_RENDER) files->selflag |= SELECTED_FILE; } } #endif files->nr= totbl+1; files->poin= id; fake= id->flag & LIB_FAKEUSER; - if(idcode == ID_MA || idcode == ID_TE || idcode == ID_LA || idcode == ID_WO || idcode == ID_IM) { + if (idcode == ID_MA || idcode == ID_TE || idcode == ID_LA || idcode == ID_WO || idcode == ID_IM) { files->flags |= IMAGEFILE; } - if(id->lib && fake) BLI_snprintf(files->extra, sizeof(files->extra), "LF %d", id->us); - else if(id->lib) BLI_snprintf(files->extra, sizeof(files->extra), "L %d", id->us); - else if(fake) BLI_snprintf(files->extra, sizeof(files->extra), "F %d", id->us); + if (id->lib && fake) BLI_snprintf(files->extra, sizeof(files->extra), "LF %d", id->us); + else if (id->lib) BLI_snprintf(files->extra, sizeof(files->extra), "L %d", id->us); + else if (fake) BLI_snprintf(files->extra, sizeof(files->extra), "F %d", id->us); else BLI_snprintf(files->extra, sizeof(files->extra), " %d", id->us); - if(id->lib) { - if(totlib==0) firstlib= files; + if (id->lib) { + if (totlib==0) firstlib= files; totlib++; } @@ -1217,7 +1251,7 @@ void filelist_from_main(struct FileList *filelist) } /* only qsort of library blocks */ - if(totlib>1) { + if (totlib>1) { qsort(firstlib, totlib, sizeof(struct direntry), compare_name); } } @@ -1230,7 +1264,7 @@ static void thumbnail_joblist_free(ThumbnailJob *tj) FileImage* limg = tj->loadimages.first; /* free the images not yet copied to the filelist -> these will get freed with the filelist */ - for( ; limg; limg= limg->next) { + for ( ; limg; limg= limg->next) { if ((limg->img) && (!limg->done)) { IMB_freeImBuf(limg->img); } @@ -1249,9 +1283,11 @@ static void thumbnails_startjob(void *tjv, short *stop, short *do_update, float while ( (*stop==0) && (limg) ) { if ( limg->flags & IMAGEFILE ) { limg->img = IMB_thumb_manage(limg->path, THB_NORMAL, THB_SOURCE_IMAGE); - } else if ( limg->flags & BLENDERFILE ) { + } + else if ( limg->flags & BLENDERFILE ) { limg->img = IMB_thumb_manage(limg->path, THB_NORMAL, THB_SOURCE_BLEND); - } else if ( limg->flags & MOVIEFILE ) { + } + else if ( limg->flags & MOVIEFILE ) { limg->img = IMB_thumb_manage(limg->path, THB_NORMAL, THB_SOURCE_MOVIE); if (!limg->img) { /* remember that file can't be loaded via IMB_open_anim */ diff --git a/source/blender/editors/space_file/filesel.c b/source/blender/editors/space_file/filesel.c index fa2874f4842..3ed3c0690a2 100644 --- a/source/blender/editors/space_file/filesel.c +++ b/source/blender/editors/space_file/filesel.c @@ -125,7 +125,7 @@ short ED_fileselect_set_params(SpaceFile *sfile) BLI_strncpy(params->title, op->type->name, sizeof(params->title)); - if(RNA_struct_find_property(op->ptr, "filemode")) + if (RNA_struct_find_property(op->ptr, "filemode")) params->type = RNA_int_get(op->ptr, "filemode"); else params->type = FILE_SPECIAL; @@ -152,12 +152,12 @@ short ED_fileselect_set_params(SpaceFile *sfile) } } - if(params->dir[0]) { + if (params->dir[0]) { BLI_cleanup_dir(G.main->name, params->dir); BLI_path_abs(params->dir, G.main->name); } - if(is_directory==TRUE && is_filename==FALSE && is_filepath==FALSE && is_files==FALSE) { + if (is_directory==TRUE && is_filename==FALSE && is_filepath==FALSE && is_files==FALSE) { params->flag |= FILE_DIRSEL_ONLY; } else { @@ -165,27 +165,27 @@ short ED_fileselect_set_params(SpaceFile *sfile) } params->filter = 0; - if(RNA_struct_find_property(op->ptr, "filter_blender")) + if (RNA_struct_find_property(op->ptr, "filter_blender")) params->filter |= RNA_boolean_get(op->ptr, "filter_blender") ? BLENDERFILE : 0; - if(RNA_struct_find_property(op->ptr, "filter_image")) + if (RNA_struct_find_property(op->ptr, "filter_image")) params->filter |= RNA_boolean_get(op->ptr, "filter_image") ? IMAGEFILE : 0; - if(RNA_struct_find_property(op->ptr, "filter_movie")) + if (RNA_struct_find_property(op->ptr, "filter_movie")) params->filter |= RNA_boolean_get(op->ptr, "filter_movie") ? MOVIEFILE : 0; - if(RNA_struct_find_property(op->ptr, "filter_text")) + if (RNA_struct_find_property(op->ptr, "filter_text")) params->filter |= RNA_boolean_get(op->ptr, "filter_text") ? TEXTFILE : 0; - if(RNA_struct_find_property(op->ptr, "filter_python")) + if (RNA_struct_find_property(op->ptr, "filter_python")) params->filter |= RNA_boolean_get(op->ptr, "filter_python") ? PYSCRIPTFILE : 0; - if(RNA_struct_find_property(op->ptr, "filter_font")) + if (RNA_struct_find_property(op->ptr, "filter_font")) params->filter |= RNA_boolean_get(op->ptr, "filter_font") ? FTFONTFILE : 0; - if(RNA_struct_find_property(op->ptr, "filter_sound")) + if (RNA_struct_find_property(op->ptr, "filter_sound")) params->filter |= RNA_boolean_get(op->ptr, "filter_sound") ? SOUNDFILE : 0; - if(RNA_struct_find_property(op->ptr, "filter_text")) + if (RNA_struct_find_property(op->ptr, "filter_text")) params->filter |= RNA_boolean_get(op->ptr, "filter_text") ? TEXTFILE : 0; - if(RNA_struct_find_property(op->ptr, "filter_folder")) + if (RNA_struct_find_property(op->ptr, "filter_folder")) params->filter |= RNA_boolean_get(op->ptr, "filter_folder") ? FOLDERFILE : 0; - if(RNA_struct_find_property(op->ptr, "filter_btx")) + if (RNA_struct_find_property(op->ptr, "filter_btx")) params->filter |= RNA_boolean_get(op->ptr, "filter_btx") ? BTXFILE : 0; - if(RNA_struct_find_property(op->ptr, "filter_collada")) + if (RNA_struct_find_property(op->ptr, "filter_collada")) params->filter |= RNA_boolean_get(op->ptr, "filter_collada") ? COLLADAFILE : 0; if (RNA_struct_find_property(op->ptr, "filter_glob")) { RNA_string_get(op->ptr, "filter_glob", params->filter_glob); @@ -198,14 +198,16 @@ short ED_fileselect_set_params(SpaceFile *sfile) if (params->filter != 0) { if (U.uiflag & USER_FILTERFILEEXTS) { params->flag |= FILE_FILTER; - } else { + } + else { params->flag &= ~FILE_FILTER; } } if (U.uiflag & USER_HIDE_DOT) { params->flag |= FILE_HIDE_DOT; - } else { + } + else { params->flag &= ~FILE_HIDE_DOT; } @@ -216,16 +218,17 @@ short ED_fileselect_set_params(SpaceFile *sfile) params->flag |= RNA_boolean_get(op->ptr, "active_layer") ? FILE_ACTIVELAY : 0; } - if(RNA_struct_find_property(op->ptr, "display_type")) + if (RNA_struct_find_property(op->ptr, "display_type")) params->display= RNA_enum_get(op->ptr, "display_type"); - if(params->display==FILE_DEFAULTDISPLAY) { + if (params->display==FILE_DEFAULTDISPLAY) { if (U.uiflag & USER_SHOW_THUMBNAILS) { - if(params->filter & (IMAGEFILE|MOVIEFILE)) + if (params->filter & (IMAGEFILE|MOVIEFILE)) params->display= FILE_IMGDISPLAY; else params->display= FILE_SHORTDISPLAY; - } else { + } + else { params->display= FILE_SHORTDISPLAY; } } @@ -276,7 +279,8 @@ int ED_fileselect_layout_numfiles(FileLayout* layout, struct ARegion *ar) int width = (int)(ar->v2d.cur.xmax - ar->v2d.cur.xmin - 2*layout->tile_border_x); numfiles = (int)((float)width / (float)layout->tile_w + 0.5f); return numfiles*layout->rows; - } else { + } + else { int height = (int)(ar->v2d.cur.ymax - ar->v2d.cur.ymin - 2*layout->tile_border_y); numfiles = (int)((float)height/(float)layout->tile_h + 0.5f); return numfiles*layout->columns; @@ -312,7 +316,8 @@ FileSelection ED_fileselect_layout_offset_rect(FileLayout* layout, const rcti* r if ( (colmin > layout->columns-1) || (rowmin > layout->rows-1) ) { sel.first = -1; - } else { + } + else { if (layout->flag & FILE_LAYOUT_HOR) sel.first = layout->rows*colmin + rowmin; else @@ -320,7 +325,8 @@ FileSelection ED_fileselect_layout_offset_rect(FileLayout* layout, const rcti* r } if ( (colmax > layout->columns-1) || (rowmax > layout->rows-1) ) { sel.last = -1; - } else { + } + else { if (layout->flag & FILE_LAYOUT_HOR) sel.last = layout->rows*colmax + rowmax; else @@ -356,7 +362,8 @@ void ED_fileselect_layout_tilepos(FileLayout* layout, int tile, int *x, int *y) if (layout->flag == FILE_LAYOUT_HOR) { *x = layout->tile_border_x + (tile/layout->rows)*(layout->tile_w+2*layout->tile_border_x); *y = layout->tile_border_y + (tile%layout->rows)*(layout->tile_h+2*layout->tile_border_y); - } else { + } + else { *x = layout->tile_border_x + ((tile)%layout->columns)*(layout->tile_w+2*layout->tile_border_x); *y = layout->tile_border_y + ((tile)/layout->columns)*(layout->tile_h+2*layout->tile_border_y); } @@ -393,7 +400,8 @@ float file_shorten_string(char* string, float w, int front) temp[slen+4] = '\0'; BLI_strncpy(string, temp, slen+4); } - } else { + } + else { char *s = string; while (sw>w) { int slen = strlen(string); @@ -482,7 +490,8 @@ void ED_fileselect_init_layout(struct SpaceFile *sfile, struct ARegion *ar) if (sfile->layout == NULL) { sfile->layout = MEM_callocN(sizeof(struct FileLayout), "file_layout"); sfile->layout->dirty = TRUE; - } else if (sfile->layout->dirty == FALSE) { + } + else if (sfile->layout->dirty == FALSE) { return; } @@ -502,7 +511,7 @@ void ED_fileselect_init_layout(struct SpaceFile *sfile, struct ARegion *ar) layout->tile_h = layout->prv_h + 2*layout->prv_border_y + textheight; layout->width= (int)(v2d->cur.xmax - v2d->cur.xmin - 2*layout->tile_border_x); layout->columns= layout->width / (layout->tile_w + 2*layout->tile_border_x); - if(layout->columns > 0) + if (layout->columns > 0) layout->rows= numfiles/layout->columns + 1; // XXX dirty, modulo is zero else { layout->columns = 1; @@ -510,7 +519,8 @@ void ED_fileselect_init_layout(struct SpaceFile *sfile, struct ARegion *ar) } layout->height= sfile->layout->rows*(layout->tile_h+2*layout->tile_border_y) + layout->tile_border_y*2; layout->flag = FILE_LAYOUT_VER; - } else { + } + else { layout->prv_w = 0; layout->prv_h = 0; layout->tile_border_x = 8; @@ -527,7 +537,8 @@ void ED_fileselect_init_layout(struct SpaceFile *sfile, struct ARegion *ar) maxlen = ICON_DEFAULT_WIDTH_SCALE + 4 + (int)layout->column_widths[COLUMN_NAME] + 12 + (int)layout->column_widths[COLUMN_SIZE] + 12; - } else { + } + else { maxlen = ICON_DEFAULT_WIDTH_SCALE + 4 + (int)layout->column_widths[COLUMN_NAME] + 12 + #ifndef WIN32 @@ -542,7 +553,7 @@ void ED_fileselect_init_layout(struct SpaceFile *sfile, struct ARegion *ar) } layout->tile_w = maxlen; - if(layout->rows > 0) + if (layout->rows > 0) layout->columns = numfiles/layout->rows + 1; // XXX dirty, modulo is zero else { layout->rows = 1; @@ -570,13 +581,13 @@ void file_change_dir(bContext *C, int checkdir) ED_fileselect_clear(C, sfile); - if(checkdir && BLI_is_dir(sfile->params->dir)==0) { + if (checkdir && BLI_is_dir(sfile->params->dir)==0) { 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)) + if (folderlist_clear_next(sfile)) folderlist_free(sfile->folders_next); folderlist_pushdir(sfile->folders_prev, sfile->params->dir); @@ -608,7 +619,7 @@ void autocomplete_directory(struct bContext *C, char *str, void *UNUSED(arg_v)) SpaceFile *sfile= CTX_wm_space_file(C); /* search if str matches the beginning of name */ - if(str[0] && sfile->files) { + if (str[0] && sfile->files) { char dirname[FILE_MAX]; DIR *dir; @@ -618,7 +629,7 @@ void autocomplete_directory(struct bContext *C, char *str, void *UNUSED(arg_v)) dir = opendir(dirname); - if(dir) { + if (dir) { AutoComplete *autocpl= autocomplete_begin(str, FILE_MAX); while ((de = readdir(dir)) != NULL) { @@ -643,7 +654,8 @@ void autocomplete_directory(struct bContext *C, char *str, void *UNUSED(arg_v)) autocomplete_end(autocpl, str); if (BLI_exists(str)) { BLI_add_slash(str); - } else { + } + else { BLI_strncpy(sfile->params->dir, str, sizeof(sfile->params->dir)); } } @@ -655,12 +667,12 @@ void autocomplete_file(struct bContext *C, char *str, void *UNUSED(arg_v)) SpaceFile *sfile= CTX_wm_space_file(C); /* search if str matches the beginning of name */ - if(str[0] && sfile->files) { + if (str[0] && sfile->files) { AutoComplete *autocpl= autocomplete_begin(str, FILE_MAX); int nentries = filelist_numfiles(sfile->files); int i; - for(i= 0; i<nentries; ++i) { + for (i= 0; i<nentries; ++i) { struct direntry* file = filelist_file(sfile->files, i); if (file && S_ISREG(file->type)) { autocomplete_do_name(autocpl, file->relname); @@ -685,8 +697,8 @@ void ED_fileselect_clear(struct bContext *C, struct SpaceFile *sfile) void ED_fileselect_exit(struct bContext *C, struct SpaceFile *sfile) { - if(!sfile) return; - if(sfile->op) { + if (!sfile) return; + if (sfile->op) { WM_event_fileselect_event(C, sfile->op, EVT_FILESELECT_EXTERNAL_CANCEL); sfile->op = NULL; } diff --git a/source/blender/editors/space_file/fsmenu.c b/source/blender/editors/space_file/fsmenu.c index 8b98b942f42..ddd4b31d145 100644 --- a/source/blender/editors/space_file/fsmenu.c +++ b/source/blender/editors/space_file/fsmenu.c @@ -177,7 +177,8 @@ void fsmenu_insert_entry(struct FSMenu* fsmenu, FSMenuCategory category, const c else if (sorted && cmp_ret < 0) { break; } - } else { + } + else { // if we're bookmarking this, file should come // before the last separator, only automatically added // current dir go after the last sep. @@ -194,7 +195,8 @@ void fsmenu_insert_entry(struct FSMenu* fsmenu, FSMenuCategory category, const c if (prev) { fsme->next= prev->next; prev->next= fsme; - } else { + } + else { fsme->next= fsms; fsmenu_set_category(fsmenu, category, fsme); } @@ -217,7 +219,8 @@ void fsmenu_remove_entry(struct FSMenu* fsmenu, FSMenuCategory category, int idx /* remove fsme from list */ if (prev) { prev->next= fsme->next; - } else { + } + else { fsms= fsme->next; fsmenu_set_category(fsmenu, category, fsms); } @@ -267,11 +270,13 @@ void fsmenu_read_bookmarks(struct FSMenu* fsmenu, const char *filename) while ( fgets ( line, 256, fp ) != NULL ) /* read a line */ { - if (strncmp(line, "[Bookmarks]", 11)==0){ + if (strncmp(line, "[Bookmarks]", 11)==0) { category = FS_CATEGORY_BOOKMARKS; - } else if (strncmp(line, "[Recent]", 8)==0){ + } + else if (strncmp(line, "[Recent]", 8)==0) { category = FS_CATEGORY_RECENT; - } else { + } + else { int len = strlen(line); if (len>0) { if (line[len-1] == '\n') { @@ -344,7 +349,7 @@ void fsmenu_read_system(struct FSMenu* fsmenu) * assume they are the standard ones * TODO : replace hardcoded paths with proper BLI_get_folder calls */ home = getenv("HOME"); - if(home) { + if (home) { BLI_snprintf(line, 256, "%s/", home); fsmenu_insert_entry(fsmenu, FS_CATEGORY_BOOKMARKS, line, 1, 0); BLI_snprintf(line, 256, "%s/Desktop/", home); @@ -465,7 +470,7 @@ void fsmenu_read_system(struct FSMenu* fsmenu) { const char *home= getenv("HOME"); - if(home) { + if (home) { BLI_snprintf(line, FILE_MAXDIR, "%s/", home); fsmenu_insert_entry(fsmenu, FS_CATEGORY_BOOKMARKS, line, 1, 0); BLI_snprintf(line, FILE_MAXDIR, "%s/Desktop/", home); @@ -489,11 +494,11 @@ void fsmenu_read_system(struct FSMenu* fsmenu) else { while ((mnt = getmntent (fp))) { /* not sure if this is right, but seems to give the relevant mnts */ - if(strncmp(mnt->mnt_fsname, "/dev", 4)) + if (strncmp(mnt->mnt_fsname, "/dev", 4)) continue; len= strlen(mnt->mnt_dir); - if(len && mnt->mnt_dir[len-1] != '/') { + if (len && mnt->mnt_dir[len-1] != '/') { BLI_snprintf(line, FILE_MAXDIR, "%s/", mnt->mnt_dir); fsmenu_insert_entry(fsmenu, FS_CATEGORY_SYSTEM, line, 1, 0); } @@ -509,7 +514,7 @@ void fsmenu_read_system(struct FSMenu* fsmenu) #endif /* fallback */ - if(!found) + if (!found) fsmenu_insert_entry(fsmenu, FS_CATEGORY_SYSTEM, "/", 1, 0); } } diff --git a/source/blender/editors/space_file/space_file.c b/source/blender/editors/space_file/space_file.c index 8d156aed6b7..0cf15c22efa 100644 --- a/source/blender/editors/space_file/space_file.c +++ b/source/blender/editors/space_file/space_file.c @@ -113,7 +113,7 @@ static void file_free(SpaceLink *sl) { SpaceFile *sfile= (SpaceFile *) sl; - if(sfile->files) { + if (sfile->files) { // XXXXX would need to do thumbnails_stop here, but no context available filelist_freelib(sfile->files); filelist_free(sfile->files); @@ -121,13 +121,13 @@ static void file_free(SpaceLink *sl) sfile->files= NULL; } - if(sfile->folders_prev) { + if (sfile->folders_prev) { folderlist_free(sfile->folders_prev); MEM_freeN(sfile->folders_prev); sfile->folders_prev= NULL; } - if(sfile->folders_next) { + if (sfile->folders_next) { folderlist_free(sfile->folders_next); MEM_freeN(sfile->folders_next); sfile->folders_next= NULL; @@ -151,7 +151,7 @@ static void file_init(struct wmWindowManager *UNUSED(wm), ScrArea *sa) SpaceFile *sfile= (SpaceFile*)sa->spacedata.first; //printf("file_init\n"); - if(sfile->layout) sfile->layout->dirty= TRUE; + if (sfile->layout) sfile->layout->dirty= TRUE; } @@ -169,10 +169,10 @@ static SpaceLink *file_duplicate(SpaceLink *sl) filelist_setdir(sfilen->files, sfilen->params->dir); } - if(sfileo->folders_prev) + if (sfileo->folders_prev) sfilen->folders_prev = folderlist_duplicate(sfileo->folders_prev); - if(sfileo->folders_next) + if (sfileo->folders_next) sfilen->folders_next = folderlist_duplicate(sfileo->folders_next); if (sfileo->layout) { @@ -200,26 +200,29 @@ static void file_refresh(const bContext *C, ScrArea *UNUSED(sa)) if (filelist_empty(sfile->files)) { thumbnails_stop(sfile->files, C); filelist_readdir(sfile->files); - if(params->sort!=FILE_SORT_NONE) { + if (params->sort!=FILE_SORT_NONE) { filelist_sort(sfile->files, params->sort); } BLI_strncpy(params->dir, filelist_dir(sfile->files), FILE_MAX); - if(params->display == FILE_IMGDISPLAY) { + if (params->display == FILE_IMGDISPLAY) { thumbnails_start(sfile->files, C); } - } else { - if(params->sort!=FILE_SORT_NONE) { + } + else { + if (params->sort!=FILE_SORT_NONE) { thumbnails_stop(sfile->files, C); filelist_sort(sfile->files, params->sort); - if(params->display == FILE_IMGDISPLAY) { + if (params->display == FILE_IMGDISPLAY) { thumbnails_start(sfile->files, C); } - } else { - if(params->display == FILE_IMGDISPLAY) { + } + else { + if (params->display == FILE_IMGDISPLAY) { if (!thumbnails_running(sfile->files,C)) { thumbnails_start(sfile->files, C); } - } else { + } + else { /* stop any running thumbnail jobs if we're not * displaying them - speedup for NFS */ thumbnails_stop(sfile->files, C); @@ -333,7 +336,7 @@ static void file_main_area_draw(const bContext *C, ARegion *ar) /* 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) { + if (v2d->cur.ymax < 0) { v2d->cur.ymin -= v2d->cur.ymax; v2d->cur.ymax = 0; } |