From 2c3165fdc01092b41d14adb94073f10073ba6c3b Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 18 Jun 2012 13:01:24 +0000 Subject: style cleanup --- source/blender/editors/space_file/file_draw.c | 118 +++--- source/blender/editors/space_file/file_intern.h | 12 +- source/blender/editors/space_file/file_ops.c | 335 ++++++++------- source/blender/editors/space_file/file_panels.c | 74 ++-- source/blender/editors/space_file/filelist.c | 516 ++++++++++++------------ source/blender/editors/space_file/filelist.h | 82 ++-- source/blender/editors/space_file/filesel.c | 208 +++++----- source/blender/editors/space_file/fsmenu.c | 6 +- source/blender/editors/space_file/fsmenu.h | 52 +-- source/blender/editors/space_file/space_file.c | 142 +++---- 10 files changed, 772 insertions(+), 773 deletions(-) (limited to 'source') diff --git a/source/blender/editors/space_file/file_draw.c b/source/blender/editors/space_file/file_draw.c index 10db1bb1f12..55e75992b89 100644 --- a/source/blender/editors/space_file/file_draw.c +++ b/source/blender/editors/space_file/file_draw.c @@ -71,7 +71,7 @@ #include "fsmenu.h" #include "filelist.h" -#include "file_intern.h" // own include +#include "file_intern.h" // own include /* button events */ enum { @@ -109,8 +109,8 @@ void file_draw_buttons(const bContext *C, ARegion *ar) { /* Button layout. */ const int max_x = ar->winx - 10; - const int line1_y = ar->winy - (IMASEL_BUTTONS_HEIGHT/2 + IMASEL_BUTTONS_MARGIN); - const int line2_y = line1_y - (IMASEL_BUTTONS_HEIGHT/2 + IMASEL_BUTTONS_MARGIN); + const int line1_y = ar->winy - (IMASEL_BUTTONS_HEIGHT / 2 + IMASEL_BUTTONS_MARGIN); + const int line2_y = line1_y - (IMASEL_BUTTONS_HEIGHT / 2 + IMASEL_BUTTONS_MARGIN); const int input_minw = 20; const int btn_h = UI_UNIT_Y; const int btn_fn_w = UI_UNIT_X; @@ -123,16 +123,16 @@ void file_draw_buttons(const bContext *C, ARegion *ar) int loadbutton; int fnumbuttons; int min_x = 10; - int chan_offs = 0; + int chan_offs = 0; 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; + uiBut *but; + uiBlock *block; + SpaceFile *sfile = CTX_wm_space_file(C); + FileSelectParams *params = ED_fileselect_get_params(sfile); + ARegion *artmp; /* Initialize UI block. */ BLI_snprintf(uiblockstr, sizeof(uiblockstr), "win %p", (void *)ar); @@ -140,7 +140,7 @@ void file_draw_buttons(const bContext *C, ARegion *ar) uiBlockSetHandleFunc(block, do_file_buttons, NULL); /* exception to make space for collapsed region icon */ - for (artmp=CTX_wm_area(C)->regionbase.first; artmp; artmp=artmp->next) { + for (artmp = CTX_wm_area(C)->regionbase.first; artmp; artmp = artmp->next) { if (artmp->regiontype == RGN_TYPE_CHANNELS && artmp->flag & RGN_FLAG_HIDDEN) { chan_offs = 16; min_x += chan_offs; @@ -152,7 +152,7 @@ void file_draw_buttons(const bContext *C, ARegion *ar) loadbutton = UI_GetStringWidth(sfile->params->title) + btn_margin; if (loadbutton < btn_minw) { loadbutton = MAX2(btn_minw, - btn_margin + UI_GetStringWidth(params->title)); + btn_margin + UI_GetStringWidth(params->title)); } if (available_w <= loadbutton + separator + input_minw || params->title[0] == 0) { @@ -174,12 +174,12 @@ void file_draw_buttons(const bContext *C, ARegion *ar) /* Text input fields for directory and file. */ if (available_w > 0) { - int overwrite_alert= file_draw_check_exists(sfile); + int overwrite_alert = file_draw_check_exists(sfile); /* callbacks for operator check functions */ uiBlockSetFunc(block, file_draw_check_cb, NULL, NULL); but = uiDefButTextO(block, TEX, "FILE_OT_directory", 0, "", - min_x, line1_y, line1_w-chan_offs, btn_h, + min_x, line1_y, line1_w - chan_offs, btn_h, params->dir, 0.0, (float)FILE_MAX, 0, 0, TIP_("File path")); uiButSetCompleteFunc(but, autocomplete_directory, NULL); @@ -187,9 +187,9 @@ void file_draw_buttons(const bContext *C, ARegion *ar) if ((params->flag & FILE_DIRSEL_ONLY) == 0) { but = uiDefBut(block, TEX, B_FS_FILENAME, "", - min_x, line2_y, line2_w-chan_offs, btn_h, + min_x, line2_y, line2_w - chan_offs, btn_h, params->file, 0.0, (float)FILE_MAXFILE, 0, 0, - TIP_(overwrite_alert ?N_("File name, overwrite existing") : N_("File name"))); + TIP_(overwrite_alert ? N_("File name, overwrite existing") : N_("File name"))); uiButSetCompleteFunc(but, autocomplete_file, NULL); uiButSetFlag(but, UI_BUT_NO_UTF8); uiButClearFlag(but, UI_BUT_UNDO); /* operator button above does this automatic */ @@ -246,8 +246,8 @@ static void draw_tile(int sx, int sy, int width, int height, int colorid, int sh static int get_file_icon(struct direntry *file) { if (file->type & S_IFDIR) { - if ( strcmp(file->relname, "..") == 0) { - return ICON_FILE_PARENT; + if (strcmp(file->relname, "..") == 0) { + return ICON_FILE_PARENT; } if (file->flags & BLENDERFILE) { return ICON_FILE_BLEND; @@ -283,7 +283,7 @@ static void file_draw_icon(uiBlock *block, char *path, int sx, int sy, int icon, /*float alpha=1.0f;*/ x = sx; - y = sy-height; + y = sy - height; /*if (icon == ICON_FILE_BLANK) alpha = 0.375f;*/ @@ -292,9 +292,9 @@ static void file_draw_icon(uiBlock *block, char *path, int sx, int sy, int icon, } -static void file_draw_string(int sx, int sy, const char* string, float width, int height, short align) +static void file_draw_string(int sx, int sy, const char *string, float width, int height, short align) { - uiStyle *style= UI_GetStyle(); + uiStyle *style = UI_GetStyle(); uiFontStyle fs = style->widgetlabel; rcti rect; char fname[FILE_MAXFILE]; @@ -306,7 +306,7 @@ static void file_draw_string(int sx, int sy, const char* string, float width, in /* no text clipping needed, uiStyleFontDraw does it but is a bit too strict (for buttons it works) */ rect.xmin = sx; - rect.xmax = (int)(sx + ceil(width+4.0f)); + rect.xmax = (int)(sx + ceil(width + 4.0f)); rect.ymin = sy - height; rect.ymax = sy; @@ -315,12 +315,12 @@ static void file_draw_string(int sx, int sy, const char* string, float width, in void file_calc_previews(const bContext *C, ARegion *ar) { - SpaceFile *sfile= CTX_wm_space_file(C); - View2D *v2d= &ar->v2d; + SpaceFile *sfile = CTX_wm_space_file(C); + View2D *v2d = &ar->v2d; ED_fileselect_init_layout(sfile, ar); /* +SCROLL_HEIGHT is bad hack to work around issue in UI_view2d_totRect_set */ - UI_view2d_totRect_set(v2d, sfile->layout->width, sfile->layout->height+V2D_SCROLL_HEIGHT); + UI_view2d_totRect_set(v2d, sfile->layout->width, sfile->layout->height + V2D_SCROLL_HEIGHT); } static void file_draw_preview(uiBlock *block, struct direntry *file, int sx, int sy, ImBuf *imb, FileLayout *layout, short dropshadow) @@ -337,13 +337,13 @@ static void file_draw_preview(uiBlock *block, struct direntry *file, int sx, int if ( (imb->x > layout->prv_w) || (imb->y > layout->prv_h) ) { if (imb->x > imb->y) { scaledx = (float)layout->prv_w; - scaledy = ( (float)imb->y/(float)imb->x )*layout->prv_w; - scale = scaledx/imb->x; + scaledy = ( (float)imb->y / (float)imb->x) * layout->prv_w; + scale = scaledx / imb->x; } else { scaledy = (float)layout->prv_h; - scaledx = ( (float)imb->x/(float)imb->y )*layout->prv_h; - scale = scaledy/imb->y; + scaledx = ( (float)imb->x / (float)imb->y) * layout->prv_h; + scale = scaledy / imb->y; } } else { @@ -353,8 +353,8 @@ static void file_draw_preview(uiBlock *block, struct direntry *file, int sx, int } ex = (int)scaledx; ey = (int)scaledy; - fx = ((float)layout->prv_w - (float)ex)/2.0f; - fy = ((float)layout->prv_h - (float)ey)/2.0f; + fx = ((float)layout->prv_w - (float)ex) / 2.0f; + fy = ((float)layout->prv_h - (float)ey) / 2.0f; dx = (fx + 0.5f + layout->prv_border_x); dy = (fy + 0.5f - layout->prv_border_y); xco = sx + (int)dx; @@ -389,17 +389,17 @@ static void file_draw_preview(uiBlock *block, struct direntry *file, int sx, int static void renamebutton_cb(bContext *C, void *UNUSED(arg1), char *oldname) { - char newname[FILE_MAX+12]; - char orgname[FILE_MAX+12]; - char filename[FILE_MAX+12]; - SpaceFile *sfile= (SpaceFile*)CTX_wm_space_data(C); - ARegion* ar = CTX_wm_region(C); + char newname[FILE_MAX + 12]; + char orgname[FILE_MAX + 12]; + char filename[FILE_MAX + 12]; + SpaceFile *sfile = (SpaceFile *)CTX_wm_space_data(C); + ARegion *ar = CTX_wm_region(C); BLI_make_file_string(G.main->name, orgname, sfile->params->dir, 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 */ @@ -417,11 +417,11 @@ static void draw_background(FileLayout *layout, View2D *v2d) int sy; /* alternating flat shade background */ - for (i=0; (i <= layout->rows); i+=2) { - sy = (int)v2d->cur.ymax - i*(layout->tile_h+2*layout->tile_border_y) - layout->tile_border_y; + for (i = 0; (i <= layout->rows); i += 2) { + sy = (int)v2d->cur.ymax - i * (layout->tile_h + 2 * layout->tile_border_y) - layout->tile_border_y; UI_ThemeColorShade(TH_BACK, -7); - glRectf(v2d->cur.xmin, (float)sy, v2d->cur.xmax, (float)(sy+layout->tile_h+2*layout->tile_border_y)); + glRectf(v2d->cur.xmin, (float)sy, v2d->cur.xmax, (float)(sy + layout->tile_h + 2 * layout->tile_border_y)); } } @@ -433,10 +433,10 @@ static void draw_dividers(FileLayout *layout, View2D *v2d) /* vertical column dividers */ sx = (int)v2d->tot.xmin; while (sx < v2d->cur.xmax) { - sx += (layout->tile_w+2*layout->tile_border_x); + sx += (layout->tile_w + 2 * layout->tile_border_x); UI_ThemeColorShade(TH_BACK, 30); - sdrawline(sx+1, (short)(v2d->cur.ymax - layout->tile_border_y), sx+1, (short)v2d->cur.ymin); + sdrawline(sx + 1, (short)(v2d->cur.ymax - layout->tile_border_y), sx + 1, (short)v2d->cur.ymin); UI_ThemeColorShade(TH_BACK, -30); sdrawline(sx, (short)(v2d->cur.ymax - layout->tile_border_y), sx, (short)v2d->cur.ymin); } @@ -444,11 +444,11 @@ static void draw_dividers(FileLayout *layout, View2D *v2d) void file_draw_list(const bContext *C, ARegion *ar) { - SpaceFile *sfile= CTX_wm_space_file(C); - FileSelectParams* params = ED_fileselect_get_params(sfile); - FileLayout* layout= ED_fileselect_get_layout(sfile, ar); - View2D *v2d= &ar->v2d; - struct FileList* files = sfile->files; + SpaceFile *sfile = CTX_wm_space_file(C); + FileSelectParams *params = ED_fileselect_get_params(sfile); + FileLayout *layout = ED_fileselect_get_layout(sfile, ar); + View2D *v2d = &ar->v2d; + struct FileList *files = sfile->files; struct direntry *file; ImBuf *imb; uiBlock *block = uiBeginBlock(C, ar, __func__, UI_EMBOSS); @@ -472,7 +472,7 @@ void file_draw_list(const bContext *C, ARegion *ar) } offset = ED_fileselect_layout_offset(layout, (int)ar->v2d.cur.xmin, (int)-ar->v2d.cur.ymax); - if (offset<0) offset=0; + if (offset < 0) offset = 0; numfiles_layout = ED_fileselect_layout_numfiles(layout, ar); @@ -484,14 +484,14 @@ void file_draw_list(const bContext *C, ARegion *ar) numfiles_layout += layout->columns; } - textwidth =( FILE_IMGDISPLAY == params->display) ? layout->tile_w : (int)layout->column_widths[COLUMN_NAME]; - textheight = (int)(layout->textheight*3.0/2.0 + 0.5); + textwidth = (FILE_IMGDISPLAY == params->display) ? layout->tile_w : (int)layout->column_widths[COLUMN_NAME]; + textheight = (int)(layout->textheight * 3.0 / 2.0 + 0.5); - align = ( FILE_IMGDISPLAY == params->display) ? UI_STYLE_TEXT_CENTER : UI_STYLE_TEXT_LEFT; + align = (FILE_IMGDISPLAY == params->display) ? UI_STYLE_TEXT_CENTER : UI_STYLE_TEXT_LEFT; - for (i = offset; (i < numfiles) && (itot.xmin+2.0f); + sx += (int)(v2d->tot.xmin + 2.0f); sy = (int)(v2d->tot.ymax - sy); file = filelist_file(files, i); @@ -503,12 +503,12 @@ void file_draw_list(const bContext *C, ARegion *ar) if ((params->active_file == i) || (file->selflag & HILITED_FILE) || (file->selflag & SELECTED_FILE)) { int colorid = (file->selflag & SELECTED_FILE) ? TH_HILITE : TH_BACK; int shade = (params->active_file == i) || (file->selflag & HILITED_FILE) ? 20 : 0; - draw_tile(sx, sy-1, layout->tile_w+4, sfile->layout->tile_h+layout->tile_border_y, colorid, shade); + draw_tile(sx, sy - 1, layout->tile_w + 4, sfile->layout->tile_h + layout->tile_border_y, colorid, shade); } } uiSetRoundBox(UI_CNR_NONE); - if ( FILE_IMGDISPLAY == params->display ) { + if (FILE_IMGDISPLAY == params->display) { is_icon = 0; imb = filelist_getimage(files, i); if (!imb) { @@ -519,26 +519,26 @@ void file_draw_list(const bContext *C, ARegion *ar) file_draw_preview(block, file, sx, sy, imb, layout, !is_icon && (file->flags & IMAGEFILE)); } 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); + 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; } UI_ThemeColor4(TH_TEXT); if (file->selflag & EDITING_FILE) { - uiBut *but = uiDefBut(block, TEX, 1, "", sx, sy-layout->tile_h-3, - textwidth, textheight, sfile->params->renameedit, 1.0f, (float)sizeof(sfile->params->renameedit), 0, 0, ""); + uiBut *but = uiDefBut(block, TEX, 1, "", sx, sy - layout->tile_h - 3, + textwidth, textheight, sfile->params->renameedit, 1.0f, (float)sizeof(sfile->params->renameedit), 0, 0, ""); uiButSetRenameFunc(but, renamebutton_cb, file); uiButSetFlag(but, UI_BUT_NO_UTF8); /* allow non utf8 names */ uiButClearFlag(but, UI_BUT_UNDO); - if ( 0 == uiButActiveOnly(C, block, but)) { + if (0 == uiButActiveOnly(C, block, but)) { file->selflag &= ~EDITING_FILE; } } if (!(file->selflag & EDITING_FILE)) { int tpos = (FILE_IMGDISPLAY == params->display) ? sy - layout->tile_h + layout->textheight : sy; - file_draw_string(sx+1, tpos, file->relname, (float)textwidth, textheight, align); + file_draw_string(sx + 1, tpos, file->relname, (float)textwidth, textheight, align); } if (params->display == FILE_SHORTDISPLAY) { diff --git a/source/blender/editors/space_file/file_intern.h b/source/blender/editors/space_file/file_intern.h index df05d0518bd..3ad6614d356 100644 --- a/source/blender/editors/space_file/file_intern.h +++ b/source/blender/editors/space_file/file_intern.h @@ -41,12 +41,12 @@ struct SpaceFile; struct ARegion *file_buttons_region(struct ScrArea *sa); /* file_draw.c */ -#define TILE_BORDER_X (UI_UNIT_X/4) -#define TILE_BORDER_Y (UI_UNIT_Y/4) +#define TILE_BORDER_X (UI_UNIT_X / 4) +#define TILE_BORDER_Y (UI_UNIT_Y / 4) /* ui geometry */ -#define IMASEL_BUTTONS_HEIGHT (UI_UNIT_Y*2) -#define IMASEL_BUTTONS_MARGIN (UI_UNIT_Y/6) +#define IMASEL_BUTTONS_HEIGHT (UI_UNIT_Y * 2) +#define IMASEL_BUTTONS_MARGIN (UI_UNIT_Y / 6) void file_draw_buttons(const bContext *C, ARegion *ar); void file_calc_previews(const bContext *C, ARegion *ar); @@ -98,8 +98,8 @@ void file_operator_to_sfile(struct SpaceFile *sfile, struct wmOperator *op); /* filesel.c */ -float file_shorten_string(char* string, float w, int front); -float file_string_width(const char* str); +float file_shorten_string(char *string, float w, int front); +float file_string_width(const char *str); float file_font_pointsize(void); void file_change_dir(bContext *C, int checkdir); diff --git a/source/blender/editors/space_file/file_ops.c b/source/blender/editors/space_file/file_ops.c index cd523b3f8a4..e2fc1b64223 100644 --- a/source/blender/editors/space_file/file_ops.c +++ b/source/blender/editors/space_file/file_ops.c @@ -65,17 +65,17 @@ #include /* for events */ -#define NOTACTIVEFILE 0 -#define ACTIVATE 1 -#define INACTIVATE 2 +#define NOTACTIVEFILE 0 +#define ACTIVATE 1 +#define INACTIVATE 2 /* ---------- FILE SELECTION ------------ */ -static FileSelection find_file_mouse_rect(SpaceFile *sfile, struct ARegion* ar, const rcti* rect) +static FileSelection find_file_mouse_rect(SpaceFile *sfile, struct ARegion *ar, const rcti *rect) { FileSelection sel; float fxmin, fymin, fxmax, fymax; - View2D* v2d = &ar->v2d; + View2D *v2d = &ar->v2d; rcti rect_view; UI_view2d_region_to_view(v2d, rect->xmin, rect->ymin, &fxmin, &fymin); @@ -88,11 +88,11 @@ static FileSelection find_file_mouse_rect(SpaceFile *sfile, struct ARegion* ar, return sel; } -static void file_deselect_all(SpaceFile* sfile, unsigned int flag) +static void file_deselect_all(SpaceFile *sfile, unsigned int flag) { FileSelection sel; sel.first = 0; - sel.last = filelist_numfiles(sfile->files)-1; + sel.last = filelist_numfiles(sfile->files) - 1; filelist_select(sfile->files, &sel, FILE_SEL_REMOVE, flag, CHECK_ALL); } @@ -103,10 +103,10 @@ typedef enum FileSelect { FILE_SELECT_FILE = 2 } FileSelect; -static void clamp_to_filelist(int numfiles, FileSelection* sel) +static void clamp_to_filelist(int numfiles, FileSelection *sel) { /* border select before the first file */ - if ( (sel->first < 0) && (sel->last >=0 ) ) { + if ( (sel->first < 0) && (sel->last >= 0) ) { sel->first = 0; } /* don't select if everything is outside filelist */ @@ -117,67 +117,67 @@ static void clamp_to_filelist(int numfiles, FileSelection* sel) /* fix if last file invalid */ if ( (sel->first > 0) && (sel->last < 0) ) - sel->last = numfiles-1; + sel->last = numfiles - 1; /* clamp */ if ( (sel->first >= numfiles) ) { - sel->first = numfiles-1; + sel->first = numfiles - 1; } if ( (sel->last >= numfiles) ) { - sel->last = numfiles-1; + sel->last = numfiles - 1; } } -static FileSelection file_selection_get(bContext* C, const rcti* rect, short fill) +static FileSelection file_selection_get(bContext *C, const rcti *rect, short fill) { - ARegion *ar= CTX_wm_region(C); - SpaceFile *sfile= CTX_wm_space_file(C); + ARegion *ar = CTX_wm_region(C); + SpaceFile *sfile = CTX_wm_space_file(C); int numfiles = filelist_numfiles(sfile->files); FileSelection sel; sel = find_file_mouse_rect(sfile, ar, rect); - if ( !((sel.first == -1) && (sel.last == -1)) ) { + if (!((sel.first == -1) && (sel.last == -1)) ) { clamp_to_filelist(numfiles, &sel); } /* if desired, fill the selection up from the last selected file to the current one */ if (fill && (sel.last >= 0) && (sel.last < numfiles) ) { - int f= sel.last; + int f = sel.last; while (f >= 0) { - if ( filelist_is_selected(sfile->files, f, CHECK_ALL) ) + if (filelist_is_selected(sfile->files, f, CHECK_ALL) ) break; f--; } if (f >= 0) { - sel.first = f+1; + sel.first = f + 1; } } return sel; } -static FileSelect file_select_do(bContext* C, int selected_idx) +static FileSelect file_select_do(bContext *C, int selected_idx) { FileSelect retval = FILE_SELECT_NOTHING; - SpaceFile *sfile= CTX_wm_space_file(C); + SpaceFile *sfile = CTX_wm_space_file(C); FileSelectParams *params = ED_fileselect_get_params(sfile); int numfiles = filelist_numfiles(sfile->files); - struct direntry* file; + struct direntry *file; /* make the selected file active */ - if ( (selected_idx >= 0) && - (selected_idx < numfiles) && - (file= filelist_file(sfile->files, selected_idx))) + if ((selected_idx >= 0) && + (selected_idx < numfiles) && + (file = filelist_file(sfile->files, selected_idx))) { params->active_file = selected_idx; 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 ) { + if (strcmp(file->relname, "..") && strlen(params->dir) + strlen(file->relname) >= FILE_MAX) { // XXX error("Path too long, cannot enter this directory"); } else { - if (strcmp(file->relname, "..")==0) { + if (strcmp(file->relname, "..") == 0) { /* avoids /../../ */ BLI_parent_dir(params->dir); } @@ -202,12 +202,12 @@ static FileSelect file_select_do(bContext* C, int selected_idx) } -static FileSelect file_select(bContext* C, const rcti* rect, FileSelType select, short fill) +static FileSelect file_select(bContext *C, const rcti *rect, FileSelType select, short fill) { - SpaceFile *sfile= CTX_wm_space_file(C); + SpaceFile *sfile = CTX_wm_space_file(C); FileSelect retval = FILE_SELECT_NOTHING; - FileSelection sel= file_selection_get(C, rect, fill); /* get the selection */ - const FileCheckType check_type= (sfile->params->flag & FILE_DIRSEL_ONLY) ? CHECK_DIRS : CHECK_ALL; + FileSelection sel = file_selection_get(C, rect, fill); /* get the selection */ + const FileCheckType check_type = (sfile->params->flag & FILE_DIRSEL_ONLY) ? CHECK_DIRS : CHECK_ALL; /* flag the files as selected in the filelist */ filelist_select(sfile->files, &sel, select, SELECTED_FILE, check_type); @@ -231,15 +231,15 @@ static FileSelect file_select(bContext* C, const rcti* rect, FileSelType select, static int file_border_select_modal(bContext *C, wmOperator *op, wmEvent *event) { - ARegion *ar= CTX_wm_region(C); - SpaceFile *sfile= CTX_wm_space_file(C); + ARegion *ar = CTX_wm_region(C); + SpaceFile *sfile = CTX_wm_space_file(C); FileSelectParams *params = ED_fileselect_get_params(sfile); FileSelection sel; rcti rect; int result; - result= WM_border_select_modal(C, op, event); + result = WM_border_select_modal(C, op, event); if (result == OPERATOR_RUNNING_MODAL) { @@ -254,7 +254,7 @@ static int file_border_select_modal(bContext *C, wmOperator *op, wmEvent *event) if ( (sel.first != params->sel_first) || (sel.last != params->sel_last) ) { file_deselect_all(sfile, HILITED_FILE); filelist_select(sfile->files, &sel, FILE_SEL_ADD, HILITED_FILE, CHECK_ALL); - WM_event_add_notifier(C, NC_SPACE|ND_SPACE_FILE_PARAMS, NULL); + WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_PARAMS, NULL); } params->sel_first = sel.first; params->sel_last = sel.last; @@ -263,7 +263,7 @@ static int file_border_select_modal(bContext *C, wmOperator *op, wmEvent *event) params->active_file = -1; params->sel_first = params->sel_last = -1; file_deselect_all(sfile, HILITED_FILE); - WM_event_add_notifier(C, NC_SPACE|ND_SPACE_FILE_PARAMS, NULL); + WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_PARAMS, NULL); } return result; @@ -271,11 +271,11 @@ static int file_border_select_modal(bContext *C, wmOperator *op, wmEvent *event) static int file_border_select_exec(bContext *C, wmOperator *op) { - ARegion *ar= CTX_wm_region(C); + ARegion *ar = CTX_wm_region(C); rcti rect; FileSelect ret; - int extend= RNA_boolean_get(op->ptr, "extend"); - short select= (RNA_int_get(op->ptr, "gesture_mode")==GESTURE_MODAL_SELECT); + int extend = RNA_boolean_get(op->ptr, "extend"); + short select = (RNA_int_get(op->ptr, "gesture_mode") == GESTURE_MODAL_SELECT); rect.xmin = RNA_int_get(op->ptr, "xmin"); rect.ymin = RNA_int_get(op->ptr, "ymin"); @@ -283,7 +283,7 @@ static int file_border_select_exec(bContext *C, wmOperator *op) rect.ymax = RNA_int_get(op->ptr, "ymax"); if (!extend) { - SpaceFile *sfile= CTX_wm_space_file(C); + SpaceFile *sfile = CTX_wm_space_file(C); file_deselect_all(sfile, SELECTED_FILE); } @@ -292,10 +292,10 @@ 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); + WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_LIST, NULL); } else if (FILE_SELECT_FILE == ret) { - WM_event_add_notifier(C, NC_SPACE|ND_SPACE_FILE_PARAMS, NULL); + WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_PARAMS, NULL); } return OPERATOR_FINISHED; } @@ -320,8 +320,8 @@ void FILE_OT_select_border(wmOperatorType *ot) static int file_select_invoke(bContext *C, wmOperator *op, wmEvent *event) { - ARegion *ar= CTX_wm_region(C); - SpaceFile *sfile= CTX_wm_space_file(C); + ARegion *ar = CTX_wm_region(C); + SpaceFile *sfile = CTX_wm_space_file(C); FileSelect ret; rcti rect; int extend = RNA_boolean_get(op->ptr, "extend"); @@ -341,12 +341,12 @@ static int file_select_invoke(bContext *C, wmOperator *op, wmEvent *event) ret = file_select(C, &rect, extend ? FILE_SEL_TOGGLE : FILE_SEL_ADD, fill); if (FILE_SELECT_DIR == ret) - WM_event_add_notifier(C, NC_SPACE|ND_SPACE_FILE_LIST, NULL); + WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_LIST, NULL); else if (FILE_SELECT_FILE == ret) - WM_event_add_notifier(C, NC_SPACE|ND_SPACE_FILE_PARAMS, NULL); + WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_PARAMS, NULL); WM_event_add_mousemove(C); /* for directory changes */ - WM_event_add_notifier(C, NC_SPACE|ND_SPACE_FILE_PARAMS, NULL); + WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_PARAMS, NULL); return OPERATOR_FINISHED; } @@ -369,18 +369,18 @@ void FILE_OT_select(wmOperatorType *ot) static int file_select_all_exec(bContext *C, wmOperator *UNUSED(op)) { - ScrArea *sa= CTX_wm_area(C); - SpaceFile *sfile= CTX_wm_space_file(C); + ScrArea *sa = CTX_wm_area(C); + SpaceFile *sfile = CTX_wm_space_file(C); FileSelection sel; int numfiles = filelist_numfiles(sfile->files); int i; int is_selected = 0; sel.first = 0; - sel.last = numfiles-1; + sel.last = numfiles - 1; /* Is any file selected ? */ - for ( i=0; i < numfiles; ++i) { + for (i = 0; i < numfiles; ++i) { if (filelist_is_selected(sfile->files, i, CHECK_ALL)) { is_selected = 1; break; @@ -391,7 +391,7 @@ static int file_select_all_exec(bContext *C, wmOperator *UNUSED(op)) filelist_select(sfile->files, &sel, FILE_SEL_REMOVE, SELECTED_FILE, CHECK_ALL); } else { - const FileCheckType check_type= (sfile->params->flag & FILE_DIRSEL_ONLY) ? CHECK_DIRS : CHECK_FILES; + const FileCheckType check_type = (sfile->params->flag & FILE_DIRSEL_ONLY) ? CHECK_DIRS : CHECK_FILES; filelist_select(sfile->files, &sel, FILE_SEL_ADD, SELECTED_FILE, check_type); } ED_area_tag_redraw(sa); @@ -418,18 +418,18 @@ void FILE_OT_select_all_toggle(wmOperatorType *ot) static int bookmark_select_exec(bContext *C, wmOperator *op) { - SpaceFile *sfile= CTX_wm_space_file(C); + SpaceFile *sfile = CTX_wm_space_file(C); if (RNA_struct_find_property(op->ptr, "dir")) { char entry[256]; - FileSelectParams* params = sfile->params; + FileSelectParams *params = sfile->params; RNA_string_get(op->ptr, "dir", entry); BLI_strncpy(params->dir, entry, sizeof(params->dir)); BLI_cleanup_dir(G.main->name, params->dir); file_change_dir(C, 1); - WM_event_add_notifier(C, NC_SPACE|ND_SPACE_FILE_LIST, NULL); + WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_LIST, NULL); } return OPERATOR_FINISHED; @@ -451,10 +451,10 @@ void FILE_OT_select_bookmark(wmOperatorType *ot) static int bookmark_add_exec(bContext *C, wmOperator *UNUSED(op)) { - ScrArea *sa= CTX_wm_area(C); - SpaceFile *sfile= CTX_wm_space_file(C); - struct FSMenu* fsmenu = fsmenu_get(); - struct FileSelectParams* params= ED_fileselect_get_params(sfile); + ScrArea *sa = CTX_wm_area(C); + SpaceFile *sfile = CTX_wm_space_file(C); + struct FSMenu *fsmenu = fsmenu_get(); + struct FileSelectParams *params = ED_fileselect_get_params(sfile); if (params->dir[0] != '\0') { char name[FILE_MAX]; @@ -482,13 +482,13 @@ void FILE_OT_bookmark_add(wmOperatorType *ot) static int bookmark_delete_exec(bContext *C, wmOperator *op) { - ScrArea *sa= CTX_wm_area(C); - struct FSMenu* fsmenu = fsmenu_get(); + ScrArea *sa = CTX_wm_area(C); + struct FSMenu *fsmenu = fsmenu_get(); int nentries = fsmenu_get_nentries(fsmenu, FS_CATEGORY_BOOKMARKS); if (RNA_struct_find_property(op->ptr, "index")) { int index = RNA_int_get(op->ptr, "index"); - if ( (index >-1) && (index < nentries)) { + if ( (index > -1) && (index < nentries)) { char name[FILE_MAX]; fsmenu_remove_entry(fsmenu, FS_CATEGORY_BOOKMARKS, index); @@ -517,16 +517,16 @@ void FILE_OT_delete_bookmark(wmOperatorType *ot) int file_hilight_set(SpaceFile *sfile, ARegion *ar, int mx, int my) { - View2D* v2d = &ar->v2d; - FileSelectParams* params; + View2D *v2d = &ar->v2d; + 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); - origfile= params->active_file; + origfile = params->active_file; mx -= ar->winrct.xmin; my -= ar->winrct.ymin; @@ -540,20 +540,20 @@ 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)) - params->active_file=active_file; + params->active_file = active_file; else - params->active_file= -1; + params->active_file = -1; } else - params->active_file= -1; + params->active_file = -1; return (params->active_file != origfile); } static int file_highlight_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *event) { - ARegion *ar= CTX_wm_region(C); - SpaceFile *sfile= CTX_wm_space_file(C); + ARegion *ar = CTX_wm_region(C); + SpaceFile *sfile = CTX_wm_space_file(C); if (!file_hilight_set(sfile, ar, event->x, event->y)) return OPERATOR_CANCELLED; @@ -577,7 +577,7 @@ void FILE_OT_highlight(struct wmOperatorType *ot) int file_cancel_exec(bContext *C, wmOperator *UNUSED(unused)) { - SpaceFile *sfile= CTX_wm_space_file(C); + SpaceFile *sfile = CTX_wm_space_file(C); wmOperator *op = sfile->op; sfile->op = NULL; @@ -590,9 +590,9 @@ int file_cancel_exec(bContext *C, wmOperator *UNUSED(unused)) static int file_operator_poll(bContext *C) { int poll = ED_operator_file_active(C); - SpaceFile *sfile= CTX_wm_space_file(C); + SpaceFile *sfile = CTX_wm_space_file(C); - if (!sfile || !sfile->op) poll= 0; + if (!sfile || !sfile->op) poll = 0; return poll; } @@ -634,16 +634,16 @@ void file_sfile_to_operator(wmOperator *op, SpaceFile *sfile, char *filepath) * they may be already set. */ { PointerRNA itemptr; - PropertyRNA *prop_files= RNA_struct_find_property(op->ptr, "files"); - PropertyRNA *prop_dirs= RNA_struct_find_property(op->ptr, "dirs"); + PropertyRNA *prop_files = RNA_struct_find_property(op->ptr, "files"); + PropertyRNA *prop_dirs = RNA_struct_find_property(op->ptr, "dirs"); int i, numfiles = filelist_numfiles(sfile->files); if (prop_files) { int num_files = 0; RNA_property_collection_clear(op->ptr, prop_files); - for (i=0; ifiles, i, CHECK_FILES)) { - struct direntry *file= filelist_file(sfile->files, i); + struct direntry *file = filelist_file(sfile->files, i); RNA_property_collection_add(op->ptr, prop_files, &itemptr); RNA_string_set(&itemptr, "name", file->relname); num_files++; @@ -659,9 +659,9 @@ void file_sfile_to_operator(wmOperator *op, SpaceFile *sfile, char *filepath) if (prop_dirs) { int num_dirs = 0; RNA_property_collection_clear(op->ptr, prop_dirs); - for (i=0; ifiles, i, CHECK_DIRS)) { - struct direntry *file= filelist_file(sfile->files, i); + struct direntry *file = filelist_file(sfile->files, i); RNA_property_collection_add(op->ptr, prop_dirs, &itemptr); RNA_string_set(&itemptr, "name", file->relname); num_dirs++; @@ -684,16 +684,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); } } @@ -707,8 +707,8 @@ void file_operator_to_sfile(SpaceFile *sfile, wmOperator *op) void file_draw_check_cb(bContext *C, void *UNUSED(arg1), void *UNUSED(arg2)) { - SpaceFile *sfile= CTX_wm_space_file(C); - wmOperator *op= sfile->op; + SpaceFile *sfile = CTX_wm_space_file(C); + wmOperator *op = sfile->op; if (op) { /* fail on reload */ if (op->type->check) { char filepath[FILE_MAX]; @@ -745,20 +745,20 @@ int file_draw_check_exists(SpaceFile *sfile) /* sends events now, so things get handled on windowqueue level */ int file_exec(bContext *C, wmOperator *exec_op) { - SpaceFile *sfile= CTX_wm_space_file(C); + SpaceFile *sfile = CTX_wm_space_file(C); char filepath[FILE_MAX]; if (sfile->op) { - wmOperator *op= sfile->op; + wmOperator *op = sfile->op; /* when used as a macro, for doubleclick, * to prevent closing when doubleclicking on .. item */ if (RNA_boolean_get(exec_op->ptr, "need_active")) { - int i, active=0; + int i, active = 0; - for (i=0; ifiles); i++) { + for (i = 0; i < filelist_numfiles(sfile->files); i++) { if (filelist_is_selected(sfile->files, i, CHECK_ALL)) { - active=1; + active = 1; break; } } @@ -803,14 +803,14 @@ void FILE_OT_execute(struct wmOperatorType *ot) int file_parent_exec(bContext *C, wmOperator *UNUSED(unused)) { - SpaceFile *sfile= CTX_wm_space_file(C); + SpaceFile *sfile = CTX_wm_space_file(C); 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); file_change_dir(C, 0); - WM_event_add_notifier(C, NC_SPACE|ND_SPACE_FILE_LIST, NULL); + WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_LIST, NULL); } } @@ -834,15 +834,15 @@ void FILE_OT_parent(struct wmOperatorType *ot) static int file_refresh_exec(bContext *C, wmOperator *UNUSED(unused)) { - SpaceFile *sfile= CTX_wm_space_file(C); - struct FSMenu* fsmenu = fsmenu_get(); + SpaceFile *sfile = CTX_wm_space_file(C); + struct FSMenu *fsmenu = fsmenu_get(); ED_fileselect_clear(C, sfile); /* refresh system directory menu */ fsmenu_refresh_system_category(fsmenu); - WM_event_add_notifier(C, NC_SPACE|ND_SPACE_FILE_LIST, NULL); + WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_LIST, NULL); return OPERATOR_FINISHED; @@ -862,7 +862,7 @@ void FILE_OT_previous(struct wmOperatorType *ot) int file_previous_exec(bContext *C, wmOperator *UNUSED(unused)) { - SpaceFile *sfile= CTX_wm_space_file(C); + SpaceFile *sfile = CTX_wm_space_file(C); if (sfile->params) { if (!sfile->folders_next) @@ -874,7 +874,7 @@ int file_previous_exec(bContext *C, wmOperator *UNUSED(unused)) file_change_dir(C, 1); } - WM_event_add_notifier(C, NC_SPACE|ND_SPACE_FILE_LIST, NULL); + WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_LIST, NULL); return OPERATOR_FINISHED; } @@ -893,7 +893,7 @@ void FILE_OT_next(struct wmOperatorType *ot) int file_next_exec(bContext *C, wmOperator *UNUSED(unused)) { - SpaceFile *sfile= CTX_wm_space_file(C); + SpaceFile *sfile = CTX_wm_space_file(C); if (sfile->params) { if (!sfile->folders_next) sfile->folders_next = folderlist_new(); @@ -906,7 +906,7 @@ int file_next_exec(bContext *C, wmOperator *UNUSED(unused)) file_change_dir(C, 1); } - WM_event_add_notifier(C, NC_SPACE|ND_SPACE_FILE_LIST, NULL); + WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_LIST, NULL); return OPERATOR_FINISHED; } @@ -916,31 +916,31 @@ int file_next_exec(bContext *C, wmOperator *UNUSED(unused)) static int file_smoothscroll_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *event) { ScrArea *sa = CTX_wm_area(C); - SpaceFile *sfile= CTX_wm_space_file(C); - ARegion *ar, *oldar= CTX_wm_region(C); + SpaceFile *sfile = CTX_wm_space_file(C); + ARegion *ar, *oldar = CTX_wm_region(C); int offset; int numfiles, numfiles_layout; int edit_idx = 0; 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); /* check if we are editing a name */ - for (i=0; i < numfiles; ++i) { + for (i = 0; i < numfiles; ++i) { if (filelist_is_selected(sfile->files, i, CHECK_ALL) ) { - edit_idx=i; + edit_idx = i; break; } } /* if we are not editing, we are done */ - if (0==edit_idx) { + if (0 == edit_idx) { WM_event_remove_timer(CTX_wm_manager(C), CTX_wm_window(C), sfile->smoothscroll_timer); - sfile->smoothscroll_timer=NULL; + sfile->smoothscroll_timer = NULL; return OPERATOR_PASS_THROUGH; } @@ -948,21 +948,21 @@ static int file_smoothscroll_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent ar = BKE_area_find_region_type(sa, RGN_TYPE_WINDOW); if (!ar || ar->regiontype != RGN_TYPE_WINDOW) { WM_event_remove_timer(CTX_wm_manager(C), CTX_wm_window(C), sfile->smoothscroll_timer); - sfile->smoothscroll_timer=NULL; + sfile->smoothscroll_timer = NULL; return OPERATOR_PASS_THROUGH; } offset = ED_fileselect_layout_offset(sfile->layout, (int)ar->v2d.cur.xmin, (int)-ar->v2d.cur.ymax); - if (offset<0) offset=0; + if (offset < 0) offset = 0; /* scroll offset is the first file in the row/column we are editing in */ if (sfile->scroll_offset == 0) { if (sfile->layout->flag & FILE_LAYOUT_HOR) { - sfile->scroll_offset = (edit_idx/sfile->layout->rows)*sfile->layout->rows; + sfile->scroll_offset = (edit_idx / sfile->layout->rows) * sfile->layout->rows; if (sfile->scroll_offset <= offset) sfile->scroll_offset -= sfile->layout->rows; } else { - sfile->scroll_offset = (edit_idx/sfile->layout->columns)*sfile->layout->columns; + sfile->scroll_offset = (edit_idx / sfile->layout->columns) * sfile->layout->columns; if (sfile->scroll_offset <= offset) sfile->scroll_offset -= sfile->layout->columns; } } @@ -972,7 +972,7 @@ static int file_smoothscroll_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent /* 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); - sfile->smoothscroll_timer=NULL; + sfile->smoothscroll_timer = NULL; return OPERATOR_FINISHED; } @@ -1026,7 +1026,7 @@ void FILE_OT_smoothscroll(wmOperatorType *ot) /* create a new, non-existing folder name, returns 1 if successful, 0 if name couldn't be created. * The actual name is returned in 'name', 'folder' contains the complete path, including the new folder name. */ -static int new_folder_path(const char* parent, char *folder, char *name) +static int new_folder_path(const char *parent, char *folder, char *name) { int i = 1; int len = 0; @@ -1036,22 +1036,22 @@ static int new_folder_path(const char* parent, char *folder, char *name) /* check whether folder with the name already exists, in this case * add number to the name. Check length of generated name to avoid * crazy case of huge number of folders each named 'New Folder (x)' */ - while (BLI_exists(folder) && (lenparams) { BKE_report(op->reports, RPT_WARNING, "No parent directory given"); @@ -1062,7 +1062,7 @@ int file_directory_new_exec(bContext *C, wmOperator *op) if (RNA_struct_find_property(op->ptr, "directory")) { RNA_string_get(op->ptr, "directory", path); - if (path[0] != '\0') generate_name= 0; + if (path[0] != '\0') generate_name = 0; } if (generate_name) { @@ -1085,12 +1085,12 @@ int file_directory_new_exec(bContext *C, wmOperator *op) BLI_strncpy(sfile->params->renamefile, name, FILE_MAXFILE); /* set timer to smoothly view newly generated file */ - sfile->smoothscroll_timer = WM_event_add_timer(CTX_wm_manager(C), CTX_wm_window(C), TIMER1, 1.0/1000.0); /* max 30 frs/sec */ - sfile->scroll_offset=0; + sfile->smoothscroll_timer = WM_event_add_timer(CTX_wm_manager(C), CTX_wm_window(C), TIMER1, 1.0 / 1000.0); /* max 30 frs/sec */ + sfile->scroll_offset = 0; /* reload dir to make sure we're seeing what's in the directory */ ED_fileselect_clear(C, sfile); - WM_event_add_notifier(C, NC_SPACE|ND_SPACE_FILE_LIST, NULL); + WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_LIST, NULL); return OPERATOR_FINISHED; } @@ -1115,7 +1115,7 @@ void FILE_OT_directory_new(struct wmOperatorType *ot) static void file_expand_directory(bContext *C) { - SpaceFile *sfile= CTX_wm_space_file(C); + SpaceFile *sfile = CTX_wm_space_file(C); if (sfile->params) { /* TODO, what about // when relbase isn't valid? */ @@ -1123,8 +1123,8 @@ static void file_expand_directory(bContext *C) BLI_path_abs(sfile->params->dir, G.main->name); } else if (sfile->params->dir[0] == '~') { - char tmpstr[sizeof(sfile->params->dir)-1]; - BLI_strncpy(tmpstr, sfile->params->dir+1, sizeof(tmpstr)); + char tmpstr[sizeof(sfile->params->dir) - 1]; + BLI_strncpy(tmpstr, sfile->params->dir + 1, sizeof(tmpstr)); BLI_join_dirfile(sfile->params->dir, sizeof(sfile->params->dir), BLI_getDefaultDocumentFolder(), tmpstr); } @@ -1140,12 +1140,12 @@ static void file_expand_directory(bContext *C) } /* change "C:" --> "C:\", [#28102] */ else if ( (isalpha(sfile->params->dir[0]) && - (sfile->params->dir[1] == ':')) && + (sfile->params->dir[1] == ':')) && (sfile->params->dir[2] == '\0') - ) { - sfile->params->dir[2]= '\\'; - sfile->params->dir[3]= '\0'; + ) { + sfile->params->dir[2] = '\\'; + sfile->params->dir[3] = '\0'; } #endif } @@ -1153,7 +1153,7 @@ static void file_expand_directory(bContext *C) static int file_directory_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) { - SpaceFile *sfile= CTX_wm_space_file(C); + SpaceFile *sfile = CTX_wm_space_file(C); if (sfile->params) { file_expand_directory(C); @@ -1172,7 +1172,7 @@ static int file_directory_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(ev int file_directory_exec(bContext *C, wmOperator *UNUSED(unused)) { - SpaceFile *sfile= CTX_wm_space_file(C); + SpaceFile *sfile = CTX_wm_space_file(C); if (sfile->params) { file_expand_directory(C); @@ -1192,7 +1192,7 @@ int file_directory_exec(bContext *C, wmOperator *UNUSED(unused)) BLI_add_slash(sfile->params->dir); file_change_dir(C, 1); - WM_event_add_notifier(C, NC_SPACE|ND_SPACE_FILE_LIST, NULL); + WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_LIST, NULL); } return OPERATOR_FINISHED; @@ -1200,7 +1200,7 @@ int file_directory_exec(bContext *C, wmOperator *UNUSED(unused)) int file_filename_exec(bContext *C, wmOperator *UNUSED(unused)) { - SpaceFile *sfile= CTX_wm_space_file(C); + SpaceFile *sfile = CTX_wm_space_file(C); char matched_file[FILE_MAX]; if (sfile->params) { matched_file[0] = '\0'; @@ -1210,7 +1210,7 @@ int file_filename_exec(bContext *C, wmOperator *UNUSED(unused)) /* 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); + WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_PARAMS, NULL); } } @@ -1222,8 +1222,8 @@ int file_filename_exec(bContext *C, wmOperator *UNUSED(unused)) static int file_directory_poll(bContext *C) { /* sfile->files can be NULL on file load */ - SpaceFile *sfile= CTX_wm_space_file(C); - return ED_operator_file_active(C) && (sfile->files==NULL || filelist_lib(sfile->files)==NULL); + SpaceFile *sfile = CTX_wm_space_file(C); + return ED_operator_file_active(C) && (sfile->files == NULL || filelist_lib(sfile->files) == NULL); } void FILE_OT_directory(struct wmOperatorType *ot) @@ -1253,12 +1253,12 @@ void FILE_OT_refresh(struct wmOperatorType *ot) static int file_hidedot_exec(bContext *C, wmOperator *UNUSED(unused)) { - SpaceFile *sfile= CTX_wm_space_file(C); + SpaceFile *sfile = CTX_wm_space_file(C); 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); + WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_LIST, NULL); } return OPERATOR_FINISHED; @@ -1277,27 +1277,26 @@ void FILE_OT_hidedot(struct wmOperatorType *ot) ot->poll = ED_operator_file_active; /* <- important, handler is on window level */ } -struct ARegion *file_buttons_region(struct ScrArea *sa) -{ +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"); + arnew = MEM_callocN(sizeof(ARegion), "buttons for file panels"); BLI_insertlinkafter(&sa->regionbase, ar, arnew); - arnew->regiontype= RGN_TYPE_CHANNELS; - arnew->alignment= RGN_ALIGN_LEFT; + arnew->regiontype = RGN_TYPE_CHANNELS; + arnew->alignment = RGN_ALIGN_LEFT; arnew->flag = RGN_FLAG_HIDDEN; @@ -1306,8 +1305,8 @@ struct ARegion *file_buttons_region(struct ScrArea *sa) static int file_bookmark_toggle_exec(bContext *C, wmOperator *UNUSED(unused)) { - ScrArea *sa= CTX_wm_area(C); - ARegion *ar= file_buttons_region(sa); + ScrArea *sa = CTX_wm_area(C); + ARegion *ar = file_buttons_region(sa); if (ar) ED_region_toggle_hidden(C, ar); @@ -1330,8 +1329,8 @@ void FILE_OT_bookmark_toggle(struct wmOperatorType *ot) static int file_filenum_exec(bContext *C, wmOperator *op) { - SpaceFile *sfile= CTX_wm_space_file(C); - ScrArea *sa= CTX_wm_area(C); + 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)) { @@ -1362,17 +1361,17 @@ void FILE_OT_filenum(struct wmOperatorType *ot) static int file_rename_exec(bContext *C, wmOperator *UNUSED(op)) { - ScrArea *sa= CTX_wm_area(C); - SpaceFile *sfile= (SpaceFile*)CTX_wm_space_data(C); + ScrArea *sa = CTX_wm_area(C); + SpaceFile *sfile = (SpaceFile *)CTX_wm_space_data(C); if (sfile->params) { int idx = sfile->params->active_file; int numfiles = filelist_numfiles(sfile->files); - if ( (0<=idx) && (idxfiles, idx); + if ( (0 <= idx) && (idx < numfiles) ) { + struct direntry *file = filelist_file(sfile->files, idx); filelist_select_file(sfile->files, idx, FILE_SEL_ADD, EDITING_FILE, CHECK_ALL); BLI_strncpy(sfile->params->renameedit, file->relname, FILE_MAXFILE); - sfile->params->renamefile[0]= '\0'; + sfile->params->renamefile[0] = '\0'; } ED_area_tag_redraw(sa); } @@ -1384,19 +1383,19 @@ static int file_rename_exec(bContext *C, wmOperator *UNUSED(op)) static int file_rename_poll(bContext *C) { int poll = ED_operator_file_active(C); - SpaceFile *sfile= CTX_wm_space_file(C); + SpaceFile *sfile = CTX_wm_space_file(C); if (sfile && sfile->params) { if (sfile->params->active_file < 0) { - poll= 0; + poll = 0; } else { char dir[FILE_MAX], group[FILE_MAX]; - if (filelist_islibrary(sfile->files, dir, group)) poll= 0; + if (filelist_islibrary(sfile->files, dir, group)) poll = 0; } } else - poll= 0; + poll = 0; return poll; } @@ -1416,22 +1415,22 @@ void FILE_OT_rename(struct wmOperatorType *ot) static int file_delete_poll(bContext *C) { int poll = ED_operator_file_active(C); - SpaceFile *sfile= CTX_wm_space_file(C); - struct direntry* file; + SpaceFile *sfile = CTX_wm_space_file(C); + struct direntry *file; if (sfile && sfile->params) { if (sfile->params->active_file < 0) { - poll= 0; + poll = 0; } else { char dir[FILE_MAX], group[FILE_MAX]; - if (filelist_islibrary(sfile->files, dir, group)) poll= 0; + if (filelist_islibrary(sfile->files, dir, group)) poll = 0; file = filelist_file(sfile->files, sfile->params->active_file); - if (file && S_ISDIR(file->type)) poll= 0; + if (file && S_ISDIR(file->type)) poll = 0; } } else - poll= 0; + poll = 0; return poll; } @@ -1439,15 +1438,15 @@ static int file_delete_poll(bContext *C) int file_delete_exec(bContext *C, wmOperator *UNUSED(op)) { char str[FILE_MAX]; - SpaceFile *sfile= CTX_wm_space_file(C); - struct direntry* file; + SpaceFile *sfile = CTX_wm_space_file(C); + struct direntry *file; file = filelist_file(sfile->files, sfile->params->active_file); BLI_make_file_string(G.main->name, str, sfile->params->dir, file->relname); BLI_delete(str, 0, 0); ED_fileselect_clear(C, sfile); - WM_event_add_notifier(C, NC_SPACE|ND_SPACE_FILE_LIST, NULL); + WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_LIST, NULL); return OPERATOR_FINISHED; diff --git a/source/blender/editors/space_file/file_panels.c b/source/blender/editors/space_file/file_panels.c index a17a7edbd80..77e99a61b10 100644 --- a/source/blender/editors/space_file/file_panels.c +++ b/source/blender/editors/space_file/file_panels.c @@ -59,7 +59,7 @@ static void file_panel_cb(bContext *C, void *arg_entry, void *UNUSED(arg_v)) { PointerRNA ptr; - char *entry= (char*)arg_entry; + char *entry = (char *)arg_entry; WM_operator_properties_create(&ptr, "FILE_OT_select_bookmark"); RNA_string_set(&ptr, "dir", entry); @@ -69,15 +69,15 @@ static void file_panel_cb(bContext *C, void *arg_entry, void *UNUSED(arg_v)) static void file_panel_category(const bContext *C, Panel *pa, FSMenuCategory category, short *nr, int icon, int allow_delete, int reverse) { - SpaceFile *sfile= CTX_wm_space_file(C); + SpaceFile *sfile = CTX_wm_space_file(C); uiBlock *block; uiBut *but; uiLayout *box, *col; - struct FSMenu* fsmenu = fsmenu_get(); + struct FSMenu *fsmenu = fsmenu_get(); int i, i_iter, nentries = fsmenu_get_nentries(fsmenu, category); /* reset each time */ - *nr= -1; + *nr = -1; /* hide if no entries */ if (nentries == 0) @@ -85,24 +85,24 @@ static void file_panel_category(const bContext *C, Panel *pa, FSMenuCategory cat /* layout */ uiLayoutSetAlignment(pa->layout, UI_LAYOUT_ALIGN_LEFT); - block= uiLayoutGetBlock(pa->layout); - box= uiLayoutBox(pa->layout); - col= uiLayoutColumn(box, 1); + block = uiLayoutGetBlock(pa->layout); + box = uiLayoutBox(pa->layout); + col = uiLayoutColumn(box, 1); - for (i_iter=0; i_iter< nentries;++i_iter) { + for (i_iter = 0; i_iter < nentries; ++i_iter) { char dir[FILE_MAX]; char temp[FILE_MAX]; - uiLayout* layout = uiLayoutRow(col, 0); + uiLayout *layout = uiLayoutRow(col, 0); char *entry; - i= reverse ? nentries-(i_iter+1) : i_iter; + i = reverse ? nentries - (i_iter + 1) : i_iter; 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) { - *nr= i; + *nr = i; } } @@ -118,7 +118,7 @@ static void file_panel_category(const bContext *C, Panel *pa, FSMenuCategory cat /* create list item */ but = uiDefIconTextButS(block, LISTROW, 0, icon, dir, 0, 0, UI_UNIT_X * 10, UI_UNIT_Y, nr, 0, i, 0, 0, entry); uiButSetFunc(but, file_panel_cb, entry, NULL); - uiButSetFlag(but, UI_ICON_LEFT|UI_TEXT_LEFT); + uiButSetFlag(but, UI_ICON_LEFT | UI_TEXT_LEFT); /* create delete button */ if (allow_delete && fsmenu_can_save(fsmenu, category, i)) { @@ -131,7 +131,7 @@ static void file_panel_category(const bContext *C, Panel *pa, FSMenuCategory cat static void file_panel_system(const bContext *C, Panel *pa) { - SpaceFile *sfile= CTX_wm_space_file(C); + SpaceFile *sfile = CTX_wm_space_file(C); if (sfile) file_panel_category(C, pa, FS_CATEGORY_SYSTEM, &sfile->systemnr, ICON_DISK_DRIVE, 0, 0); @@ -139,11 +139,11 @@ static void file_panel_system(const bContext *C, Panel *pa) static void file_panel_bookmarks(const bContext *C, Panel *pa) { - SpaceFile *sfile= CTX_wm_space_file(C); + SpaceFile *sfile = CTX_wm_space_file(C); uiLayout *row; if (sfile) { - row= uiLayoutRow(pa->layout, 0); + row = uiLayoutRow(pa->layout, 0); uiItemO(row, IFACE_("Add"), ICON_ZOOMIN, "file.bookmark_add"); uiItemL(row, NULL, ICON_NONE); @@ -153,10 +153,10 @@ static void file_panel_bookmarks(const bContext *C, Panel *pa) static void file_panel_recent(const bContext *C, Panel *pa) { - SpaceFile *sfile= CTX_wm_space_file(C); + SpaceFile *sfile = CTX_wm_space_file(C); if (sfile) { - if ( !(U.uiflag & USER_HIDE_RECENT) ) { + if (!(U.uiflag & USER_HIDE_RECENT) ) { file_panel_category(C, pa, FS_CATEGORY_RECENT, &sfile->recentnr, ICON_FILE_FOLDER, 0, 1); } } @@ -165,31 +165,31 @@ static void file_panel_recent(const bContext *C, Panel *pa) static int file_panel_operator_poll(const bContext *C, PanelType *UNUSED(pt)) { - SpaceFile *sfile= CTX_wm_space_file(C); + SpaceFile *sfile = CTX_wm_space_file(C); return (sfile && sfile->op); } static void file_panel_operator_header(const bContext *C, Panel *pa) { - SpaceFile *sfile= CTX_wm_space_file(C); - wmOperator *op= sfile->op; + SpaceFile *sfile = CTX_wm_space_file(C); + wmOperator *op = sfile->op; BLI_strncpy(pa->drawname, RNA_struct_ui_name(op->type->srna), sizeof(pa->drawname)); } static int file_panel_check_prop(PointerRNA *UNUSED(ptr), PropertyRNA *prop) { - const char *prop_id= RNA_property_identifier(prop); - return !( strcmp(prop_id, "filepath") == 0 || - strcmp(prop_id, "directory") == 0 || - strcmp(prop_id, "filename") == 0 - ); + const char *prop_id = RNA_property_identifier(prop); + return !(strcmp(prop_id, "filepath") == 0 || + strcmp(prop_id, "directory") == 0 || + strcmp(prop_id, "filename") == 0 + ); } static void file_panel_operator(const bContext *C, Panel *pa) { - SpaceFile *sfile= CTX_wm_space_file(C); - wmOperator *op= sfile->op; + SpaceFile *sfile = CTX_wm_space_file(C); + wmOperator *op = sfile->op; // int empty= 1, flag; uiBlockSetFunc(uiLayoutGetBlock(pa->layout), file_draw_check_cb, NULL, NULL); @@ -203,30 +203,30 @@ void file_panels_register(ARegionType *art) { PanelType *pt; - pt= MEM_callocN(sizeof(PanelType), "spacetype file system directories"); + pt = MEM_callocN(sizeof(PanelType), "spacetype file system directories"); strcpy(pt->idname, "FILE_PT_system"); strcpy(pt->label, N_("System")); - pt->draw= file_panel_system; + pt->draw = file_panel_system; BLI_addtail(&art->paneltypes, pt); - pt= MEM_callocN(sizeof(PanelType), "spacetype file bookmarks"); + pt = MEM_callocN(sizeof(PanelType), "spacetype file bookmarks"); strcpy(pt->idname, "FILE_PT_bookmarks"); strcpy(pt->label, N_("Bookmarks")); - pt->draw= file_panel_bookmarks; + pt->draw = file_panel_bookmarks; BLI_addtail(&art->paneltypes, pt); - pt= MEM_callocN(sizeof(PanelType), "spacetype file recent directories"); + pt = MEM_callocN(sizeof(PanelType), "spacetype file recent directories"); strcpy(pt->idname, "FILE_PT_recent"); strcpy(pt->label, N_("Recent")); - pt->draw= file_panel_recent; + pt->draw = file_panel_recent; BLI_addtail(&art->paneltypes, pt); - pt= MEM_callocN(sizeof(PanelType), "spacetype file operator properties"); + pt = MEM_callocN(sizeof(PanelType), "spacetype file operator properties"); strcpy(pt->idname, "FILE_PT_operator"); strcpy(pt->label, N_("Operator")); - pt->poll= file_panel_operator_poll; - pt->draw_header= file_panel_operator_header; - pt->draw= file_panel_operator; + pt->poll = file_panel_operator_poll; + pt->draw_header = file_panel_operator_header; + pt->draw = file_panel_operator; BLI_addtail(&art->paneltypes, pt); } diff --git a/source/blender/editors/space_file/filelist.c b/source/blender/editors/space_file/filelist.c index a535e888156..a4cf447686c 100644 --- a/source/blender/editors/space_file/filelist.c +++ b/source/blender/editors/space_file/filelist.c @@ -98,7 +98,7 @@ typedef struct ThumbnailJob { ListBase loadimages; short *stop; short *do_update; - struct FileList* filelist; + struct FileList *filelist; ReportList reports; } ThumbnailJob; @@ -119,7 +119,7 @@ typedef struct FileList { short hide_parent; void (*readf)(struct FileList *); - int (*filterf)(struct direntry* file, const char* dir, unsigned int filter, short hide_dot); + int (*filterf)(struct direntry *file, const char *dir, unsigned int filter, short hide_dot); } FileList; @@ -145,25 +145,25 @@ typedef struct FolderList { #define SPECIAL_IMG_LOADING 10 #define SPECIAL_IMG_MAX SPECIAL_IMG_LOADING + 1 -static ImBuf* gSpecialFileImages[SPECIAL_IMG_MAX]; +static ImBuf *gSpecialFileImages[SPECIAL_IMG_MAX]; /* ******************* SORT ******************* */ static int compare_name(const void *a1, const void *a2) { - const struct direntry *entry1=a1, *entry2=a2; + const struct direntry *entry1 = a1, *entry2 = a2; /* type is equal to stat.st_mode */ if (S_ISDIR(entry1->type)) { - if (S_ISDIR(entry2->type)==0) return (-1); + if (S_ISDIR(entry2->type) == 0) return (-1); } else { if (S_ISDIR(entry2->type)) return (1); } if (S_ISREG(entry1->type)) { - if (S_ISREG(entry2->type)==0) return (-1); + if (S_ISREG(entry2->type) == 0) return (-1); } else { if (S_ISREG(entry2->type)) return (1); @@ -172,28 +172,28 @@ static int compare_name(const void *a1, const void *a2) 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)); } static int compare_date(const void *a1, const void *a2) { - const struct direntry *entry1=a1, *entry2=a2; + const struct direntry *entry1 = a1, *entry2 = a2; /* type is equal to stat.st_mode */ if (S_ISDIR(entry1->type)) { - if (S_ISDIR(entry2->type)==0) return (-1); + if (S_ISDIR(entry2->type) == 0) return (-1); } else { if (S_ISDIR(entry2->type)) return (1); } if (S_ISREG(entry1->type)) { - if (S_ISREG(entry2->type)==0) return (-1); + if (S_ISREG(entry2->type) == 0) return (-1); } else { if (S_ISREG(entry2->type)) return (1); @@ -202,31 +202,31 @@ static int compare_date(const void *a1, const void *a2) 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; + if (entry1->s.st_mtime < entry2->s.st_mtime) return 1; + if (entry1->s.st_mtime > entry2->s.st_mtime) return -1; else return BLI_natstrcmp(entry1->relname, entry2->relname); } static int compare_size(const void *a1, const void *a2) { - const struct direntry *entry1=a1, *entry2=a2; + const struct direntry *entry1 = a1, *entry2 = a2; /* type is equal to stat.st_mode */ if (S_ISDIR(entry1->type)) { - if (S_ISDIR(entry2->type)==0) return (-1); + if (S_ISDIR(entry2->type) == 0) return (-1); } else { if (S_ISDIR(entry2->type)) return (1); } if (S_ISREG(entry1->type)) { - if (S_ISREG(entry2->type)==0) return (-1); + if (S_ISREG(entry2->type) == 0) return (-1); } else { if (S_ISREG(entry2->type)) return (1); @@ -235,39 +235,39 @@ static int compare_size(const void *a1, const void *a2) 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; + if (entry1->s.st_size < entry2->s.st_size) return 1; + if (entry1->s.st_size > entry2->s.st_size) return -1; else return BLI_natstrcmp(entry1->relname, entry2->relname); } static int compare_extension(const void *a1, const void *a2) { - const struct direntry *entry1=a1, *entry2=a2; + const struct direntry *entry1 = a1, *entry2 = a2; const char *sufix1, *sufix2; - const char *nil=""; + const char *nil = ""; - if (!(sufix1= strstr (entry1->relname, ".blend.gz"))) - sufix1= strrchr (entry1->relname, '.'); - if (!(sufix2= strstr (entry2->relname, ".blend.gz"))) - sufix2= strrchr (entry2->relname, '.'); - if (!sufix1) sufix1= nil; - if (!sufix2) sufix2= nil; + if (!(sufix1 = strstr(entry1->relname, ".blend.gz"))) + sufix1 = strrchr(entry1->relname, '.'); + if (!(sufix2 = strstr(entry2->relname, ".blend.gz"))) + sufix2 = strrchr(entry2->relname, '.'); + if (!sufix1) sufix1 = nil; + if (!sufix2) sufix2 = nil; /* type is equal to stat.st_mode */ if (S_ISDIR(entry1->type)) { - if (S_ISDIR(entry2->type)==0) return (-1); + if (S_ISDIR(entry2->type) == 0) return (-1); } else { if (S_ISDIR(entry2->type)) return (1); } if (S_ISREG(entry1->type)) { - if (S_ISREG(entry2->type)==0) return (-1); + if (S_ISREG(entry2->type) == 0) return (-1); } else { if (S_ISREG(entry2->type)) return (1); @@ -276,46 +276,46 @@ static int compare_extension(const void *a1, const void *a2) 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)); } -static int is_hidden_file(const char* filename, short hide_dot) +static int is_hidden_file(const char *filename, short hide_dot) { - int is_hidden=0; + int is_hidden = 0; if (hide_dot) { - if (filename[0]=='.' && filename[1]!='.' && filename[1]!=0) { - is_hidden=1; /* ignore .file */ + if (filename[0] == '.' && filename[1] != '.' && filename[1] != 0) { + is_hidden = 1; /* ignore .file */ } else if (((filename[0] == '.') && (filename[1] == 0) )) { - is_hidden=1; /* ignore . */ + is_hidden = 1; /* ignore . */ } else { - int len=strlen(filename); - if ( (len>0) && (filename[len-1]=='~') ) { - is_hidden=1; /* ignore file~ */ + int len = strlen(filename); + if ( (len > 0) && (filename[len - 1] == '~') ) { + is_hidden = 1; /* ignore file~ */ } } } else { if (((filename[0] == '.') && (filename[1] == 0) )) { - is_hidden=1; /* ignore . */ + is_hidden = 1; /* ignore . */ } } return is_hidden; } -static int is_filtered_file(struct direntry* file, const char* UNUSED(dir), unsigned int filter, short hide_dot) +static int is_filtered_file(struct direntry *file, const char *UNUSED(dir), unsigned int filter, short hide_dot) { - int is_filtered=0; + int is_filtered = 0; if (filter) { if (file->flags & filter) { - is_filtered=1; + is_filtered = 1; } else if (file->type & S_IFDIR) { if (filter & FOLDERFILE) { @@ -329,9 +329,9 @@ static int is_filtered_file(struct direntry* file, const char* UNUSED(dir), unsi return is_filtered && !is_hidden_file(file->relname, hide_dot); } -static int is_filtered_lib(struct direntry* file, const char* dir, unsigned int filter, short hide_dot) +static int is_filtered_lib(struct direntry *file, const char *dir, unsigned int filter, short hide_dot) { - int is_filtered=0; + int is_filtered = 0; char tdir[FILE_MAX], tgroup[GROUP_MAX]; if (BLO_is_a_library(dir, tdir, tgroup)) { is_filtered = !is_hidden_file(file->relname, hide_dot); @@ -342,12 +342,12 @@ static int is_filtered_lib(struct direntry* file, const char* dir, unsigned int return is_filtered; } -static int is_filtered_main(struct direntry* file, const char* UNUSED(dir), unsigned int UNUSED(filter), short hide_dot) +static int is_filtered_main(struct direntry *file, const char *UNUSED(dir), unsigned int UNUSED(filter), short hide_dot) { return !is_hidden_file(file->relname, hide_dot); } -void filelist_filter(FileList* filelist) +void filelist_filter(FileList *filelist) { int num_filtered = 0; int i, j; @@ -358,7 +358,7 @@ void filelist_filter(FileList* filelist) // How many files are left after filter ? for (i = 0; i < filelist->numfiles; ++i) { struct direntry *file = &filelist->filelist[i]; - if ( filelist->filterf(file, filelist->dir, filelist->filter, filelist->hide_dot) ) { + if (filelist->filterf(file, filelist->dir, filelist->filter, filelist->hide_dot) ) { num_filtered++; } } @@ -367,12 +367,12 @@ void filelist_filter(FileList* filelist) MEM_freeN(filelist->fidx); filelist->fidx = NULL; } - filelist->fidx = (int *)MEM_callocN(num_filtered*sizeof(int), "filteridx"); + filelist->fidx = (int *)MEM_callocN(num_filtered * sizeof(int), "filteridx"); filelist->numfiltered = num_filtered; - for (i = 0, j=0; i < filelist->numfiles; ++i) { + for (i = 0, j = 0; i < filelist->numfiles; ++i) { struct direntry *file = &filelist->filelist[i]; - if ( filelist->filterf(file, filelist->dir, filelist->filter, filelist->hide_dot) ) { + if (filelist->filterf(file, filelist->dir, filelist->filter, filelist->hide_dot) ) { filelist->fidx[j++] = i; } } @@ -386,16 +386,16 @@ void filelist_init_icons(void) #ifdef WITH_HEADLESS bbuf = NULL; #else - bbuf = IMB_ibImageFromMemory((unsigned char*)datatoc_prvicons, datatoc_prvicons_size, IB_rect, ""); + bbuf = IMB_ibImageFromMemory((unsigned char *)datatoc_prvicons, datatoc_prvicons_size, IB_rect, ""); #endif if (bbuf) { - for (y=0; yrect[k*SPECIAL_IMG_SIZE], &bbuf->rect[(k+y*SPECIAL_IMG_SIZE)*SPECIAL_IMG_SIZE*SPECIAL_IMG_COLS+x*SPECIAL_IMG_SIZE], SPECIAL_IMG_SIZE*sizeof(int)); + for (k = 0; k < SPECIAL_IMG_SIZE; k++) { + memcpy(&ibuf->rect[k * SPECIAL_IMG_SIZE], &bbuf->rect[(k + y * SPECIAL_IMG_SIZE) * SPECIAL_IMG_SIZE * SPECIAL_IMG_COLS + x * SPECIAL_IMG_SIZE], SPECIAL_IMG_SIZE * sizeof(int)); } gSpecialFileImages[tile] = ibuf; } @@ -408,20 +408,20 @@ void filelist_init_icons(void) void filelist_free_icons(void) { int i; - for (i=0; i < SPECIAL_IMG_MAX; ++i) { + for (i = 0; i < SPECIAL_IMG_MAX; ++i) { IMB_freeImBuf(gSpecialFileImages[i]); gSpecialFileImages[i] = NULL; } } //-----------------FOLDERLIST (previous/next) --------------// -struct ListBase* folderlist_new(void) +ListBase *folderlist_new(void) { - ListBase* p = MEM_callocN(sizeof(ListBase), "folderlist" ); + ListBase *p = MEM_callocN(sizeof(ListBase), "folderlist"); return p; } -void folderlist_popdir(struct ListBase* folderlist, char *dir) +void folderlist_popdir(struct ListBase *folderlist, char *dir) { const char *prev_dir; struct FolderList *folder; @@ -441,21 +441,21 @@ void folderlist_popdir(struct ListBase* folderlist, char *dir) // delete the folder next or use setdir directly before PREVIOUS OP } -void folderlist_pushdir(ListBase* folderlist, const char *dir) +void folderlist_pushdir(ListBase *folderlist, const char *dir) { struct FolderList *folder, *previous_folder; previous_folder = folderlist->last; // check if already exists if (previous_folder && previous_folder->foldername) { - if (BLI_path_cmp(previous_folder->foldername, dir)==0) { + if (BLI_path_cmp(previous_folder->foldername, dir) == 0) { return; } } // create next folder element - folder = (FolderList*)MEM_mallocN(sizeof(FolderList), "FolderList"); - folder->foldername = (char*)MEM_mallocN(sizeof(char)*(strlen(dir)+1), "foldername"); + folder = (FolderList *)MEM_mallocN(sizeof(FolderList), "FolderList"); + folder->foldername = (char *)MEM_mallocN(sizeof(char) * (strlen(dir) + 1), "foldername"); folder->foldername[0] = '\0'; BLI_strncpy(folder->foldername, dir, FILE_MAXDIR); @@ -474,7 +474,7 @@ int folderlist_clear_next(struct SpaceFile *sfile) // if previous_folder, next_folder or refresh_folder operators are executed it doesn't clear folder_next folder = sfile->folders_prev->last; - if ((!folder) ||(BLI_path_cmp(folder->foldername, sfile->params->dir) == 0)) + if ((!folder) || (BLI_path_cmp(folder->foldername, sfile->params->dir) == 0)) return 0; // eventually clear flist->folders_next @@ -482,27 +482,27 @@ int folderlist_clear_next(struct SpaceFile *sfile) } /* not listbase itself */ -void folderlist_free(ListBase* folderlist) +void folderlist_free(ListBase *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); } } -ListBase *folderlist_duplicate(ListBase* folderlist) +ListBase *folderlist_duplicate(ListBase *folderlist) { if (folderlist) { - ListBase *folderlistn= MEM_callocN(sizeof(ListBase), "copy folderlist"); + ListBase *folderlistn = MEM_callocN(sizeof(ListBase), "copy folderlist"); FolderList *folder; BLI_duplicatelist(folderlistn, folderlist); - for (folder= folderlistn->first; folder; folder= folder->next) { - folder->foldername= MEM_dupallocN(folder->foldername); + for (folder = folderlistn->first; folder; folder = folder->next) { + folder->foldername = MEM_dupallocN(folder->foldername); } return folderlistn; } @@ -510,14 +510,14 @@ ListBase *folderlist_duplicate(ListBase* folderlist) } -static void filelist_read_main(struct FileList* filelist); -static void filelist_read_library(struct FileList* filelist); -static void filelist_read_dir(struct FileList* filelist); +static void filelist_read_main(struct FileList *filelist); +static void filelist_read_library(struct FileList *filelist); +static void filelist_read_dir(struct FileList *filelist); //------------------FILELIST------------------------// -struct FileList* filelist_new(short type) +FileList *filelist_new(short type) { - FileList* p = MEM_callocN(sizeof(FileList), "filelist" ); + FileList *p = MEM_callocN(sizeof(FileList), "filelist"); switch (type) { case FILE_MAIN: p->readf = filelist_read_main; @@ -536,7 +536,7 @@ struct FileList* filelist_new(short type) } -void filelist_free(struct FileList* filelist) +void filelist_free(struct FileList *filelist) { int i; @@ -570,51 +570,51 @@ void filelist_free(struct FileList* filelist) filelist->filelist = NULL; filelist->filter = 0; filelist->filter_glob[0] = '\0'; - filelist->numfiltered =0; - filelist->hide_dot =0; + filelist->numfiltered = 0; + filelist->hide_dot = 0; } -void filelist_freelib(struct FileList* filelist) +void filelist_freelib(struct FileList *filelist) { if (filelist->libfiledata) BLO_blendhandle_close(filelist->libfiledata); - filelist->libfiledata= NULL; + filelist->libfiledata = NULL; } -struct BlendHandle *filelist_lib(struct FileList* filelist) +BlendHandle *filelist_lib(struct FileList *filelist) { return filelist->libfiledata; } -int filelist_numfiles(struct FileList* filelist) +int filelist_numfiles(struct FileList *filelist) { return filelist->numfiltered; } -const char * filelist_dir(struct FileList* filelist) +const char *filelist_dir(struct FileList *filelist) { return filelist->dir; } -void filelist_setdir(struct FileList* filelist, const char *dir) +void filelist_setdir(struct FileList *filelist, const char *dir) { BLI_strncpy(filelist->dir, dir, sizeof(filelist->dir)); } -void filelist_imgsize(struct FileList* filelist, short w, short h) +void filelist_imgsize(struct FileList *filelist, short w, short h) { filelist->prv_w = w; filelist->prv_h = h; } -short filelist_changed(struct FileList* filelist) +short filelist_changed(struct FileList *filelist) { return filelist->changed; } -struct ImBuf * filelist_getimage(struct FileList* filelist, int index) +ImBuf *filelist_getimage(struct FileList *filelist, int index) { - ImBuf* ibuf = NULL; + ImBuf *ibuf = NULL; int fidx = 0; if ( (index < 0) || (index >= filelist->numfiltered) ) { return NULL; @@ -625,10 +625,10 @@ struct ImBuf * filelist_getimage(struct FileList* filelist, int index) return ibuf; } -struct ImBuf * filelist_geticon(struct FileList* filelist, int index) +ImBuf *filelist_geticon(struct FileList *filelist, int index) { - ImBuf* ibuf= NULL; - struct direntry *file= NULL; + ImBuf *ibuf = NULL; + struct direntry *file = NULL; int fidx = 0; if ( (index < 0) || (index >= filelist->numfiltered) ) { return NULL; @@ -636,7 +636,7 @@ struct ImBuf * filelist_geticon(struct FileList* filelist, int index) fidx = filelist->fidx[index]; file = &filelist->filelist[fidx]; if (file->type & S_IFDIR) { - if ( strcmp(filelist->filelist[fidx].relname, "..") == 0) { + if (strcmp(filelist->filelist[fidx].relname, "..") == 0) { ibuf = gSpecialFileImages[SPECIAL_IMG_PARENT]; } else if (strcmp(filelist->filelist[fidx].relname, ".") == 0) { @@ -675,7 +675,7 @@ struct ImBuf * filelist_geticon(struct FileList* filelist, int index) return ibuf; } -struct direntry * filelist_file(struct FileList* filelist, int index) +struct direntry *filelist_file(struct FileList *filelist, int index) { int fidx = 0; @@ -687,7 +687,7 @@ struct direntry * filelist_file(struct FileList* filelist, int index) return &filelist->filelist[fidx]; } -int filelist_find(struct FileList* filelist, const char *filename) +int filelist_find(struct FileList *filelist, const char *filename) { int index = -1; int i; @@ -698,7 +698,7 @@ int filelist_find(struct FileList* filelist, const char *filename) for (i = 0; i < filelist->numfiles; ++i) { - if ( strcmp(filelist->filelist[i].relname, filename) == 0) { /* not dealing with user input so don't need BLI_path_cmp */ + if (strcmp(filelist->filelist[i].relname, filename) == 0) { /* not dealing with user input so don't need BLI_path_cmp */ index = i; break; } @@ -713,17 +713,17 @@ int filelist_find(struct FileList* filelist, const char *filename) return fidx; } -void filelist_hidedot(struct FileList* filelist, short hide) +void filelist_hidedot(struct FileList *filelist, short hide) { filelist->hide_dot = hide; } -void filelist_setfilter(struct FileList* filelist, unsigned int filter) +void filelist_setfilter(struct FileList *filelist, unsigned int filter) { filelist->filter = filter; } -void filelist_setfilter_types(struct FileList* filelist, const char *filter_glob) +void filelist_setfilter_types(struct FileList *filelist, const char *filter_glob) { BLI_strncpy(filelist->filter_glob, filter_glob, sizeof(filelist->filter_glob)); } @@ -731,23 +731,23 @@ void filelist_setfilter_types(struct FileList* filelist, const char *filter_glob static int file_is_blend_backup(const char *str) { short a, b; - int retval= 0; + int retval = 0; - a= strlen(str); - b= 7; + 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"); + loc = BLI_strcasestr(str + a - b, ".blend"); if (loc) - retval= 1; + retval = 1; } return (retval); @@ -801,9 +801,9 @@ static int file_extension_type(const char *relname) int ED_file_extension_icon(const char *relname) { - int type= file_extension_type(relname); + int type = file_extension_type(relname); - if (type == BLENDERFILE || type==BLENDERFILE_BACKUP) + if (type == BLENDERFILE || type == BLENDERFILE_BACKUP) return ICON_FILE_BLEND; else if (type == IMAGEFILE) return ICON_FILE_IMAGE; @@ -823,15 +823,15 @@ int ED_file_extension_icon(const char *relname) return ICON_FILE_BLANK; } -static void filelist_setfiletypes(struct FileList* filelist) +static void filelist_setfiletypes(struct FileList *filelist) { struct direntry *file; int num; - file= filelist->filelist; + file = filelist->filelist; - for (num=0; numnumfiles; num++, file++) { - file->type= file->s.st_mode; /* restore the mess below */ + for (num = 0; num < filelist->numfiles; num++, file++) { + file->type = file->s.st_mode; /* restore the mess below */ /* Don't check extensions for directories */ if (file->type & S_IFDIR) { @@ -842,21 +842,21 @@ static void filelist_setfiletypes(struct FileList* filelist) if (filelist->filter_glob && BLI_testextensie_glob(file->relname, filelist->filter_glob)) { - file->flags= OPERATORFILE; + file->flags = OPERATORFILE; } } } -static void filelist_read_dir(struct FileList* filelist) +static void filelist_read_dir(struct FileList *filelist) { - char wdir[FILE_MAX]= ""; + char wdir[FILE_MAX] = ""; if (!filelist) return; filelist->fidx = NULL; filelist->filelist = NULL; - BLI_current_working_dir(wdir, sizeof(wdir)); /* backup cwd to restore after */ + BLI_current_working_dir(wdir, sizeof(wdir)); /* backup cwd to restore after */ BLI_cleanup_dir(G.main->name, filelist->dir); filelist->numfiles = BLI_dir_contents(filelist->dir, &(filelist->filelist)); @@ -866,13 +866,13 @@ static void filelist_read_dir(struct FileList* filelist) filelist_filter(filelist); } -static void filelist_read_main(struct FileList* filelist) +static void filelist_read_main(struct FileList *filelist) { if (!filelist) return; filelist_from_main(filelist); } -static void filelist_read_library(struct FileList* filelist) +static void filelist_read_library(struct FileList *filelist) { if (!filelist) return; BLI_cleanup_dir(G.main->name, filelist->dir); @@ -884,7 +884,7 @@ static void filelist_read_library(struct FileList* filelist) BLI_make_exist(filelist->dir); filelist_read_dir(filelist); file = filelist->filelist; - for (num=0; numnumfiles; num++, file++) { + for (num = 0; num < filelist->numfiles; num++, file++) { if (BLO_has_bfile_extension(file->relname)) { char name[FILE_MAX]; @@ -900,26 +900,26 @@ static void filelist_read_library(struct FileList* filelist) } } -void filelist_readdir(struct FileList* filelist) +void filelist_readdir(struct FileList *filelist) { filelist->readf(filelist); } -int filelist_empty(struct FileList* filelist) +int filelist_empty(struct FileList *filelist) { return filelist->filelist == NULL; } -void filelist_parent(struct FileList* filelist) +void filelist_parent(struct FileList *filelist) { BLI_parent_dir(filelist->dir); BLI_make_exist(filelist->dir); filelist_readdir(filelist); } -void filelist_select_file(struct FileList* filelist, int index, FileSelType select, unsigned int flag, FileCheckType check) +void filelist_select_file(struct FileList *filelist, int index, FileSelType select, unsigned int flag, FileCheckType check) { - struct direntry* file = filelist_file(filelist, index); + struct direntry *file = filelist_file(filelist, index); if (file != NULL) { int check_ok = 0; switch (check) { @@ -950,7 +950,7 @@ void filelist_select_file(struct FileList* filelist, int index, FileSelType sele } } -void filelist_select(struct FileList* filelist, FileSelection* sel, FileSelType select, unsigned int flag, FileCheckType check) +void filelist_select(struct FileList *filelist, FileSelection *sel, FileSelType select, unsigned int flag, FileCheckType check) { /* select all valid files between first and last indicated */ if ( (sel->first >= 0) && (sel->first < filelist->numfiltered) && (sel->last >= 0) && (sel->last < filelist->numfiltered) ) { @@ -961,9 +961,9 @@ void filelist_select(struct FileList* filelist, FileSelection* sel, FileSelType } } -int filelist_is_selected(struct FileList* filelist, int index, FileCheckType check) +int filelist_is_selected(struct FileList *filelist, int index, FileCheckType check) { - struct direntry* file = filelist_file(filelist, index); + struct direntry *file = filelist_file(filelist, index); if (!file) { return 0; } @@ -978,27 +978,27 @@ int filelist_is_selected(struct FileList* filelist, int index, FileCheckType che } } -void filelist_sort(struct FileList* filelist, short sort) +void filelist_sort(struct FileList *filelist, short sort) { switch (sort) { - case FILE_SORT_ALPHA: - qsort(filelist->filelist, filelist->numfiles, sizeof(struct direntry), compare_name); - break; - case FILE_SORT_TIME: - qsort(filelist->filelist, filelist->numfiles, sizeof(struct direntry), compare_date); - break; - case FILE_SORT_SIZE: - qsort(filelist->filelist, filelist->numfiles, sizeof(struct direntry), compare_size); - break; - case FILE_SORT_EXTENSION: - qsort(filelist->filelist, filelist->numfiles, sizeof(struct direntry), compare_extension); + case FILE_SORT_ALPHA: + qsort(filelist->filelist, filelist->numfiles, sizeof(struct direntry), compare_name); + break; + case FILE_SORT_TIME: + qsort(filelist->filelist, filelist->numfiles, sizeof(struct direntry), compare_date); + break; + case FILE_SORT_SIZE: + qsort(filelist->filelist, filelist->numfiles, sizeof(struct direntry), compare_size); + break; + case FILE_SORT_EXTENSION: + qsort(filelist->filelist, filelist->numfiles, sizeof(struct direntry), compare_extension); } filelist_filter(filelist); } -int filelist_islibrary(struct FileList* filelist, char* dir, char* group) +int filelist_islibrary(struct FileList *filelist, char *dir, char *group) { return BLO_is_a_library(filelist->dir, dir, group); } @@ -1009,27 +1009,27 @@ static int groupname_to_code(const char *group) char *lslash; BLI_strncpy(buf, group, sizeof(buf)); - lslash= BLI_last_slash(buf); + lslash = BLI_last_slash(buf); if (lslash) - lslash[0]= '\0'; + lslash[0] = '\0'; return BKE_idcode_from_name(buf); } -void filelist_from_library(struct FileList* filelist) +void filelist_from_library(struct FileList *filelist) { LinkNode *l, *names, *previews; - struct ImBuf* ima; + struct ImBuf *ima; int ok, i, nprevs, nnames, idcode; char filename[FILE_MAX]; char dir[FILE_MAX], group[GROUP_MAX]; /* name test */ - ok= filelist_islibrary(filelist, dir, group); + ok = filelist_islibrary(filelist, dir, group); if (!ok) { /* free */ if (filelist->libfiledata) BLO_blendhandle_close(filelist->libfiledata); - filelist->libfiledata= NULL; + filelist->libfiledata = NULL; return; } @@ -1038,40 +1038,40 @@ void filelist_from_library(struct FileList* filelist) /* there we go */ /* for the time being only read filedata when libfiledata==0 */ if (filelist->libfiledata == NULL) { - filelist->libfiledata= BLO_blendhandle_from_file(dir, NULL); + filelist->libfiledata = BLO_blendhandle_from_file(dir, NULL); if (filelist->libfiledata == NULL) return; } - idcode= groupname_to_code(group); + idcode = groupname_to_code(group); /* memory for strings is passed into filelist[i].relname * and freed in freefilelist */ if (idcode) { - previews= BLO_blendhandle_get_previews(filelist->libfiledata, idcode, &nprevs); - names= BLO_blendhandle_get_datablock_names(filelist->libfiledata, idcode, &nnames); + previews = BLO_blendhandle_get_previews(filelist->libfiledata, idcode, &nprevs); + names = BLO_blendhandle_get_datablock_names(filelist->libfiledata, idcode, &nnames); /* ugh, no rewind, need to reopen */ BLO_blendhandle_close(filelist->libfiledata); - filelist->libfiledata= BLO_blendhandle_from_file(dir, NULL); + filelist->libfiledata = BLO_blendhandle_from_file(dir, NULL); } else { - previews= NULL; - nprevs= 0; - names= BLO_blendhandle_get_linkable_groups(filelist->libfiledata); - nnames= BLI_linklist_length(names); + previews = NULL; + nprevs = 0; + names = BLO_blendhandle_get_linkable_groups(filelist->libfiledata); + nnames = BLI_linklist_length(names); } - filelist->numfiles= nnames + 1; - filelist->filelist= malloc(filelist->numfiles * sizeof(*filelist->filelist)); + filelist->numfiles = nnames + 1; + filelist->filelist = malloc(filelist->numfiles * sizeof(*filelist->filelist)); memset(filelist->filelist, 0, filelist->numfiles * sizeof(*filelist->filelist)); - filelist->filelist[0].relname= BLI_strdup(".."); + filelist->filelist[0].relname = BLI_strdup(".."); filelist->filelist[0].type |= S_IFDIR; - for (i=0, l= names; inext) { - char *blockname= l->link; + for (i = 0, l = names; i < nnames; i++, l = l->next) { + char *blockname = l->link; - filelist->filelist[i + 1].relname= BLI_strdup(blockname); + filelist->filelist[i + 1].relname = BLI_strdup(blockname); if (idcode) { filelist->filelist[i + 1].type |= S_IFREG; } @@ -1084,8 +1084,8 @@ void filelist_from_library(struct FileList* filelist) printf("filelist_from_library: error, found %d items, %d previews\n", nnames, nprevs); } else if (previews) { - for (i=0, l= previews; inext) { - PreviewImage *img= l->link; + for (i = 0, l = previews; i < nnames; i++, l = l->next) { + PreviewImage *img = l->link; if (img) { unsigned int w = img->w[ICON_SIZE_PREVIEW]; @@ -1095,7 +1095,7 @@ void filelist_from_library(struct FileList* filelist) /* first allocate imbuf for copying preview into it */ if (w > 0 && h > 0 && rect) { ima = IMB_allocImBuf(w, h, 32, IB_rect); - memcpy(ima->rect, rect, w*h*sizeof(unsigned int)); + memcpy(ima->rect, rect, w * h * sizeof(unsigned int)); filelist->filelist[i + 1].image = ima; filelist->filelist[i + 1].flags = IMAGEFILE; } @@ -1108,13 +1108,13 @@ void filelist_from_library(struct FileList* filelist) filelist_sort(filelist, FILE_SORT_ALPHA); - BLI_strncpy(G.main->name, filename, sizeof(filename)); // prevent G.main->name to change + BLI_strncpy(G.main->name, filename, sizeof(filename)); // prevent G.main->name to change filelist->filter = 0; filelist_filter(filelist); } -void filelist_hideparent(struct FileList* filelist, short hide) +void filelist_hideparent(struct FileList *filelist, short hide) { filelist->hide_parent = hide; } @@ -1128,109 +1128,109 @@ 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]) { - idcode= groupname_to_code(filelist->dir); - if (idcode==0) filelist->dir[0]= 0; + idcode = groupname_to_code(filelist->dir); + 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)); + filelist->numfiles = 24; + filelist->filelist = (struct direntry *)malloc(filelist->numfiles * sizeof(struct direntry)); - for (a=0; anumfiles; a++) { + for (a = 0; a < filelist->numfiles; a++) { memset(&(filelist->filelist[a]), 0, sizeof(struct direntry)); filelist->filelist[a].type |= S_IFDIR; } - filelist->filelist[0].relname= BLI_strdup(".."); - filelist->filelist[2].relname= BLI_strdup("Scene"); - filelist->filelist[3].relname= BLI_strdup("Object"); - filelist->filelist[4].relname= BLI_strdup("Mesh"); - filelist->filelist[5].relname= BLI_strdup("Curve"); - filelist->filelist[6].relname= BLI_strdup("Metaball"); - filelist->filelist[7].relname= BLI_strdup("Material"); - filelist->filelist[8].relname= BLI_strdup("Texture"); - filelist->filelist[9].relname= BLI_strdup("Image"); - filelist->filelist[10].relname= BLI_strdup("Ika"); - filelist->filelist[11].relname= BLI_strdup("Wave"); - filelist->filelist[12].relname= BLI_strdup("Lattice"); - filelist->filelist[13].relname= BLI_strdup("Lamp"); - filelist->filelist[14].relname= BLI_strdup("Camera"); - filelist->filelist[15].relname= BLI_strdup("Ipo"); - filelist->filelist[16].relname= BLI_strdup("World"); - filelist->filelist[17].relname= BLI_strdup("Screen"); - filelist->filelist[18].relname= BLI_strdup("VFont"); - filelist->filelist[19].relname= BLI_strdup("Text"); - filelist->filelist[20].relname= BLI_strdup("Armature"); - filelist->filelist[21].relname= BLI_strdup("Action"); - filelist->filelist[22].relname= BLI_strdup("NodeTree"); - filelist->filelist[23].relname= BLI_strdup("Speaker"); + filelist->filelist[0].relname = BLI_strdup(".."); + filelist->filelist[2].relname = BLI_strdup("Scene"); + filelist->filelist[3].relname = BLI_strdup("Object"); + filelist->filelist[4].relname = BLI_strdup("Mesh"); + filelist->filelist[5].relname = BLI_strdup("Curve"); + filelist->filelist[6].relname = BLI_strdup("Metaball"); + filelist->filelist[7].relname = BLI_strdup("Material"); + filelist->filelist[8].relname = BLI_strdup("Texture"); + filelist->filelist[9].relname = BLI_strdup("Image"); + filelist->filelist[10].relname = BLI_strdup("Ika"); + filelist->filelist[11].relname = BLI_strdup("Wave"); + filelist->filelist[12].relname = BLI_strdup("Lattice"); + filelist->filelist[13].relname = BLI_strdup("Lamp"); + filelist->filelist[14].relname = BLI_strdup("Camera"); + filelist->filelist[15].relname = BLI_strdup("Ipo"); + filelist->filelist[16].relname = BLI_strdup("World"); + filelist->filelist[17].relname = BLI_strdup("Screen"); + filelist->filelist[18].relname = BLI_strdup("VFont"); + filelist->filelist[19].relname = BLI_strdup("Text"); + filelist->filelist[20].relname = BLI_strdup("Armature"); + filelist->filelist[21].relname = BLI_strdup("Action"); + filelist->filelist[22].relname = BLI_strdup("NodeTree"); + filelist->filelist[23].relname = BLI_strdup("Speaker"); filelist_sort(filelist, FILE_SORT_ALPHA); } else { /* make files */ - idcode= groupname_to_code(filelist->dir); + idcode = groupname_to_code(filelist->dir); - lb= which_libbase(G.main, idcode ); + lb = which_libbase(G.main, idcode); if (lb == NULL) return; - id= lb->first; - filelist->numfiles= 0; + id = lb->first; + filelist->numfiles = 0; while (id) { if (!filelist->hide_dot || id->name[2] != '.') { filelist->numfiles++; } - id= id->next; + id = id->next; } /* XXXXX TODO: if databrowse F4 or append/link filelist->hide_parent has to be set */ - if (!filelist->hide_parent) filelist->numfiles+= 1; - filelist->filelist= filelist->numfiles > 0 ? (struct direntry *)malloc(filelist->numfiles * sizeof(struct direntry)) : NULL; + if (!filelist->hide_parent) filelist->numfiles += 1; + filelist->filelist = filelist->numfiles > 0 ? (struct direntry *)malloc(filelist->numfiles * sizeof(struct direntry)) : NULL; files = filelist->filelist; if (!filelist->hide_parent) { memset(&(filelist->filelist[0]), 0, sizeof(struct direntry)); - filelist->filelist[0].relname= BLI_strdup(".."); + filelist->filelist[0].relname = BLI_strdup(".."); filelist->filelist[0].type |= S_IFDIR; files++; } - id= lb->first; - totlib= totbl= 0; + id = lb->first; + totlib = totbl = 0; while (id) { ok = 1; if (ok) { if (!filelist->hide_dot || id->name[2] != '.') { memset(files, 0, sizeof(struct direntry)); - if (id->lib==NULL) - files->relname= BLI_strdup(id->name+2); + if (id->lib == NULL) + files->relname = BLI_strdup(id->name + 2); else { - files->relname= MEM_mallocN(FILE_MAX+32, "filename for lib"); - sprintf(files->relname, "%s | %s", id->lib->name, id->name+2); + files->relname = MEM_mallocN(FILE_MAX + 32, "filename for lib"); + sprintf(files->relname, "%s | %s", id->lib->name, id->name + 2); } files->type |= S_IFREG; -#if 0 // XXXXX TODO show the selection status of the objects +#if 0 // XXXXX TODO show the selection status of the objects if (!filelist->has_func) { /* F4 DATA BROWSE */ - if (idcode==ID_OB) { + if (idcode == ID_OB) { if ( ((Object *)id)->flag & SELECT) files->selflag |= SELECTED_FILE; } - else if (idcode==ID_SCE) { + 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; + 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) { files->flags |= IMAGEFILE; } @@ -1240,7 +1240,7 @@ void filelist_from_main(struct FileList *filelist) else BLI_snprintf(files->extra, sizeof(files->extra), " %d", id->us); if (id->lib) { - if (totlib==0) firstlib= files; + if (totlib == 0) firstlib = files; totlib++; } @@ -1249,11 +1249,11 @@ void filelist_from_main(struct FileList *filelist) totbl++; } - id= id->next; + id = id->next; } /* only qsort of library blocks */ - if (totlib>1) { + if (totlib > 1) { qsort(firstlib, totlib, sizeof(struct direntry), compare_name); } } @@ -1263,10 +1263,10 @@ void filelist_from_main(struct FileList *filelist) static void thumbnail_joblist_free(ThumbnailJob *tj) { - FileImage* limg = tj->loadimages.first; + 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); } @@ -1276,26 +1276,26 @@ static void thumbnail_joblist_free(ThumbnailJob *tj) static void thumbnails_startjob(void *tjv, short *stop, short *do_update, float *UNUSED(progress)) { - ThumbnailJob *tj= tjv; - FileImage* limg = tj->loadimages.first; + ThumbnailJob *tj = tjv; + FileImage *limg = tj->loadimages.first; - tj->stop= stop; - tj->do_update= do_update; + tj->stop = stop; + tj->do_update = do_update; - while ( (*stop==0) && (limg) ) { - if ( limg->flags & IMAGEFILE ) { + 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 */ - limg->flags &= ~MOVIEFILE; - limg->flags |= MOVIEFILE_ICON; - } + /* remember that file can't be loaded via IMB_open_anim */ + limg->flags &= ~MOVIEFILE; + limg->flags |= MOVIEFILE_ICON; + } } *do_update = TRUE; PIL_sleep_ms(10); @@ -1305,10 +1305,10 @@ static void thumbnails_startjob(void *tjv, short *stop, short *do_update, float static void thumbnails_update(void *tjv) { - ThumbnailJob *tj= tjv; + ThumbnailJob *tj = tjv; if (tj->filelist && tj->filelist->filelist) { - FileImage* limg = tj->loadimages.first; + FileImage *limg = tj->loadimages.first; while (limg) { if (!limg->done && limg->img) { tj->filelist->filelist[limg->index].image = limg->img; @@ -1326,28 +1326,28 @@ static void thumbnails_update(void *tjv) static void thumbnails_free(void *tjv) { - ThumbnailJob *tj= tjv; + ThumbnailJob *tj = tjv; thumbnail_joblist_free(tj); MEM_freeN(tj); } -void thumbnails_start(struct FileList* filelist, const struct bContext* C) +void thumbnails_start(struct FileList *filelist, const struct bContext *C) { wmJob *steve; ThumbnailJob *tj; int idx; /* prepare job data */ - tj= MEM_callocN(sizeof(ThumbnailJob), "thumbnails\n"); + tj = MEM_callocN(sizeof(ThumbnailJob), "thumbnails\n"); tj->filelist = filelist; - for (idx = 0; idx < filelist->numfiles;idx++) { + for (idx = 0; idx < filelist->numfiles; idx++) { if (!filelist->filelist[idx].image) { - if ( (filelist->filelist[idx].flags & (IMAGEFILE|MOVIEFILE|BLENDERFILE)) ) { - FileImage* limg = MEM_callocN(sizeof(struct FileImage), "loadimage"); + if ( (filelist->filelist[idx].flags & (IMAGEFILE | MOVIEFILE | BLENDERFILE)) ) { + FileImage *limg = MEM_callocN(sizeof(struct FileImage), "loadimage"); BLI_strncpy(limg->path, filelist->filelist[idx].path, FILE_MAX); - limg->index= idx; - limg->flags= filelist->filelist[idx].flags; + limg->index = idx; + limg->flags = filelist->filelist[idx].flags; BLI_addtail(&tj->loadimages, limg); } } @@ -1356,7 +1356,7 @@ void thumbnails_start(struct FileList* filelist, const struct bContext* C) BKE_reports_init(&tj->reports, RPT_PRINT); /* setup job */ - steve= WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), filelist, "Thumbnails", 0); + steve = WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), filelist, "Thumbnails", 0); WM_jobs_customdata(steve, tj, thumbnails_free); WM_jobs_timer(steve, 0.5, NC_WINDOW, NC_WINDOW); WM_jobs_callbacks(steve, thumbnails_startjob, NULL, thumbnails_update, NULL); @@ -1365,12 +1365,12 @@ void thumbnails_start(struct FileList* filelist, const struct bContext* C) WM_jobs_start(CTX_wm_manager(C), steve); } -void thumbnails_stop(struct FileList* filelist, const struct bContext* C) +void thumbnails_stop(struct FileList *filelist, const struct bContext *C) { WM_jobs_kill(CTX_wm_manager(C), filelist, NULL); } -int thumbnails_running(struct FileList* filelist, const struct bContext* C) +int thumbnails_running(struct FileList *filelist, const struct bContext *C) { return WM_jobs_test(CTX_wm_manager(C), filelist); } diff --git a/source/blender/editors/space_file/filelist.h b/source/blender/editors/space_file/filelist.h index 7a37c5fb3c5..32a31c51229 100644 --- a/source/blender/editors/space_file/filelist.h +++ b/source/blender/editors/space_file/filelist.h @@ -49,8 +49,8 @@ struct FileSelection; typedef enum FileSelType { FILE_SEL_REMOVE = 0, - FILE_SEL_ADD = 1, - FILE_SEL_TOGGLE = 2 + FILE_SEL_ADD = 1, + FILE_SEL_TOGGLE = 2 } FileSelType; typedef enum FileCheckType { @@ -59,49 +59,49 @@ typedef enum FileCheckType { CHECK_ALL = 3 } FileCheckType; -struct FileList * filelist_new(short type); -void filelist_init_icons(void); -void filelist_free_icons(void); -int filelist_find(struct FileList* filelist, const char *file); -void filelist_free(struct FileList* filelist); -void filelist_sort(struct FileList* filelist, short sort); -int filelist_numfiles(struct FileList* filelist); -const char * filelist_dir(struct FileList* filelist); -void filelist_setdir(struct FileList* filelist, const char *dir); -struct direntry * filelist_file(struct FileList* filelist, int index); -void filelist_select(struct FileList* filelist, FileSelection* sel, FileSelType select, unsigned int flag, FileCheckType check); -void filelist_select_file(struct FileList* filelist, int index, FileSelType select, unsigned int flag, FileCheckType check); -int filelist_is_selected(struct FileList* filelist, int index, FileCheckType check); -void filelist_hidedot(struct FileList* filelist, short hide); -void filelist_setfilter(struct FileList* filelist, unsigned int filter); -void filelist_setfilter_types(struct FileList* filelist, const char *filter_glob); -void filelist_filter(struct FileList* filelist); -void filelist_imgsize(struct FileList* filelist, short w, short h); -struct ImBuf * filelist_getimage(struct FileList* filelist, int index); -struct ImBuf * filelist_geticon(struct FileList* filelist, int index); -short filelist_changed(struct FileList* filelist); -void filelist_readdir(struct FileList* filelist); +struct FileList * filelist_new(short type); +void filelist_init_icons(void); +void filelist_free_icons(void); +int filelist_find(struct FileList *filelist, const char *file); +void filelist_free(struct FileList *filelist); +void filelist_sort(struct FileList *filelist, short sort); +int filelist_numfiles(struct FileList *filelist); +const char * filelist_dir(struct FileList *filelist); +void filelist_setdir(struct FileList *filelist, const char *dir); +struct direntry * filelist_file(struct FileList *filelist, int index); +void filelist_select(struct FileList *filelist, FileSelection *sel, FileSelType select, unsigned int flag, FileCheckType check); +void filelist_select_file(struct FileList *filelist, int index, FileSelType select, unsigned int flag, FileCheckType check); +int filelist_is_selected(struct FileList *filelist, int index, FileCheckType check); +void filelist_hidedot(struct FileList *filelist, short hide); +void filelist_setfilter(struct FileList *filelist, unsigned int filter); +void filelist_setfilter_types(struct FileList *filelist, const char *filter_glob); +void filelist_filter(struct FileList *filelist); +void filelist_imgsize(struct FileList *filelist, short w, short h); +struct ImBuf * filelist_getimage(struct FileList *filelist, int index); +struct ImBuf * filelist_geticon(struct FileList *filelist, int index); +short filelist_changed(struct FileList *filelist); +void filelist_readdir(struct FileList *filelist); -int filelist_empty(struct FileList* filelist); -void filelist_parent(struct FileList* filelist); +int filelist_empty(struct FileList *filelist); +void filelist_parent(struct FileList *filelist); -struct BlendHandle *filelist_lib(struct FileList* filelist); -int filelist_islibrary (struct FileList* filelist, char* dir, char* group); -void filelist_from_main(struct FileList* filelist); -void filelist_from_library(struct FileList* filelist); -void filelist_freelib(struct FileList* filelist); -void filelist_hideparent(struct FileList* filelist, short hide); +struct BlendHandle *filelist_lib(struct FileList *filelist); +int filelist_islibrary(struct FileList *filelist, char *dir, char *group); +void filelist_from_main(struct FileList *filelist); +void filelist_from_library(struct FileList *filelist); +void filelist_freelib(struct FileList *filelist); +void filelist_hideparent(struct FileList *filelist, short hide); -struct ListBase * folderlist_new(void); -void folderlist_free(struct ListBase* folderlist); -struct ListBase * folderlist_duplicate(ListBase* folderlist); -void folderlist_popdir(struct ListBase* folderlist, char *dir); -void folderlist_pushdir(struct ListBase* folderlist, const char *dir); -int folderlist_clear_next(struct SpaceFile* sfile); +struct ListBase * folderlist_new(void); +void folderlist_free(struct ListBase *folderlist); +struct ListBase * folderlist_duplicate(ListBase *folderlist); +void folderlist_popdir(struct ListBase *folderlist, char *dir); +void folderlist_pushdir(struct ListBase *folderlist, const char *dir); +int folderlist_clear_next(struct SpaceFile *sfile); -void thumbnails_stop(struct FileList* filelist, const struct bContext* C); -void thumbnails_start(struct FileList* filelist, const struct bContext* C); -int thumbnails_running(struct FileList* filelist, const struct bContext* C); +void thumbnails_stop(struct FileList *filelist, const struct bContext *C); +void thumbnails_start(struct FileList *filelist, const struct bContext *C); +int thumbnails_running(struct FileList *filelist, const struct bContext *C); #ifdef __cplusplus } diff --git a/source/blender/editors/space_file/filesel.c b/source/blender/editors/space_file/filesel.c index 969bdcb0d19..adb3e7acca5 100644 --- a/source/blender/editors/space_file/filesel.c +++ b/source/blender/editors/space_file/filesel.c @@ -86,7 +86,7 @@ # include #endif -FileSelectParams* ED_fileselect_get_params(struct SpaceFile *sfile) +FileSelectParams *ED_fileselect_get_params(struct SpaceFile *sfile) { if (!sfile->params) { ED_fileselect_set_params(sfile); @@ -101,7 +101,7 @@ short ED_fileselect_set_params(SpaceFile *sfile) /* create new parameters if necessary */ if (!sfile->params) { - sfile->params= MEM_callocN(sizeof(FileSelectParams), "fileselparams"); + sfile->params = MEM_callocN(sizeof(FileSelectParams), "fileselparams"); /* set path to most recently opened .blend */ BLI_split_dirfile(G.main->name, sfile->params->dir, sfile->params->file, sizeof(sfile->params->dir), sizeof(sfile->params->file)); sfile->params->filter_glob[0] = '\0'; @@ -111,11 +111,11 @@ short ED_fileselect_set_params(SpaceFile *sfile) /* set the parameters from the operator, if it exists */ if (op) { - const short is_files= (RNA_struct_find_property(op->ptr, "files") != NULL); - const short is_filepath= (RNA_struct_find_property(op->ptr, "filepath") != NULL); - const short is_filename= (RNA_struct_find_property(op->ptr, "filename") != NULL); - const short is_directory= (RNA_struct_find_property(op->ptr, "directory") != NULL); - const short is_relative_path= (RNA_struct_find_property(op->ptr, "relative_path") != NULL); + const short is_files = (RNA_struct_find_property(op->ptr, "files") != NULL); + const short is_filepath = (RNA_struct_find_property(op->ptr, "filepath") != NULL); + const short is_filename = (RNA_struct_find_property(op->ptr, "filename") != NULL); + const short is_directory = (RNA_struct_find_property(op->ptr, "directory") != NULL); + const short is_relative_path = (RNA_struct_find_property(op->ptr, "relative_path") != NULL); BLI_strncpy(params->title, RNA_struct_ui_name(op->type->srna), sizeof(params->title)); @@ -129,7 +129,7 @@ short ED_fileselect_set_params(SpaceFile *sfile) RNA_string_get(op->ptr, "filepath", name); if (params->type == FILE_LOADLIB) { BLI_strncpy(params->dir, name, sizeof(params->dir)); - sfile->params->file[0]= '\0'; + sfile->params->file[0] = '\0'; } else { BLI_split_dirfile(name, sfile->params->dir, sfile->params->file, sizeof(sfile->params->dir), sizeof(sfile->params->file)); @@ -138,7 +138,7 @@ short ED_fileselect_set_params(SpaceFile *sfile) else { if (is_directory && RNA_struct_property_is_set(op->ptr, "directory")) { RNA_string_get(op->ptr, "directory", params->dir); - sfile->params->file[0]= '\0'; + sfile->params->file[0] = '\0'; } if (is_filename && RNA_struct_property_is_set(op->ptr, "filename")) { @@ -151,7 +151,7 @@ short ED_fileselect_set_params(SpaceFile *sfile) 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 { @@ -183,7 +183,7 @@ short ED_fileselect_set_params(SpaceFile *sfile) 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); - params->filter |= (OPERATORFILE|FOLDERFILE); + params->filter |= (OPERATORFILE | FOLDERFILE); } else { params->filter_glob[0] = '\0'; @@ -213,17 +213,17 @@ short ED_fileselect_set_params(SpaceFile *sfile) } if (RNA_struct_find_property(op->ptr, "display_type")) - params->display= RNA_enum_get(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)) - params->display= FILE_IMGDISPLAY; + if (params->filter & (IMAGEFILE | MOVIEFILE)) + params->display = FILE_IMGDISPLAY; else - params->display= FILE_SHORTDISPLAY; + params->display = FILE_SHORTDISPLAY; } else { - params->display= FILE_SHORTDISPLAY; + params->display = FILE_SHORTDISPLAY; } } @@ -252,7 +252,7 @@ short ED_fileselect_set_params(SpaceFile *sfile) /* switching thumbnails needs to recalc layout [#28809] */ if (sfile->layout) { - sfile->layout->dirty= TRUE; + sfile->layout->dirty = TRUE; } return 1; @@ -265,28 +265,28 @@ void ED_fileselect_reset_params(SpaceFile *sfile) sfile->params->title[0] = '\0'; } -int ED_fileselect_layout_numfiles(FileLayout* layout, struct ARegion *ar) +int ED_fileselect_layout_numfiles(FileLayout *layout, struct ARegion *ar) { int numfiles; if (layout->flag & FILE_LAYOUT_HOR) { - int width = (int)(ar->v2d.cur.xmax - ar->v2d.cur.xmin - 2*layout->tile_border_x); + 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; + return numfiles * layout->rows; } 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; + 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; } } static int is_inside(int x, int y, int cols, int rows) { - return ( (x >= 0) && (x=0) && (y= 0) && (x < cols) && (y >= 0) && (y < rows) ); } -FileSelection ED_fileselect_layout_offset_rect(FileLayout* layout, const rcti* rect) +FileSelection ED_fileselect_layout_offset_rect(FileLayout *layout, const rcti *rect) { int colmin, colmax, rowmin, rowmax; FileSelection sel; @@ -295,43 +295,43 @@ 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); + 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) ) { - CLAMP(colmin, 0, layout->columns-1); - CLAMP(rowmin, 0, layout->rows-1); - CLAMP(colmax, 0, layout->columns-1); - CLAMP(rowmax, 0, layout->rows-1); + CLAMP(colmin, 0, layout->columns - 1); + CLAMP(rowmin, 0, layout->rows - 1); + CLAMP(colmax, 0, layout->columns - 1); + CLAMP(rowmax, 0, layout->rows - 1); } - if ((colmin > layout->columns-1) || (rowmin > layout->rows-1)) { + if ((colmin > layout->columns - 1) || (rowmin > layout->rows - 1)) { sel.first = -1; } else { if (layout->flag & FILE_LAYOUT_HOR) - sel.first = layout->rows*colmin + rowmin; + sel.first = layout->rows * colmin + rowmin; else - sel.first = colmin + layout->columns*rowmin; + sel.first = colmin + layout->columns * rowmin; } - if ((colmax > layout->columns-1) || (rowmax > layout->rows-1)) { + if ((colmax > layout->columns - 1) || (rowmax > layout->rows - 1)) { sel.last = -1; } else { if (layout->flag & FILE_LAYOUT_HOR) - sel.last = layout->rows*colmax + rowmax; + sel.last = layout->rows * colmax + rowmax; else - sel.last = colmax + layout->columns*rowmax; + sel.last = colmax + layout->columns * rowmax; } return sel; } -int ED_fileselect_layout_offset(FileLayout* layout, int x, int y) +int ED_fileselect_layout_offset(FileLayout *layout, int x, int y) { int offsetx, offsety; int active_file; @@ -339,35 +339,35 @@ 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); + 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) - active_file = layout->rows*offsetx + offsety; + active_file = layout->rows * offsetx + offsety; else - active_file = offsetx + layout->columns*offsety; + active_file = offsetx + layout->columns * offsety; return active_file; } -void ED_fileselect_layout_tilepos(FileLayout* layout, int tile, int *x, int *y) +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); + *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 { - *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); + *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); } } /* Shorten a string to a given width w. * If front is set, shorten from the front, * otherwise shorten from the end. */ -float file_shorten_string(char* string, float w, int front) +float file_shorten_string(char *string, float w, int front) { char temp[FILE_MAX]; short shortened = 0; @@ -384,23 +384,23 @@ float file_shorten_string(char* string, float w, int front) char *s = string; BLI_strncpy(temp, "...", 4); pad = file_string_width(temp); - while ((*s) && (sw+pad>w)) { + while ((*s) && (sw + pad > w)) { s++; sw = file_string_width(s); shortened = 1; } if (shortened) { int slen = strlen(s); - BLI_strncpy(temp+3, s, slen+1); - temp[slen+4] = '\0'; - BLI_strncpy(string, temp, slen+4); + BLI_strncpy(temp + 3, s, slen + 1); + temp[slen + 4] = '\0'; + BLI_strncpy(string, temp, slen + 4); } } else { char *s = string; - while (sw>w) { + while (sw > w) { int slen = strlen(string); - string[slen-1] = '\0'; + string[slen - 1] = '\0'; sw = file_string_width(s); shortened = 1; } @@ -408,7 +408,7 @@ float file_shorten_string(char* string, float w, int front) if (shortened) { int slen = strlen(string); if (slen > 3) { - BLI_strncpy(string+slen-3, "...", 4); + BLI_strncpy(string + slen - 3, "...", 4); } } } @@ -416,9 +416,9 @@ float file_shorten_string(char* string, float w, int front) return sw; } -float file_string_width(const char* str) +float file_string_width(const char *str) { - uiStyle *style= UI_GetStyle(); + uiStyle *style = UI_GetStyle(); uiStyleFontSet(&style->widget); return BLF_width(style->widget.uifont_id, str); } @@ -428,28 +428,28 @@ float file_font_pointsize(void) #if 0 float s; char tmp[2] = "X"; - uiStyle *style= UI_GetStyle(); + uiStyle *style = UI_GetStyle(); uiStyleFontSet(&style->widget); s = BLF_height(style->widget.uifont_id, tmp); return style->widget.points; #else - uiStyle *style= UI_GetStyle(); + uiStyle *style = UI_GetStyle(); uiStyleFontSet(&style->widget); return style->widget.points * UI_DPI_FAC; #endif } -static void column_widths(struct FileList* files, struct FileLayout* layout) +static void column_widths(struct FileList *files, struct FileLayout *layout) { int i; int numfiles = filelist_numfiles(files); - for (i=0; icolumn_widths[i] = 0; } - for (i=0; (i < numfiles); ++i) { - struct direntry* file = filelist_file(files, i); + for (i = 0; (i < numfiles); ++i) { + struct direntry *file = filelist_file(files, i); if (file) { float len; len = file_string_width(file->relname); @@ -475,8 +475,8 @@ static void column_widths(struct FileList* files, struct FileLayout* layout) void ED_fileselect_init_layout(struct SpaceFile *sfile, struct ARegion *ar) { FileSelectParams *params = ED_fileselect_get_params(sfile); - FileLayout *layout= NULL; - View2D *v2d= &ar->v2d; + FileLayout *layout = NULL; + View2D *v2d = &ar->v2d; int maxlen = 0; int numfiles; int textheight; @@ -501,17 +501,17 @@ void ED_fileselect_init_layout(struct SpaceFile *sfile, struct ARegion *ar) layout->tile_border_y = 6; layout->prv_border_x = 6; layout->prv_border_y = 6; - layout->tile_w = layout->prv_w + 2*layout->prv_border_x; - 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); + layout->tile_w = layout->prv_w + 2 * layout->prv_border_x; + 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) - layout->rows= numfiles/layout->columns + 1; // XXX dirty, modulo is zero + layout->rows = numfiles / layout->columns + 1; // XXX dirty, modulo is zero else { layout->columns = 1; - layout->rows= numfiles + 1; // XXX dirty, modulo is zero + layout->rows = numfiles + 1; // XXX dirty, modulo is zero } - layout->height= sfile->layout->rows*(layout->tile_h+2*layout->tile_border_y) + layout->tile_border_y*2; + layout->height = sfile->layout->rows * (layout->tile_h + 2 * layout->tile_border_y) + layout->tile_border_y * 2; layout->flag = FILE_LAYOUT_VER; } else { @@ -521,45 +521,45 @@ void ED_fileselect_init_layout(struct SpaceFile *sfile, struct ARegion *ar) layout->tile_border_y = 2; layout->prv_border_x = 0; layout->prv_border_y = 0; - layout->tile_h = textheight*3/2; - layout->height= (int)(v2d->cur.ymax - v2d->cur.ymin - 2*layout->tile_border_y); - layout->rows = layout->height / (layout->tile_h + 2*layout->tile_border_y); + layout->tile_h = textheight * 3 / 2; + layout->height = (int)(v2d->cur.ymax - v2d->cur.ymin - 2 * layout->tile_border_y); + layout->rows = layout->height / (layout->tile_h + 2 * layout->tile_border_y); column_widths(sfile->files, layout); if (params->display == FILE_SHORTDISPLAY) { maxlen = ICON_DEFAULT_WIDTH_SCALE + 4 + - (int)layout->column_widths[COLUMN_NAME] + 12 + - (int)layout->column_widths[COLUMN_SIZE] + 12; + (int)layout->column_widths[COLUMN_NAME] + 12 + + (int)layout->column_widths[COLUMN_SIZE] + 12; } else { maxlen = ICON_DEFAULT_WIDTH_SCALE + 4 + - (int)layout->column_widths[COLUMN_NAME] + 12 + + (int)layout->column_widths[COLUMN_NAME] + 12 + #ifndef WIN32 - (int)layout->column_widths[COLUMN_MODE1] + 12 + - (int)layout->column_widths[COLUMN_MODE2] + 12 + - (int)layout->column_widths[COLUMN_MODE3] + 12 + - (int)layout->column_widths[COLUMN_OWNER] + 12 + + (int)layout->column_widths[COLUMN_MODE1] + 12 + + (int)layout->column_widths[COLUMN_MODE2] + 12 + + (int)layout->column_widths[COLUMN_MODE3] + 12 + + (int)layout->column_widths[COLUMN_OWNER] + 12 + #endif - (int)layout->column_widths[COLUMN_DATE] + 12 + - (int)layout->column_widths[COLUMN_TIME] + 12 + - (int)layout->column_widths[COLUMN_SIZE] + 12; + (int)layout->column_widths[COLUMN_DATE] + 12 + + (int)layout->column_widths[COLUMN_TIME] + 12 + + (int)layout->column_widths[COLUMN_SIZE] + 12; } layout->tile_w = maxlen; if (layout->rows > 0) - layout->columns = numfiles/layout->rows + 1; // XXX dirty, modulo is zero + layout->columns = numfiles / layout->rows + 1; // XXX dirty, modulo is zero else { layout->rows = 1; layout->columns = numfiles + 1; // XXX dirty, modulo is zero } - layout->width = sfile->layout->columns * (layout->tile_w + 2*layout->tile_border_x) + layout->tile_border_x*2; + layout->width = sfile->layout->columns * (layout->tile_w + 2 * layout->tile_border_x) + layout->tile_border_x * 2; layout->flag = FILE_LAYOUT_HOR; } - layout->dirty= FALSE; + layout->dirty = FALSE; } -FileLayout* ED_fileselect_get_layout(struct SpaceFile *sfile, struct ARegion *ar) +FileLayout *ED_fileselect_get_layout(struct SpaceFile *sfile, struct ARegion *ar) { if (!sfile->layout) { ED_fileselect_init_layout(sfile, ar); @@ -569,13 +569,13 @@ FileLayout* ED_fileselect_get_layout(struct SpaceFile *sfile, struct ARegion *ar void file_change_dir(bContext *C, int checkdir) { - SpaceFile *sfile= CTX_wm_space_file(C); + SpaceFile *sfile = CTX_wm_space_file(C); if (sfile->params) { 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 */ } @@ -605,7 +605,7 @@ int file_select_match(struct SpaceFile *sfile, const char *pattern, char *matche if (fnmatch(pattern, file->relname, 0) == 0) { file->selflag |= SELECTED_FILE; if (!match) { - BLI_strncpy(matched_file, file->relname, FILE_MAX ); + BLI_strncpy(matched_file, file->relname, FILE_MAX); } match = 1; } @@ -616,7 +616,7 @@ int file_select_match(struct SpaceFile *sfile, const char *pattern, char *matche void autocomplete_directory(struct bContext *C, char *str, void *UNUSED(arg_v)) { - SpaceFile *sfile= CTX_wm_space_file(C); + SpaceFile *sfile = CTX_wm_space_file(C); /* search if str matches the beginning of name */ if (str[0] && sfile->files) { @@ -630,10 +630,10 @@ void autocomplete_directory(struct bContext *C, char *str, void *UNUSED(arg_v)) dir = opendir(dirname); if (dir) { - AutoComplete *autocpl= autocomplete_begin(str, FILE_MAX); + AutoComplete *autocpl = autocomplete_begin(str, FILE_MAX); while ((de = readdir(dir)) != NULL) { - if (strcmp(".", de->d_name)==0 || strcmp("..", de->d_name)==0) { + if (strcmp(".", de->d_name) == 0 || strcmp("..", de->d_name) == 0) { /* pass */ } else { @@ -664,16 +664,16 @@ void autocomplete_directory(struct bContext *C, char *str, void *UNUSED(arg_v)) void autocomplete_file(struct bContext *C, char *str, void *UNUSED(arg_v)) { - SpaceFile *sfile= CTX_wm_space_file(C); + SpaceFile *sfile = CTX_wm_space_file(C); /* search if str matches the beginning of name */ if (str[0] && sfile->files) { - AutoComplete *autocpl= autocomplete_begin(str, FILE_MAX); + AutoComplete *autocpl = autocomplete_begin(str, FILE_MAX); int nentries = filelist_numfiles(sfile->files); int i; - for (i= 0; ifiles, 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); } @@ -692,7 +692,7 @@ void ED_fileselect_clear(struct bContext *C, struct SpaceFile *sfile) } sfile->params->active_file = -1; - WM_event_add_notifier(C, NC_SPACE|ND_SPACE_FILE_LIST, NULL); + WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_LIST, NULL); } void ED_fileselect_exit(struct bContext *C, struct SpaceFile *sfile) @@ -709,7 +709,7 @@ void ED_fileselect_exit(struct bContext *C, struct SpaceFile *sfile) if (sfile->files) { ED_fileselect_clear(C, sfile); MEM_freeN(sfile->files); - sfile->files= NULL; + sfile->files = NULL; } } diff --git a/source/blender/editors/space_file/fsmenu.c b/source/blender/editors/space_file/fsmenu.c index 6d2381e64d5..0366043aaa0 100644 --- a/source/blender/editors/space_file/fsmenu.c +++ b/source/blender/editors/space_file/fsmenu.c @@ -449,9 +449,9 @@ void fsmenu_read_system(struct FSMenu *fsmenu, int read_bookmarks) itemRef = (LSSharedFileListItemRef)CFArrayGetValueAtIndex(pathesArray, i); err = LSSharedFileListItemResolve(itemRef, - kLSSharedFileListNoUserInteraction | - kLSSharedFileListDoNotMountVolumes, - &cfURL, NULL); + kLSSharedFileListNoUserInteraction | + kLSSharedFileListDoNotMountVolumes, + &cfURL, NULL); if (err != noErr) continue; diff --git a/source/blender/editors/space_file/fsmenu.h b/source/blender/editors/space_file/fsmenu.h index e5b3d54ac9f..d7576d71933 100644 --- a/source/blender/editors/space_file/fsmenu.h +++ b/source/blender/editors/space_file/fsmenu.h @@ -45,42 +45,42 @@ typedef enum FSMenuCategory { struct FSMenu; -struct FSMenu* fsmenu_get (void); +struct FSMenu *fsmenu_get(void); - /** Returns the number of entries in the Fileselect Menu */ -int fsmenu_get_nentries (struct FSMenu* fsmenu, FSMenuCategory category); +/** Returns the number of entries in the Fileselect Menu */ +int fsmenu_get_nentries(struct FSMenu *fsmenu, FSMenuCategory category); - /** Returns the fsmenu entry at \a index (or NULL if a bad index) - * or a separator. - */ -char* fsmenu_get_entry (struct FSMenu* fsmenu, FSMenuCategory category, int index); +/** Returns the fsmenu entry at \a index (or NULL if a bad index) + * or a separator. + */ +char *fsmenu_get_entry(struct FSMenu *fsmenu, FSMenuCategory category, int index); - /** Inserts a new fsmenu entry with the given \a path. - * Duplicate entries are not added. - * \param sorted Should entry be inserted in sorted order? - */ -void fsmenu_insert_entry (struct FSMenu* fsmenu, FSMenuCategory category, const char *path, int sorted, short save); +/** Inserts a new fsmenu entry with the given \a path. + * Duplicate entries are not added. + * \param sorted Should entry be inserted in sorted order? + */ +void fsmenu_insert_entry(struct FSMenu *fsmenu, FSMenuCategory category, const char *path, int sorted, short save); - /** Return whether the entry was created by the user and can be saved and deleted */ -short fsmenu_can_save (struct FSMenu* fsmenu, FSMenuCategory category, int index); +/** Return whether the entry was created by the user and can be saved and deleted */ +short fsmenu_can_save(struct FSMenu *fsmenu, FSMenuCategory category, int index); - /** Removes the fsmenu entry at the given \a index. */ -void fsmenu_remove_entry (struct FSMenu* fsmenu, FSMenuCategory category, int index); +/** Removes the fsmenu entry at the given \a index. */ +void fsmenu_remove_entry(struct FSMenu *fsmenu, FSMenuCategory category, int index); - /** saves the 'bookmarks' to the specified file */ -void fsmenu_write_file (struct FSMenu* fsmenu, const char *filename); +/** 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); +/** reads the 'bookmarks' from the specified file */ +void fsmenu_read_bookmarks(struct FSMenu *fsmenu, const char *filename); - /** adds system specific directories */ -void fsmenu_read_system (struct FSMenu* fsmenu, int read_bookmarks); +/** adds system specific directories */ +void fsmenu_read_system(struct FSMenu *fsmenu, int read_bookmarks); - /** Free's all the memory associated with the fsmenu */ -void fsmenu_free (struct FSMenu* fsmenu); +/** Free's all the memory associated with the fsmenu */ +void fsmenu_free(struct FSMenu *fsmenu); - /** Refresh system directory menu */ -void fsmenu_refresh_system_category (struct FSMenu* fsmenu); +/** Refresh system directory menu */ +void fsmenu_refresh_system_category(struct FSMenu *fsmenu); #endif diff --git a/source/blender/editors/space_file/space_file.c b/source/blender/editors/space_file/space_file.c index a90daa7e1e9..79979603f54 100644 --- a/source/blender/editors/space_file/space_file.c +++ b/source/blender/editors/space_file/space_file.c @@ -63,7 +63,7 @@ #include "UI_view2d.h" -#include "file_intern.h" // own include +#include "file_intern.h" // own include #include "fsmenu.h" #include "filelist.h" @@ -74,36 +74,36 @@ static SpaceLink *file_new(const bContext *UNUSED(C)) ARegion *ar; SpaceFile *sfile; - sfile= MEM_callocN(sizeof(SpaceFile), "initfile"); - sfile->spacetype= SPACE_FILE; + sfile = MEM_callocN(sizeof(SpaceFile), "initfile"); + sfile->spacetype = SPACE_FILE; /* header */ - ar= MEM_callocN(sizeof(ARegion), "header for file"); + ar = MEM_callocN(sizeof(ARegion), "header for file"); BLI_addtail(&sfile->regionbase, ar); - ar->regiontype= RGN_TYPE_HEADER; - ar->alignment= RGN_ALIGN_TOP; + ar->regiontype = RGN_TYPE_HEADER; + ar->alignment = RGN_ALIGN_TOP; /* channel list region */ - ar= MEM_callocN(sizeof(ARegion), "channel area for file"); + ar = MEM_callocN(sizeof(ARegion), "channel area for file"); BLI_addtail(&sfile->regionbase, ar); - ar->regiontype= RGN_TYPE_CHANNELS; - ar->alignment= RGN_ALIGN_LEFT; + ar->regiontype = RGN_TYPE_CHANNELS; + ar->alignment = RGN_ALIGN_LEFT; /* ui list region */ - ar= MEM_callocN(sizeof(ARegion), "ui area for file"); + ar = MEM_callocN(sizeof(ARegion), "ui area for file"); BLI_addtail(&sfile->regionbase, ar); - ar->regiontype= RGN_TYPE_UI; - ar->alignment= RGN_ALIGN_TOP; + ar->regiontype = RGN_TYPE_UI; + ar->alignment = RGN_ALIGN_TOP; /* main area */ - ar= MEM_callocN(sizeof(ARegion), "main area for file"); + ar = MEM_callocN(sizeof(ARegion), "main area for file"); BLI_addtail(&sfile->regionbase, ar); - ar->regiontype= RGN_TYPE_WINDOW; + ar->regiontype = RGN_TYPE_WINDOW; ar->v2d.scroll = (V2D_SCROLL_RIGHT | V2D_SCROLL_BOTTOM); - ar->v2d.align = (V2D_ALIGN_NO_NEG_X|V2D_ALIGN_NO_POS_Y); - ar->v2d.keepzoom = (V2D_LOCKZOOM_X|V2D_LOCKZOOM_Y|V2D_LIMITZOOM|V2D_KEEPASPECT); - ar->v2d.keeptot= V2D_KEEPTOT_STRICT; - ar->v2d.minzoom= ar->v2d.maxzoom= 1.0f; + ar->v2d.align = (V2D_ALIGN_NO_NEG_X | V2D_ALIGN_NO_POS_Y); + ar->v2d.keepzoom = (V2D_LOCKZOOM_X | V2D_LOCKZOOM_Y | V2D_LIMITZOOM | V2D_KEEPASPECT); + ar->v2d.keeptot = V2D_KEEPTOT_STRICT; + ar->v2d.minzoom = ar->v2d.maxzoom = 1.0f; return (SpaceLink *)sfile; } @@ -111,31 +111,31 @@ static SpaceLink *file_new(const bContext *UNUSED(C)) /* not spacelink itself */ static void file_free(SpaceLink *sl) { - SpaceFile *sfile= (SpaceFile *) sl; + SpaceFile *sfile = (SpaceFile *) sl; if (sfile->files) { // XXXXX would need to do thumbnails_stop here, but no context available filelist_freelib(sfile->files); filelist_free(sfile->files); MEM_freeN(sfile->files); - sfile->files= NULL; + sfile->files = NULL; } if (sfile->folders_prev) { folderlist_free(sfile->folders_prev); MEM_freeN(sfile->folders_prev); - sfile->folders_prev= NULL; + sfile->folders_prev = NULL; } if (sfile->folders_next) { folderlist_free(sfile->folders_next); MEM_freeN(sfile->folders_next); - sfile->folders_next= NULL; + sfile->folders_next = NULL; } if (sfile->params) { MEM_freeN(sfile->params); - sfile->params= NULL; + sfile->params = NULL; } if (sfile->layout) { @@ -148,27 +148,27 @@ static void file_free(SpaceLink *sl) /* spacetype; init callback, area size changes, screen set, etc */ static void file_init(struct wmWindowManager *UNUSED(wm), ScrArea *sa) { - SpaceFile *sfile= (SpaceFile*)sa->spacedata.first; + SpaceFile *sfile = (SpaceFile *)sa->spacedata.first; //printf("file_init\n"); /* refresh system directory list */ fsmenu_refresh_system_category(fsmenu_get()); - if (sfile->layout) sfile->layout->dirty= TRUE; + if (sfile->layout) sfile->layout->dirty = TRUE; } static SpaceLink *file_duplicate(SpaceLink *sl) { - SpaceFile *sfileo= (SpaceFile*)sl; - SpaceFile *sfilen= MEM_dupallocN(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 */ if (sfileo->params) { sfilen->files = filelist_new(sfileo->params->type); - sfilen->params= MEM_dupallocN(sfileo->params); + sfilen->params = MEM_dupallocN(sfileo->params); filelist_setdir(sfilen->files, sfilen->params->dir); } @@ -179,14 +179,14 @@ static SpaceLink *file_duplicate(SpaceLink *sl) sfilen->folders_next = folderlist_duplicate(sfileo->folders_next); if (sfileo->layout) { - sfilen->layout= MEM_dupallocN(sfileo->layout); + sfilen->layout = MEM_dupallocN(sfileo->layout); } return (SpaceLink *)sfilen; } static void file_refresh(const bContext *C, ScrArea *UNUSED(sa)) { - SpaceFile *sfile= CTX_wm_space_file(C); + SpaceFile *sfile = CTX_wm_space_file(C); FileSelectParams *params = ED_fileselect_get_params(sfile); if (!sfile->folders_prev) @@ -203,7 +203,7 @@ 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); @@ -212,7 +212,7 @@ static void file_refresh(const bContext *C, ScrArea *UNUSED(sa)) } } else { - if (params->sort!=FILE_SORT_NONE) { + if (params->sort != FILE_SORT_NONE) { thumbnails_stop(sfile->files, C); filelist_sort(sfile->files, params->sort); if (params->display == FILE_IMGDISPLAY) { @@ -237,7 +237,7 @@ static void file_refresh(const bContext *C, ScrArea *UNUSED(sa)) if (params->renamefile[0] != '\0') { int idx = filelist_find(sfile->files, params->renamefile); if (idx >= 0) { - struct direntry *file= filelist_file(sfile->files, idx); + struct direntry *file = filelist_file(sfile->files, idx); if (file) { file->selflag |= EDITING_FILE; } @@ -245,7 +245,7 @@ static void file_refresh(const bContext *C, ScrArea *UNUSED(sa)) BLI_strncpy(sfile->params->renameedit, sfile->params->renamefile, sizeof(sfile->params->renameedit)); params->renamefile[0] = '\0'; } - if (sfile->layout) sfile->layout->dirty= TRUE; + if (sfile->layout) sfile->layout->dirty = TRUE; } @@ -307,11 +307,11 @@ static void file_main_area_listener(ARegion *ar, wmNotifier *wmn) static void file_main_area_draw(const bContext *C, ARegion *ar) { /* draw entirely, view changes should be handled here */ - SpaceFile *sfile= CTX_wm_space_file(C); + SpaceFile *sfile = CTX_wm_space_file(C); FileSelectParams *params = ED_fileselect_get_params(sfile); - FileLayout *layout=NULL; + FileLayout *layout = NULL; - View2D *v2d= &ar->v2d; + View2D *v2d = &ar->v2d; View2DScrollers *scrollers; float col[3]; @@ -355,7 +355,7 @@ static void file_main_area_draw(const bContext *C, ARegion *ar) /* on first read, find active file */ if (params->active_file == -1) { - wmEvent *event= CTX_wm_window(C)->eventstate; + wmEvent *event = CTX_wm_window(C)->eventstate; file_hilight_set(sfile, ar, event->x, event->y); } @@ -365,7 +365,7 @@ static void file_main_area_draw(const bContext *C, ARegion *ar) 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); + 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); UI_view2d_scrollers_free(scrollers); @@ -553,58 +553,58 @@ static void file_ui_area_listener(ARegion *ar, wmNotifier *wmn) /* only called once, from space/spacetypes.c */ void ED_spacetype_file(void) { - SpaceType *st= MEM_callocN(sizeof(SpaceType), "spacetype file"); + SpaceType *st = MEM_callocN(sizeof(SpaceType), "spacetype file"); ARegionType *art; - st->spaceid= SPACE_FILE; + st->spaceid = SPACE_FILE; strncpy(st->name, "File", BKE_ST_MAXNAME); - st->new= file_new; - st->free= file_free; - st->init= file_init; - st->duplicate= file_duplicate; - st->refresh= file_refresh; - st->listener= file_listener; - st->operatortypes= file_operatortypes; - st->keymap= file_keymap; + st->new = file_new; + st->free = file_free; + st->init = file_init; + st->duplicate = file_duplicate; + st->refresh = file_refresh; + st->listener = file_listener; + st->operatortypes = file_operatortypes; + st->keymap = file_keymap; /* regions: main window */ - art= MEM_callocN(sizeof(ARegionType), "spacetype file region"); + art = MEM_callocN(sizeof(ARegionType), "spacetype file region"); art->regionid = RGN_TYPE_WINDOW; - art->init= file_main_area_init; - art->draw= file_main_area_draw; - art->listener= file_main_area_listener; - art->keymapflag= ED_KEYMAP_UI|ED_KEYMAP_VIEW2D; + art->init = file_main_area_init; + art->draw = file_main_area_draw; + art->listener = file_main_area_listener; + art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D; BLI_addhead(&st->regiontypes, art); /* regions: header */ - art= MEM_callocN(sizeof(ARegionType), "spacetype file region"); + art = MEM_callocN(sizeof(ARegionType), "spacetype file region"); art->regionid = RGN_TYPE_HEADER; - art->prefsizey= HEADERY; - art->keymapflag= ED_KEYMAP_UI|ED_KEYMAP_VIEW2D|ED_KEYMAP_HEADER; - art->init= file_header_area_init; - art->draw= file_header_area_draw; + art->prefsizey = HEADERY; + art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_HEADER; + art->init = file_header_area_init; + art->draw = file_header_area_draw; // art->listener= file_header_area_listener; BLI_addhead(&st->regiontypes, art); /* regions: ui */ - art= MEM_callocN(sizeof(ARegionType), "spacetype file region"); + art = MEM_callocN(sizeof(ARegionType), "spacetype file region"); art->regionid = RGN_TYPE_UI; - art->prefsizey= 60; - art->keymapflag= ED_KEYMAP_UI; - art->listener= file_ui_area_listener; - art->init= file_ui_area_init; - art->draw= file_ui_area_draw; + art->prefsizey = 60; + art->keymapflag = ED_KEYMAP_UI; + art->listener = file_ui_area_listener; + art->init = file_ui_area_init; + art->draw = file_ui_area_draw; BLI_addhead(&st->regiontypes, art); /* regions: channels (directories) */ - art= MEM_callocN(sizeof(ARegionType), "spacetype file region"); + art = MEM_callocN(sizeof(ARegionType), "spacetype file region"); art->regionid = RGN_TYPE_CHANNELS; - art->prefsizex= 240; - art->keymapflag= ED_KEYMAP_UI; - art->listener= file_channel_area_listener; - art->init= file_channel_area_init; - art->draw= file_channel_area_draw; + art->prefsizex = 240; + art->keymapflag = ED_KEYMAP_UI; + art->listener = file_channel_area_listener; + art->init = file_channel_area_init; + art->draw = file_channel_area_draw; BLI_addhead(&st->regiontypes, art); file_panels_register(art); -- cgit v1.2.3