Fix [#21618] Wrong Icon For BLEND file on File/Append
authorAndrea Weikert <elubie@gmx.net>
Mon, 15 Mar 2010 20:28:13 +0000 (20:28 +0000)
committerAndrea Weikert <elubie@gmx.net>
Mon, 15 Mar 2010 20:28:13 +0000 (20:28 +0000)
While the folder icon was originally planned when in append/link mode, it's easier to distinguish with a blender icon, so the folder icon is now replaced.

Also fixed issue introduced in rev. 27491 where filter settings were incorrectly set when moving out of .blend file again.

source/blender/editors/space_file/file_draw.c
source/blender/editors/space_file/filelist.c
source/blender/editors/space_file/filesel.c
source/blender/editors/space_file/space_file.c
source/blender/makesdna/DNA_space_types.h
source/blender/makesrna/intern/rna_space.c

index a2b4dcbac60029dea77850f6e4fba2faf9700ecd..63729f03e581c4d8191b83277f372803f9cbd9a8 100644 (file)
@@ -298,6 +298,9 @@ static int get_file_icon(struct direntry *file)
                if ( strcmp(file->relname, "..") == 0) {
                                return  ICON_FILE_PARENT;
                }
+               if(file->flags & BLENDERFILE) {
+                       return ICON_FILE_BLEND;
+               }
                return ICON_FILE_FOLDER;
        }
        else if (file->flags & BLENDERFILE)
index b90bb47e6cebb333a9d25752ee202b6d88c044db..c11260d717937526eddf96607643714de1492632 100644 (file)
@@ -627,13 +627,13 @@ 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) {
-                               ibuf = gSpecialFileImages[SPECIAL_IMG_PARENT];
-                       } else if  ( strcmp(filelist->filelist[fidx].relname, ".") == 0) {
-                               ibuf = gSpecialFileImages[SPECIAL_IMG_REFRESH];
-                       } else {
-               ibuf = gSpecialFileImages[SPECIAL_IMG_FOLDER];
-                       }
+               if ( strcmp(filelist->filelist[fidx].relname, "..") == 0) {
+                       ibuf = gSpecialFileImages[SPECIAL_IMG_PARENT];
+               } else if  ( strcmp(filelist->filelist[fidx].relname, ".") == 0) {
+                       ibuf = gSpecialFileImages[SPECIAL_IMG_REFRESH];
+               } else {
+                       ibuf = gSpecialFileImages[SPECIAL_IMG_FOLDER];
+               }
        } else {
                ibuf = gSpecialFileImages[SPECIAL_IMG_UNKNOWNFILE];
        }
@@ -788,8 +788,12 @@ void filelist_setfiletypes(struct FileList* filelist, short has_quicktime)
                file->type= file->s.st_mode;    /* restore the mess below */ 
 
                        /* Don't check extensions for directories */ 
-               if (file->type & S_IFDIR)
+               if (file->type & S_IFDIR) {
+                       if(BLO_has_bfile_extension(file->relname)) {
+                               file->flags |= BLENDERFILE;
+                       }
                        continue;
+               }
 
                if(BLO_has_bfile_extension(file->relname)) {
                        file->flags |= BLENDERFILE;
index 758740e676a442a69f8854e91a70d03afe13c440..6945e8c959a12c33331ad977a8958c457d800775 100644 (file)
@@ -194,7 +194,7 @@ short ED_fileselect_set_params(SpaceFile *sfile)
                params->filter = 0;
                params->sort = FILE_SORT_ALPHA;
        }
-
+       params->oldflag = params->flag; 
        return 1;
 }
 
@@ -414,6 +414,9 @@ void file_change_dir(bContext *C, int checkdir)
                        char dir[FILE_MAX];
                        if (filelist_islibrary(sfile->files, dir, group)) {
                                sfile->params->flag &= ~FILE_FILTER;
+                       } else {
+                               /* reset the old flag */
+                               sfile->params->flag = sfile->params->oldflag;
                        }
                }
                if(folderlist_clear_next(sfile))
