2.5 filebrowser
[blender.git] / source / blender / editors / space_file / file_header.c
index b967e21c99cb39c0a8af802e698dc42925659651..b9d6c7f7c101cf48a7b94d647d75d89e6e39fd43 100644 (file)
@@ -63,7 +63,7 @@
 
 #define B_SORTIMASELLIST 1
 #define B_RELOADIMASELDIR 2
 
 #define B_SORTIMASELLIST 1
 #define B_RELOADIMASELDIR 2
-
+#define B_FILTERIMASELDIR 3
 
 /* ************************ header area region *********************** */
 
 
 /* ************************ header area region *********************** */
 
@@ -108,6 +108,17 @@ static void do_file_header_buttons(bContext *C, void *arg, int event)
                case B_RELOADIMASELDIR:
                        WM_event_add_notifier(C, NC_WINDOW, NULL);
                        break;
                case B_RELOADIMASELDIR:
                        WM_event_add_notifier(C, NC_WINDOW, NULL);
                        break;
+               case B_FILTERIMASELDIR:
+                       if(sfile->params) {
+                               if (sfile->params->flag & FILE_FILTER) {
+                                       filelist_setfilter(sfile->files,sfile->params->filter);
+                                       filelist_filter(sfile->files);
+                               } else {
+                                       filelist_setfilter(sfile->files,0);
+                                       filelist_filter(sfile->files);
+                               }
+                       }
+                       WM_event_add_notifier(C, NC_WINDOW, NULL);
        }
 }
 
        }
 }
 
@@ -180,6 +191,22 @@ void file_header_buttons(const bContext *C, ARegion *ar)
        }
         */
 
        }
         */
 
+       uiDefIconButBitS(block, TOG, FILE_FILTER, B_FILTERIMASELDIR, ICON_FILTER,xco+=XIC,0,XIC,YIC, &params->flag, 0, 0, 0, 0, "Filter files");
+       if (params->flag & FILE_FILTER) {
+               xco+=4;
+               uiBlockBeginAlign(block);
+               uiDefIconButBitS(block, TOG, IMAGEFILE, B_FILTERIMASELDIR, ICON_FILE_IMAGE,xco+=XIC,0,XIC,YIC, &params->filter, 0, 0, 0, 0, "Show images");
+               uiDefIconButBitS(block, TOG, BLENDERFILE, B_FILTERIMASELDIR, ICON_FILE_BLEND,xco+=XIC,0,XIC,YIC, &params->filter, 0, 0, 0, 0, "Show .blend files");
+               uiDefIconButBitS(block, TOG, MOVIEFILE, B_FILTERIMASELDIR, ICON_FILE_MOVIE,xco+=XIC,0,XIC,YIC, &params->filter, 0, 0, 0, 0, "Show movies");
+               uiDefIconButBitS(block, TOG, PYSCRIPTFILE, B_FILTERIMASELDIR, ICON_FILE_SCRIPT,xco+=XIC,0,XIC,YIC, &params->filter, 0, 0, 0, 0, "Show python scripts");
+               uiDefIconButBitS(block, TOG, FTFONTFILE, B_FILTERIMASELDIR, ICON_FILE_FONT,xco+=XIC,0,XIC,YIC, &params->filter, 0, 0, 0, 0, "Show fonts");
+               uiDefIconButBitS(block, TOG, SOUNDFILE, B_FILTERIMASELDIR, ICON_FILE_SOUND,xco+=XIC,0,XIC,YIC, &params->filter, 0, 0, 0, 0, "Show sound files");
+               uiDefIconButBitS(block, TOG, TEXTFILE, B_FILTERIMASELDIR, ICON_FILE_BLANK,xco+=XIC,0,XIC,YIC, &params->filter, 0, 0, 0, 0, "Show text files");
+               uiDefIconButBitS(block, TOG, FOLDERFILE, B_FILTERIMASELDIR, ICON_FILE_FOLDER,xco+=XIC,0,XIC,YIC, &params->filter, 0, 0, 0, 0, "Show folders");
+               uiBlockEndAlign(block);
+               xco+=XIC;
+       }
+
        xcotitle= xco;
        xco+= UI_GetStringWidth(G.font, params->title, 0);
 
        xcotitle= xco;
        xco+= UI_GetStringWidth(G.font, params->title, 0);