Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/editors/space_file')
-rw-r--r--source/blender/editors/space_file/file_draw.c6
-rw-r--r--source/blender/editors/space_file/file_ops.c84
-rw-r--r--source/blender/editors/space_file/filelist.c111
-rw-r--r--source/blender/editors/space_file/filesel.c84
-rw-r--r--source/blender/editors/space_file/fsmenu.c21
-rw-r--r--source/blender/editors/space_file/space_file.c12
6 files changed, 212 insertions, 106 deletions
diff --git a/source/blender/editors/space_file/file_draw.c b/source/blender/editors/space_file/file_draw.c
index 3245cbf2a29..bb8680682d2 100644
--- a/source/blender/editors/space_file/file_draw.c
+++ b/source/blender/editors/space_file/file_draw.c
@@ -193,8 +193,9 @@ void file_draw_buttons(const bContext *C, ARegion *ar)
/* TODO, directory editing is non-functional while a library is loaded
* until this is properly supported just disable it. */
- if (sfile->files && filelist_lib(sfile->files))
+ if (sfile->files && filelist_lib(sfile->files)) {
UI_but_flag_enable(but, UI_BUT_DISABLED);
+ }
if ((params->flag & FILE_DIRSEL_ONLY) == 0) {
but = uiDefBut(
@@ -660,8 +661,9 @@ 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)
+ if (offset < 0) {
offset = 0;
+ }
numfiles_layout = ED_fileselect_layout_numfiles(layout, ar);
diff --git a/source/blender/editors/space_file/file_ops.c b/source/blender/editors/space_file/file_ops.c
index 2f1671aefa7..7d3a042d75a 100644
--- a/source/blender/editors/space_file/file_ops.c
+++ b/source/blender/editors/space_file/file_ops.c
@@ -119,8 +119,9 @@ static void clamp_to_filelist(int numfiles, FileSelection *sel)
}
/* fix if last file invalid */
- if ((sel->first > 0) && (sel->last < 0))
+ if ((sel->first > 0) && (sel->last < 0)) {
sel->last = numfiles - 1;
+ }
/* clamp */
if ((sel->first >= numfiles)) {
@@ -148,8 +149,9 @@ static FileSelection file_selection_get(bContext *C, const rcti *rect, bool fill
int f;
/* Try to find a smaller-index selected item. */
for (f = sel.last; f >= 0; f--) {
- if (filelist_entry_select_index_get(sfile->files, f, CHECK_ALL))
+ if (filelist_entry_select_index_get(sfile->files, f, CHECK_ALL)) {
break;
+ }
}
if (f >= 0) {
sel.first = f + 1;
@@ -157,8 +159,9 @@ static FileSelection file_selection_get(bContext *C, const rcti *rect, bool fill
/* If none found, try to find a higher-index selected item. */
else {
for (f = sel.first; f < numfiles; f++) {
- if (filelist_entry_select_index_get(sfile->files, f, CHECK_ALL))
+ if (filelist_entry_select_index_get(sfile->files, f, CHECK_ALL)) {
break;
+ }
}
if (f < numfiles) {
sel.last = f - 1;
@@ -298,8 +301,9 @@ static FileSelect file_select(
sfile->files, &sel, select, FILE_SEL_SELECTED, check_type);
/* Don't act on multiple selected files */
- if (sel.first != sel.last)
+ if (sel.first != sel.last) {
select = 0;
+ }
/* Do we have a valid selection and are we actually selecting */
if ((sel.last >= 0) && (select != FILE_SEL_REMOVE)) {
@@ -482,14 +486,16 @@ static int file_select_invoke(bContext *C, wmOperator *op, const wmEvent *event)
const bool fill = RNA_boolean_get(op->ptr, "fill");
const bool do_diropen = RNA_boolean_get(op->ptr, "open");
- if (ar->regiontype != RGN_TYPE_WINDOW)
+ if (ar->regiontype != RGN_TYPE_WINDOW) {
return OPERATOR_CANCELLED;
+ }
rect.xmin = rect.xmax = event->mval[0];
rect.ymin = rect.ymax = event->mval[1];
- if (!BLI_rcti_isect_pt(&ar->v2d.mask, rect.xmin, rect.ymin))
+ if (!BLI_rcti_isect_pt(&ar->v2d.mask, rect.xmin, rect.ymin)) {
return OPERATOR_CANCELLED;
+ }
if (sfile && sfile->params) {
int idx = sfile->params->highlight_file;
@@ -512,10 +518,12 @@ static int file_select_invoke(bContext *C, wmOperator *op, const wmEvent *event)
sfile->files, 0, FILE_SEL_REMOVE, FILE_SEL_SELECTED, CHECK_ALL);
}
- if (FILE_SELECT_DIR == ret)
+ if (FILE_SELECT_DIR == ret) {
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_LIST, NULL);
- else if (FILE_SELECT_FILE == ret)
+ }
+ else if (FILE_SELECT_FILE == ret) {
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_PARAMS, NULL);
+ }
WM_event_add_mousemove(C); /* for directory changes */
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_PARAMS, NULL);
@@ -1149,8 +1157,9 @@ int file_highlight_set(SpaceFile *sfile, ARegion *ar, int mx, int my)
FileSelectParams *params;
int numfiles, origfile;
- if (sfile == NULL || sfile->files == NULL)
+ if (sfile == NULL || sfile->files == NULL) {
return 0;
+ }
numfiles = filelist_files_ensure(sfile->files);
params = ED_fileselect_get_params(sfile);
@@ -1169,13 +1178,16 @@ int file_highlight_set(SpaceFile *sfile, ARegion *ar, int mx, int my)
highlight_file = ED_fileselect_layout_offset(
sfile->layout, (int)(v2d->tot.xmin + fx), (int)(v2d->tot.ymax - fy));
- if ((highlight_file >= 0) && (highlight_file < numfiles))
+ if ((highlight_file >= 0) && (highlight_file < numfiles)) {
params->highlight_file = highlight_file;
- else
+ }
+ else {
params->highlight_file = -1;
+ }
}
- else
+ else {
params->highlight_file = -1;
+ }
return (params->highlight_file != origfile);
}
@@ -1185,8 +1197,9 @@ static int file_highlight_invoke(bContext *C, wmOperator *UNUSED(op), const wmEv
ARegion *ar = CTX_wm_region(C);
SpaceFile *sfile = CTX_wm_space_file(C);
- if (!file_highlight_set(sfile, ar, event->x, event->y))
+ if (!file_highlight_set(sfile, ar, event->x, event->y)) {
return OPERATOR_PASS_THROUGH;
+ }
ED_area_tag_redraw(CTX_wm_area(C));
@@ -1223,8 +1236,9 @@ static bool file_operator_poll(bContext *C)
bool poll = ED_operator_file_active(C);
SpaceFile *sfile = CTX_wm_space_file(C);
- if (!sfile || !sfile->op)
+ if (!sfile || !sfile->op) {
poll = 0;
+ }
return poll;
}
@@ -1459,8 +1473,9 @@ int file_exec(bContext *C, wmOperator *exec_op)
break;
}
}
- if (active == 0)
+ if (active == 0) {
return OPERATOR_CANCELLED;
+ }
}
sfile->op = NULL;
@@ -1575,8 +1590,9 @@ int file_previous_exec(bContext *C, wmOperator *UNUSED(unused))
SpaceFile *sfile = CTX_wm_space_file(C);
if (sfile->params) {
- if (!sfile->folders_next)
+ if (!sfile->folders_next) {
sfile->folders_next = folderlist_new();
+ }
folderlist_pushdir(sfile->folders_next, sfile->params->dir);
folderlist_popdir(sfile->folders_prev, sfile->params->dir);
@@ -1605,8 +1621,9 @@ int file_next_exec(bContext *C, wmOperator *UNUSED(unused))
{
SpaceFile *sfile = CTX_wm_space_file(C);
if (sfile->params) {
- if (!sfile->folders_next)
+ if (!sfile->folders_next) {
sfile->folders_next = folderlist_new();
+ }
folderlist_pushdir(sfile->folders_prev, sfile->params->dir);
folderlist_popdir(sfile->folders_next, sfile->params->dir);
@@ -1633,8 +1650,9 @@ static int file_smoothscroll_invoke(bContext *C, wmOperator *UNUSED(op), const w
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_files_ensure(sfile->files);
@@ -1683,13 +1701,15 @@ static int file_smoothscroll_invoke(bContext *C, wmOperator *UNUSED(op), const w
if (sfile->scroll_offset == 0) {
if (sfile->layout->flag & FILE_LAYOUT_HOR) {
sfile->scroll_offset = (edit_idx / sfile->layout->rows) * sfile->layout->rows;
- if (sfile->scroll_offset <= offset)
+ if (sfile->scroll_offset <= offset) {
sfile->scroll_offset -= sfile->layout->rows;
+ }
}
else {
sfile->scroll_offset = (edit_idx / sfile->layout->columns) * sfile->layout->columns;
- if (sfile->scroll_offset <= offset)
+ if (sfile->scroll_offset <= offset) {
sfile->scroll_offset -= sfile->layout->columns;
+ }
}
}
@@ -2030,8 +2050,9 @@ void file_directory_enter_handle(bContext *C, void *UNUSED(arg_unused), void *UN
#if defined(WIN32)
else if (!can_create_dir(sfile->params->dir)) {
const char *lastdir = folderlist_peeklastdir(sfile->folders_prev);
- if (lastdir)
+ if (lastdir) {
BLI_strncpy(sfile->params->dir, lastdir, sizeof(sfile->params->dir));
+ }
}
#endif
else {
@@ -2050,8 +2071,9 @@ void file_directory_enter_handle(bContext *C, void *UNUSED(arg_unused), void *UN
RNA_string_set(&ptr, "directory", sfile->params->dir);
RNA_boolean_set(&ptr, "open", true);
- if (lastdir)
+ if (lastdir) {
BLI_strncpy(sfile->params->dir, lastdir, sizeof(sfile->params->dir));
+ }
WM_operator_name_call_ptr(C, ot, WM_OP_INVOKE_DEFAULT, &ptr);
WM_operator_properties_free(&ptr);
@@ -2153,15 +2175,17 @@ ARegion *file_tools_region(ScrArea *sa)
{
ARegion *ar, *arnew;
- if ((ar = BKE_area_find_region_type(sa, RGN_TYPE_TOOLS)) != NULL)
+ if ((ar = BKE_area_find_region_type(sa, RGN_TYPE_TOOLS)) != NULL) {
return ar;
+ }
/* add subdiv level; after header */
ar = BKE_area_find_region_type(sa, RGN_TYPE_HEADER);
/* is error! */
- if (ar == NULL)
+ if (ar == NULL) {
return NULL;
+ }
arnew = MEM_callocN(sizeof(ARegion), "tools for file");
BLI_insertlinkafter(&sa->regionbase, ar, arnew);
@@ -2181,8 +2205,9 @@ static int file_bookmark_toggle_exec(bContext *C, wmOperator *UNUSED(unused))
ScrArea *sa = CTX_wm_area(C);
ARegion *ar = file_tools_region(sa);
- if (ar)
+ if (ar) {
ED_region_toggle_hidden(C, ar);
+ }
return OPERATOR_FINISHED;
}
@@ -2224,8 +2249,9 @@ static void filenum_newname(char *name, size_t name_size, int add)
}
pic += add;
- if (pic < 0)
+ if (pic < 0) {
pic = 0;
+ }
BLI_stringenc(name_temp, head, tail, digits, pic);
BLI_strncpy(name, name_temp, name_size);
}
@@ -2340,8 +2366,9 @@ static bool file_delete_poll(bContext *C)
int i;
int num_selected = 0;
- if (filelist_islibrary(sfile->files, dir, NULL))
+ if (filelist_islibrary(sfile->files, dir, NULL)) {
poll = 0;
+ }
for (i = 0; i < numfiles; i++) {
if (filelist_entry_select_index_get(sfile->files, i, CHECK_FILES)) {
num_selected++;
@@ -2351,8 +2378,9 @@ static bool file_delete_poll(bContext *C)
poll = 0;
}
}
- else
+ else {
poll = 0;
+ }
return poll;
}
diff --git a/source/blender/editors/space_file/filelist.c b/source/blender/editors/space_file/filelist.c
index a6a9f3681fd..564dd0ec81d 100644
--- a/source/blender/editors/space_file/filelist.c
+++ b/source/blender/editors/space_file/filelist.c
@@ -139,8 +139,9 @@ const char *folderlist_peeklastdir(ListBase *folderlist)
{
struct FolderList *folder;
- if (!folderlist->last)
+ if (!folderlist->last) {
return NULL;
+ }
folder = folderlist->last;
return folder->foldername;
@@ -151,14 +152,16 @@ int folderlist_clear_next(struct SpaceFile *sfile)
struct FolderList *folder;
/* if there is no folder_next there is nothing we can clear */
- if (!sfile->folders_next)
+ if (!sfile->folders_next) {
return 0;
+ }
/* 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 */
return 1;
@@ -169,8 +172,9 @@ 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);
}
}
@@ -400,14 +404,18 @@ static int compare_direntry_generic(const FileListInternEntry *entry1,
}
/* make sure "." and ".." are always first */
- if (FILENAME_IS_CURRENT(entry1->relpath))
+ if (FILENAME_IS_CURRENT(entry1->relpath)) {
return -1;
- if (FILENAME_IS_CURRENT(entry2->relpath))
+ }
+ if (FILENAME_IS_CURRENT(entry2->relpath)) {
return 1;
- if (FILENAME_IS_PARENT(entry1->relpath))
+ }
+ if (FILENAME_IS_PARENT(entry1->relpath)) {
return -1;
- if (FILENAME_IS_PARENT(entry2->relpath))
+ }
+ if (FILENAME_IS_PARENT(entry2->relpath)) {
return 1;
+ }
return 0;
}
@@ -443,10 +451,12 @@ static int compare_date(void *UNUSED(user_data), const void *a1, const void *a2)
time1 = (int64_t)entry1->st.st_mtime;
time2 = (int64_t)entry2->st.st_mtime;
- if (time1 < time2)
+ if (time1 < time2) {
return 1;
- if (time1 > time2)
+ }
+ if (time1 > time2) {
return -1;
+ }
name1 = entry1->name;
name2 = entry2->name;
@@ -468,10 +478,12 @@ static int compare_size(void *UNUSED(user_data), const void *a1, const void *a2)
size1 = entry1->st.st_size;
size2 = entry2->st.st_size;
- if (size1 < size2)
+ if (size1 < size2) {
return 1;
- if (size1 > size2)
+ }
+ if (size1 > size2) {
return -1;
+ }
name1 = entry1->name;
name2 = entry2->name;
@@ -490,31 +502,41 @@ static int compare_extension(void *UNUSED(user_data), const void *a1, const void
return ret;
}
- if ((entry1->typeflag & FILE_TYPE_BLENDERLIB) && !(entry2->typeflag & FILE_TYPE_BLENDERLIB))
+ if ((entry1->typeflag & FILE_TYPE_BLENDERLIB) && !(entry2->typeflag & FILE_TYPE_BLENDERLIB)) {
return -1;
- if (!(entry1->typeflag & FILE_TYPE_BLENDERLIB) && (entry2->typeflag & FILE_TYPE_BLENDERLIB))
+ }
+ if (!(entry1->typeflag & FILE_TYPE_BLENDERLIB) && (entry2->typeflag & FILE_TYPE_BLENDERLIB)) {
return 1;
+ }
if ((entry1->typeflag & FILE_TYPE_BLENDERLIB) && (entry2->typeflag & FILE_TYPE_BLENDERLIB)) {
- if ((entry1->typeflag & FILE_TYPE_DIR) && !(entry2->typeflag & FILE_TYPE_DIR))
+ if ((entry1->typeflag & FILE_TYPE_DIR) && !(entry2->typeflag & FILE_TYPE_DIR)) {
return 1;
- if (!(entry1->typeflag & FILE_TYPE_DIR) && (entry2->typeflag & FILE_TYPE_DIR))
+ }
+ if (!(entry1->typeflag & FILE_TYPE_DIR) && (entry2->typeflag & FILE_TYPE_DIR)) {
return -1;
- if (entry1->blentype < entry2->blentype)
+ }
+ if (entry1->blentype < entry2->blentype) {
return -1;
- if (entry1->blentype > entry2->blentype)
+ }
+ if (entry1->blentype > entry2->blentype) {
return 1;
+ }
}
else {
const char *sufix1, *sufix2;
- if (!(sufix1 = strstr(entry1->relpath, ".blend.gz")))
+ if (!(sufix1 = strstr(entry1->relpath, ".blend.gz"))) {
sufix1 = strrchr(entry1->relpath, '.');
- if (!(sufix2 = strstr(entry2->relpath, ".blend.gz")))
+ }
+ if (!(sufix2 = strstr(entry2->relpath, ".blend.gz"))) {
sufix2 = strrchr(entry2->relpath, '.');
- if (!sufix1)
+ }
+ if (!sufix1) {
sufix1 = "";
- if (!sufix2)
+ }
+ if (!sufix2) {
sufix2 = "";
+ }
if ((ret = BLI_strcasecmp(sufix1, sufix2))) {
return ret;
@@ -954,28 +976,39 @@ static int filelist_geticon_ex(const int typeflag,
}
}
- if (typeflag & FILE_TYPE_BLENDER)
+ if (typeflag & FILE_TYPE_BLENDER) {
return ICON_FILE_BLEND;
- else if (typeflag & FILE_TYPE_BLENDER_BACKUP)
+ }
+ else if (typeflag & FILE_TYPE_BLENDER_BACKUP) {
return ICON_FILE_BACKUP;
- else if (typeflag & FILE_TYPE_IMAGE)
+ }
+ else if (typeflag & FILE_TYPE_IMAGE) {
return ICON_FILE_IMAGE;
- else if (typeflag & FILE_TYPE_MOVIE)
+ }
+ else if (typeflag & FILE_TYPE_MOVIE) {
return ICON_FILE_MOVIE;
- else if (typeflag & FILE_TYPE_PYSCRIPT)
+ }
+ else if (typeflag & FILE_TYPE_PYSCRIPT) {
return ICON_FILE_SCRIPT;
- else if (typeflag & FILE_TYPE_SOUND)
+ }
+ else if (typeflag & FILE_TYPE_SOUND) {
return ICON_FILE_SOUND;
- else if (typeflag & FILE_TYPE_FTFONT)
+ }
+ else if (typeflag & FILE_TYPE_FTFONT) {
return ICON_FILE_FONT;
- else if (typeflag & FILE_TYPE_BTX)
+ }
+ else if (typeflag & FILE_TYPE_BTX) {
return ICON_FILE_BLANK;
- else if (typeflag & FILE_TYPE_COLLADA)
+ }
+ else if (typeflag & FILE_TYPE_COLLADA) {
return ICON_FILE_BLANK;
- else if (typeflag & FILE_TYPE_ALEMBIC)
+ }
+ else if (typeflag & FILE_TYPE_ALEMBIC) {
return ICON_FILE_BLANK;
- else if (typeflag & FILE_TYPE_TEXT)
+ }
+ else if (typeflag & FILE_TYPE_TEXT) {
return ICON_FILE_TEXT;
+ }
else if (typeflag & FILE_TYPE_BLENDERLIB) {
const int ret = UI_idcode_icon_get(blentype);
if (ret != ICON_NONE) {
@@ -1424,8 +1457,9 @@ void filelist_free(struct FileList *filelist)
void filelist_freelib(struct FileList *filelist)
{
- if (filelist->libfiledata)
+ if (filelist->libfiledata) {
BLO_blendhandle_close(filelist->libfiledata);
+ }
filelist->libfiledata = NULL;
}
@@ -2044,14 +2078,16 @@ static bool file_is_blend_backup(const char *str)
else {
const char *loc;
- if (a > b + 1)
+ if (a > b + 1) {
b++;
+ }
/* allow .blend1 .blend2 .blend32 */
loc = BLI_strcasestr(str + a - b, ".blend");
- if (loc)
+ if (loc) {
retval = 1;
+ }
}
return (retval);
@@ -2274,8 +2310,9 @@ static int groupname_to_code(const char *group)
BLI_strncpy(buf, group, sizeof(buf));
lslash = (char *)BLI_last_slash(buf);
- if (lslash)
+ if (lslash) {
lslash[0] = '\0';
+ }
return buf[0] ? BKE_idcode_from_name(buf) : 0;
}
diff --git a/source/blender/editors/space_file/filesel.c b/source/blender/editors/space_file/filesel.c
index 9261c954bb6..e5f19f0164d 100644
--- a/source/blender/editors/space_file/filesel.c
+++ b/source/blender/editors/space_file/filesel.c
@@ -161,32 +161,45 @@ short ED_fileselect_set_params(SpaceFile *sfile)
}
params->filter = 0;
- if ((prop = RNA_struct_find_property(op->ptr, "filter_blender")))
+ if ((prop = RNA_struct_find_property(op->ptr, "filter_blender"))) {
params->filter |= RNA_property_boolean_get(op->ptr, prop) ? FILE_TYPE_BLENDER : 0;
- if ((prop = RNA_struct_find_property(op->ptr, "filter_blenlib")))
+ }
+ if ((prop = RNA_struct_find_property(op->ptr, "filter_blenlib"))) {
params->filter |= RNA_property_boolean_get(op->ptr, prop) ? FILE_TYPE_BLENDERLIB : 0;
- if ((prop = RNA_struct_find_property(op->ptr, "filter_backup")))
+ }
+ if ((prop = RNA_struct_find_property(op->ptr, "filter_backup"))) {
params->filter |= RNA_property_boolean_get(op->ptr, prop) ? FILE_TYPE_BLENDER_BACKUP : 0;
- if ((prop = RNA_struct_find_property(op->ptr, "filter_image")))
+ }
+ if ((prop = RNA_struct_find_property(op->ptr, "filter_image"))) {
params->filter |= RNA_property_boolean_get(op->ptr, prop) ? FILE_TYPE_IMAGE : 0;
- if ((prop = RNA_struct_find_property(op->ptr, "filter_movie")))
+ }
+ if ((prop = RNA_struct_find_property(op->ptr, "filter_movie"))) {
params->filter |= RNA_property_boolean_get(op->ptr, prop) ? FILE_TYPE_MOVIE : 0;
- if ((prop = RNA_struct_find_property(op->ptr, "filter_python")))
+ }
+ if ((prop = RNA_struct_find_property(op->ptr, "filter_python"))) {
params->filter |= RNA_property_boolean_get(op->ptr, prop) ? FILE_TYPE_PYSCRIPT : 0;
- if ((prop = RNA_struct_find_property(op->ptr, "filter_font")))
+ }
+ if ((prop = RNA_struct_find_property(op->ptr, "filter_font"))) {
params->filter |= RNA_property_boolean_get(op->ptr, prop) ? FILE_TYPE_FTFONT : 0;
- if ((prop = RNA_struct_find_property(op->ptr, "filter_sound")))
+ }
+ if ((prop = RNA_struct_find_property(op->ptr, "filter_sound"))) {
params->filter |= RNA_property_boolean_get(op->ptr, prop) ? FILE_TYPE_SOUND : 0;
- if ((prop = RNA_struct_find_property(op->ptr, "filter_text")))
+ }
+ if ((prop = RNA_struct_find_property(op->ptr, "filter_text"))) {
params->filter |= RNA_property_boolean_get(op->ptr, prop) ? FILE_TYPE_TEXT : 0;
- if ((prop = RNA_struct_find_property(op->ptr, "filter_folder")))
+ }
+ if ((prop = RNA_struct_find_property(op->ptr, "filter_folder"))) {
params->filter |= RNA_property_boolean_get(op->ptr, prop) ? FILE_TYPE_FOLDER : 0;
- if ((prop = RNA_struct_find_property(op->ptr, "filter_btx")))
+ }
+ if ((prop = RNA_struct_find_property(op->ptr, "filter_btx"))) {
params->filter |= RNA_property_boolean_get(op->ptr, prop) ? FILE_TYPE_BTX : 0;
- if ((prop = RNA_struct_find_property(op->ptr, "filter_collada")))
+ }
+ if ((prop = RNA_struct_find_property(op->ptr, "filter_collada"))) {
params->filter |= RNA_property_boolean_get(op->ptr, prop) ? FILE_TYPE_COLLADA : 0;
- if ((prop = RNA_struct_find_property(op->ptr, "filter_alembic")))
+ }
+ if ((prop = RNA_struct_find_property(op->ptr, "filter_alembic"))) {
params->filter |= RNA_property_boolean_get(op->ptr, prop) ? FILE_TYPE_ALEMBIC : 0;
+ }
if ((prop = RNA_struct_find_property(op->ptr, "filter_glob"))) {
/* Protection against pyscripts not setting proper size limit... */
char *tmp = RNA_property_string_get_alloc(
@@ -290,8 +303,9 @@ short ED_fileselect_set_params(SpaceFile *sfile)
params->active_file = -1;
/* initialize the list with previous folders */
- if (!sfile->folders_prev)
+ if (!sfile->folders_prev) {
sfile->folders_prev = folderlist_new();
+ }
if (!sfile->params->dir[0]) {
if (blendfile_path[0] != '\0') {
@@ -375,8 +389,9 @@ FileSelection ED_fileselect_layout_offset_rect(FileLayout *layout, const rcti *r
FileSelection sel;
sel.first = sel.last = -1;
- if (layout == NULL)
+ 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);
@@ -395,19 +410,23 @@ FileSelection ED_fileselect_layout_offset_rect(FileLayout *layout, const rcti *r
sel.first = -1;
}
else {
- if (layout->flag & FILE_LAYOUT_HOR)
+ if (layout->flag & FILE_LAYOUT_HOR) {
sel.first = layout->rows * colmin + rowmin;
- else
+ }
+ else {
sel.first = colmin + layout->columns * rowmin;
+ }
}
if ((colmax > layout->columns - 1) || (rowmax > layout->rows - 1)) {
sel.last = -1;
}
else {
- if (layout->flag & FILE_LAYOUT_HOR)
+ if (layout->flag & FILE_LAYOUT_HOR) {
sel.last = layout->rows * colmax + rowmax;
- else
+ }
+ else {
sel.last = colmax + layout->columns * rowmax;
+ }
}
return sel;
@@ -418,21 +437,26 @@ int ED_fileselect_layout_offset(FileLayout *layout, int x, int y)
int offsetx, offsety;
int active_file;
- if (layout == NULL)
+ if (layout == NULL) {
return -1;
+ }
offsetx = (x) / (layout->tile_w + 2 * layout->tile_border_x);
offsety = (y) / (layout->tile_h + 2 * layout->tile_border_y);
- if (offsetx > layout->columns - 1)
+ if (offsetx > layout->columns - 1) {
return -1;
- if (offsety > layout->rows - 1)
+ }
+ if (offsety > layout->rows - 1) {
return -1;
+ }
- if (layout->flag & FILE_LAYOUT_HOR)
+ if (layout->flag & FILE_LAYOUT_HOR) {
active_file = layout->rows * offsetx + offsety;
- else
+ }
+ else {
active_file = offsetx + layout->columns * offsety;
+ }
return active_file;
}
@@ -536,8 +560,9 @@ void ED_fileselect_init_layout(struct SpaceFile *sfile, ARegion *ar)
layout->tile_h = layout->prv_h + 2 * layout->prv_border_y + textheight;
layout->width = (int)(BLI_rctf_size_x(&v2d->cur) - 2 * layout->tile_border_x);
layout->columns = layout->width / (layout->tile_w + 2 * layout->tile_border_x);
- if (layout->columns > 0)
+ if (layout->columns > 0) {
layout->rows = numfiles / layout->columns + 1; // XXX dirty, modulo is zero
+ }
else {
layout->columns = 1;
layout->rows = numfiles + 1; // XXX dirty, modulo is zero
@@ -577,8 +602,9 @@ void ED_fileselect_init_layout(struct SpaceFile *sfile, ARegion *ar)
(int)layout->column_widths[COLUMN_SIZE] + column_space;
}
layout->tile_w = maxlen;
- if (layout->rows > 0)
+ if (layout->rows > 0) {
layout->columns = numfiles / layout->rows + 1; // XXX dirty, modulo is zero
+ }
else {
layout->rows = 1;
layout->columns = numfiles + 1; // XXX dirty, modulo is zero
@@ -619,8 +645,9 @@ void ED_file_change_dir(bContext *C)
}
filelist_setdir(sfile->files, sfile->params->dir);
- if (folderlist_clear_next(sfile))
+ if (folderlist_clear_next(sfile)) {
folderlist_free(sfile->folders_next);
+ }
folderlist_pushdir(sfile->folders_prev, sfile->params->dir);
@@ -739,8 +766,9 @@ void ED_fileselect_clear(wmWindowManager *wm, ScrArea *sa, SpaceFile *sfile)
void ED_fileselect_exit(wmWindowManager *wm, ScrArea *sa, SpaceFile *sfile)
{
- if (!sfile)
+ if (!sfile) {
return;
+ }
if (sfile->op) {
WM_event_fileselect_event(wm, sfile->op, EVT_FILESELECT_EXTERNAL_CANCEL);
sfile->op = NULL;
diff --git a/source/blender/editors/space_file/fsmenu.c b/source/blender/editors/space_file/fsmenu.c
index f1030a93dc2..982c663cd18 100644
--- a/source/blender/editors/space_file/fsmenu.c
+++ b/source/blender/editors/space_file/fsmenu.c
@@ -351,8 +351,9 @@ void fsmenu_remove_entry(struct FSMenu *fsmenu, FSMenuCategory category, int idx
fsm_head = ED_fsmenu_get_category(fsmenu, category);
- for (fsm_iter = fsm_head; fsm_iter && idx; fsm_prev = fsm_iter, fsm_iter = fsm_iter->next)
+ for (fsm_iter = fsm_head; fsm_iter && idx; fsm_prev = fsm_iter, fsm_iter = fsm_iter->next) {
idx--;
+ }
if (fsm_iter) {
/* you should only be able to remove entries that were
@@ -382,8 +383,9 @@ void fsmenu_write_file(struct FSMenu *fsmenu, const char *filename)
int nwritten = 0;
FILE *fp = BLI_fopen(filename, "w");
- if (!fp)
+ if (!fp) {
return;
+ }
fprintf(fp, "[Bookmarks]\n");
for (fsm_iter = ED_fsmenu_get_category(fsmenu, FS_CATEGORY_BOOKMARKS); fsm_iter;
@@ -419,8 +421,9 @@ void fsmenu_read_bookmarks(struct FSMenu *fsmenu, const char *filename)
FILE *fp;
fp = BLI_fopen(filename, "r");
- if (!fp)
+ if (!fp) {
return;
+ }
name[0] = '\0';
@@ -533,8 +536,9 @@ void fsmenu_read_system(struct FSMenu *fsmenu, int read_bookmarks)
char defPath[FILE_MAX];
result = CFURLEnumeratorGetNextURL(volEnum, &cfURL, NULL);
- if (result != kCFURLEnumeratorSuccess)
+ if (result != kCFURLEnumeratorSuccess) {
continue;
+ }
CFURLGetFileSystemRepresentation(cfURL, false, (UInt8 *)defPath, FILE_MAX);
@@ -564,14 +568,16 @@ void fsmenu_read_system(struct FSMenu *fsmenu, int read_bookmarks)
kLSSharedFileListDoNotMountVolumes,
&cfURL,
NULL);
- if (err != noErr || !cfURL)
+ if (err != noErr || !cfURL) {
continue;
+ }
CFStringRef pathString = CFURLCopyFileSystemPath(cfURL, kCFURLPOSIXPathStyle);
if (pathString == NULL ||
- !CFStringGetCString(pathString, line, sizeof(line), kCFStringEncodingUTF8))
+ !CFStringGetCString(pathString, line, sizeof(line), kCFStringEncodingUTF8)) {
continue;
+ }
/* Add end slash for consistency with other platforms */
BLI_add_slash(line);
@@ -677,8 +683,9 @@ void fsmenu_read_system(struct FSMenu *fsmenu, int read_bookmarks)
# endif
/* fallback */
- if (!found)
+ if (!found) {
fsmenu_insert_entry(fsmenu, FS_CATEGORY_SYSTEM, "/", NULL, FS_INSERT_SORTED);
+ }
}
}
# endif
diff --git a/source/blender/editors/space_file/space_file.c b/source/blender/editors/space_file/space_file.c
index 53bcf7068f4..e0d370cdde2 100644
--- a/source/blender/editors/space_file/space_file.c
+++ b/source/blender/editors/space_file/space_file.c
@@ -155,8 +155,9 @@ static void file_init(wmWindowManager *UNUSED(wm), ScrArea *sa)
*/
fsmenu_refresh_bookmarks_status(ED_fsmenu_get());
- if (sfile->layout)
+ if (sfile->layout) {
sfile->layout->dirty = true;
+ }
}
static void file_exit(wmWindowManager *wm, ScrArea *sa)
@@ -188,11 +189,13 @@ static SpaceLink *file_duplicate(SpaceLink *sl)
filelist_setdir(sfilen->files, sfilen->params->dir);
}
- if (sfileo->folders_prev)
+ if (sfileo->folders_prev) {
sfilen->folders_prev = folderlist_duplicate(sfileo->folders_prev);
+ }
- if (sfileo->folders_next)
+ if (sfileo->folders_next) {
sfilen->folders_next = folderlist_duplicate(sfileo->folders_next);
+ }
if (sfileo->layout) {
sfilen->layout = MEM_dupallocN(sfileo->layout);
@@ -389,8 +392,9 @@ static void file_main_region_draw(const bContext *C, ARegion *ar)
float col[3];
/* Needed, because filelist is not initialized on loading */
- if (!sfile->files || filelist_empty(sfile->files))
+ if (!sfile->files || filelist_empty(sfile->files)) {
file_refresh(C, NULL);
+ }
/* clear and setup matrix */
UI_GetThemeColor3fv(TH_BACK, col);