index 105ece8e95fd3af05ba21d6eeca9b7c6548b216d..141d4f63f1ce2250b683baaea57d3b8cc1f09d54 100644 (file)
@@ -140,8 +140,6 @@ static void file_free(SpaceLink *sl)
        }
 
        if (sfile->params) {
-               if(sfile->params->pupmenu)
-                       MEM_freeN(sfile->params->pupmenu);
                MEM_freeN(sfile->params);
                sfile->params= NULL;
        }
@@ -208,6 +206,8 @@ static void file_refresh(const bContext *C, ScrArea *sa)
                filelist_readdir(sfile->files);
                thumbnails_start(sfile->files, C);
                BLI_strncpy(params->dir, filelist_dir(sfile->files), FILE_MAX);
+       } else {
+               filelist_filter(sfile->files);
        }
        if(params->sort!=FILE_SORT_NONE) filelist_sort(sfile->files, params->sort);             
        
index 293eac3c5a5c678fc3e40eae241f33a7c67341fe..8e460b80585e1c1256c8120eb57409a062c53010 100644 (file)
@@ -162,21 +162,23 @@ typedef struct FileSelectParams {
 
        short type; /* XXXXX for now store type here, should be moved to the operator */
        short flag; /* settings for filter, hiding dots files,...  */
+       short oldflag; /* temp storage of original flag settings */
        short sort; /* sort order */
        short display; /* display mode flag */
        short filter; /* filter when (flags & FILE_FILTER) is true */
 
        /* XXX - temporary, better move to filelist */
        short active_bookmark;
+       short pad;
        int     active_file;
        int selstate;
 
        /* short */
        /* XXX --- still unused -- */
        short f_fp; /* show font preview */
-       short menu; /* currently selected option in pupmenu */
+       short pad2;
        char fp_str[8]; /* string to use for font preview */
-       char *pupmenu; /* allows menu for save options - result stored in menup */
+
        /* XXX --- end unused -- */
 } FileSelectParams;
 
index 9b7e6b5bc05f8da2eddca2baa42d075ab5b6926e..ddbeb8a85fe1f5d2b01122512812c5615ac78a5f 100644 (file)
@@ -567,6 +567,14 @@ static void rna_Sequencer_display_mode_update(bContext *C, PointerRNA *ptr)
        ED_sequencer_update_view(C, view);
 }
 
+static void rna_FileSelectParams_flag_update(Main *bmain, Scene *scene, PointerRNA *ptr)
+{
+       FileSelectParams* params = (FileSelectParams*)ptr->data;
+       if (params) {
+               params->oldflag = params->flag;
+       }
+}
+
 #else
 
 static void rna_def_space(BlenderRNA *brna)
@@ -1838,12 +1846,12 @@ static void rna_def_fileselect_params(BlenderRNA *brna)
        prop= RNA_def_property(srna, "do_filter", PROP_BOOLEAN, PROP_NONE);
        RNA_def_property_boolean_sdna(prop, NULL, "flag", FILE_FILTER);
        RNA_def_property_ui_text(prop, "Filter Files", "Enable filtering of files");
-       RNA_def_property_update(prop, NC_SPACE|ND_SPACE_FILE_PARAMS, NULL);
+       RNA_def_property_update(prop, NC_SPACE|ND_SPACE_FILE_PARAMS, "rna_FileSelectParams_flag_update");
 
        prop= RNA_def_property(srna, "hide_dot", PROP_BOOLEAN, PROP_NONE);
        RNA_def_property_boolean_sdna(prop, NULL, "flag", FILE_HIDE_DOT);
        RNA_def_property_ui_text(prop, "Hide Dot Files", "Hide hidden dot files");
-       RNA_def_property_update(prop, NC_SPACE|ND_SPACE_FILE_LIST , NULL);
+       RNA_def_property_update(prop, NC_SPACE|ND_SPACE_FILE_LIST , "rna_FileSelectParams_flag_update");
 
        prop= RNA_def_property(srna, "sort", PROP_ENUM, PROP_NONE);
        RNA_def_property_enum_sdna(prop, NULL, "sort");