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/file_ops.c | |
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/file_ops.c')
-rw-r--r-- | source/blender/editors/space_file/file_ops.c | 122 |
1 files changed, 65 insertions, 57 deletions
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); |