style cleanup: comments
[blender.git] / source / blender / editors / space_file / filelist.c
index a23cb86..9d5f7fd 100644 (file)
@@ -383,10 +383,13 @@ void filelist_init_icons(void)
        short x, y, k;
        ImBuf *bbuf;
        ImBuf *ibuf;
+
+       BLI_assert(G.background == FALSE);
+
 #ifdef WITH_HEADLESS
        bbuf = NULL;
 #else
-       bbuf = IMB_ibImageFromMemory((unsigned char *)datatoc_prvicons, datatoc_prvicons_size, IB_rect, "<splash>");
+       bbuf = IMB_ibImageFromMemory((unsigned char *)datatoc_prvicons_png, datatoc_prvicons_png_size, IB_rect, NULL, "<splash>");
 #endif
        if (bbuf) {
                for (y = 0; y < SPECIAL_IMG_ROWS; y++) {
@@ -408,13 +411,16 @@ void filelist_init_icons(void)
 void filelist_free_icons(void)
 {
        int i;
+
+       BLI_assert(G.background == FALSE);
+
        for (i = 0; i < SPECIAL_IMG_MAX; ++i) {
                IMB_freeImBuf(gSpecialFileImages[i]);
                gSpecialFileImages[i] = NULL;
        }
 }
 
-//-----------------FOLDERLIST (previous/next) --------------//
+/* -----------------FOLDERLIST (previous/next) -------------- */
 ListBase *folderlist_new(void)
 {
        ListBase *p = MEM_callocN(sizeof(ListBase), "folderlist");
@@ -514,7 +520,7 @@ 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------------------------//
+/* ------------------FILELIST------------------------ */
 FileList *filelist_new(short type)
 {
        FileList *p = MEM_callocN(sizeof(FileList), "filelist");
@@ -615,7 +621,10 @@ short filelist_changed(struct FileList *filelist)
 ImBuf *filelist_getimage(struct FileList *filelist, int index)
 {
        ImBuf *ibuf = NULL;
-       int fidx = 0;   
+       int fidx = 0;
+
+       BLI_assert(G.background == FALSE);
+
        if ( (index < 0) || (index >= filelist->numfiltered) ) {
                return NULL;
        }
@@ -629,7 +638,10 @@ ImBuf *filelist_geticon(struct FileList *filelist, int index)
 {
        ImBuf *ibuf = NULL;
        struct direntry *file = NULL;
-       int fidx = 0;   
+       int fidx = 0;
+
+       BLI_assert(G.background == FALSE);
+
        if ( (index < 0) || (index >= filelist->numfiltered) ) {
                return NULL;
        }
@@ -736,7 +748,9 @@ static int file_is_blend_backup(const char *str)
        a = strlen(str);
        b = 7;
        
-       if (a == 0 || b >= a) ;
+       if (a == 0 || b >= a) {
+               /* pass */
+       }
        else {
                char *loc;
                
@@ -1211,21 +1225,22 @@ void filelist_from_main(struct FileList *filelist)
                        if (ok) {
                                if (!filelist->hide_dot || id->name[2] != '.') {
                                        memset(files, 0, sizeof(struct direntry));
-                                       if (id->lib == NULL)
+                                       if (id->lib == NULL) {
                                                files->relname = BLI_strdup(id->name + 2);
+                                       }
                                        else {
-                                               files->relname = MEM_mallocN(FILE_MAX + 32, "filename for lib");
-                                               sprintf(files->relname, "%s | %s", id->lib->name, id->name + 2);
+                                               files->relname = MEM_mallocN(FILE_MAX + (MAX_ID_NAME - 2),     "filename for lib");
+                                               BLI_snprintf(files->relname, FILE_MAX + (MAX_ID_NAME - 2) + 3, "%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 ( ((Object *)id)->flag & SELECT) files->selflag |= SELECTED_FILE;
                                                }
                                                else if (idcode == ID_SCE) {
                                                        if ( ((Scene *)id)->r.scemode & R_BG_RENDER) files->selflag |= SELECTED_FILE;
-                                               }                                       
+                                               }
                                        }
 #endif
                                        files->nr = totbl + 1;
@@ -1234,10 +1249,10 @@ void filelist_from_main(struct FileList *filelist)
                                        if (idcode == ID_MA || idcode == ID_TE || idcode == ID_LA || idcode == ID_WO || idcode == ID_IM) {
                                                files->flags |= IMAGEFILE;
                                        }
-                                       if (id->lib && fake) BLI_snprintf(files->extra, sizeof(files->extra), "LF %d", id->us);
-                                       else if (id->lib) BLI_snprintf(files->extra, sizeof(files->extra), "L    %d", id->us);
-                                       else if (fake) BLI_snprintf(files->extra, sizeof(files->extra), "F    %d", id->us);
-                                       else BLI_snprintf(files->extra, sizeof(files->extra), "      %d", id->us);
+                                       if      (id->lib && fake) BLI_snprintf(files->extra, sizeof(files->extra), "LF %d",    id->us);
+                                       else if (id->lib)         BLI_snprintf(files->extra, sizeof(files->extra), "L    %d",  id->us);
+                                       else if (fake)            BLI_snprintf(files->extra, sizeof(files->extra), "F    %d",  id->us);
+                                       else                      BLI_snprintf(files->extra, sizeof(files->extra), "      %d", id->us);
                                        
                                        if (id->lib) {
                                                if (totlib == 0) firstlib = files;
@@ -1334,7 +1349,7 @@ static void thumbnails_free(void *tjv)
 
 void thumbnails_start(struct FileList *filelist, const struct bContext *C)
 {
-       wmJob *steve;
+       wmJob *wm_job;
        ThumbnailJob *tj;
        int idx;
        
@@ -1356,13 +1371,14 @@ 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);
-       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);
+       wm_job = WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), filelist, "Thumbnails",
+                            0, WM_JOB_TYPE_FILESEL_THUMBNAIL);
+       WM_jobs_customdata_set(wm_job, tj, thumbnails_free);
+       WM_jobs_timer(wm_job, 0.5, NC_WINDOW, NC_WINDOW);
+       WM_jobs_callbacks(wm_job, thumbnails_startjob, NULL, thumbnails_update, NULL);
 
        /* start the job */
-       WM_jobs_start(CTX_wm_manager(C), steve);
+       WM_jobs_start(CTX_wm_manager(C), wm_job);
 }
 
 void thumbnails_stop(struct FileList *filelist, const struct bContext *C)
@@ -1372,5 +1388,5 @@ void thumbnails_stop(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);
+       return WM_jobs_test(CTX_wm_manager(C), filelist, WM_JOB_TYPE_FILESEL_THUMBNAIL);
 }