2.5 filebrowser
* code cleanup: removed unused fileselect mode (type) * brought back 'hide dot files', needs proper storing of the settings still.
This commit is contained in:
@@ -35,7 +35,6 @@ struct SpaceFile;
|
||||
#define FILE_IMGDISPLAY 3
|
||||
|
||||
typedef struct FileSelectParams {
|
||||
int type; /* the mode of the filebrowser, FILE_BLENDER, FILE_SPECIAL, FILE_MAIN or FILE_LOADLIB */
|
||||
char title[24]; /* title, also used for the text of the execute button */
|
||||
char dir[240]; /* directory */
|
||||
char file[80]; /* file */
|
||||
@@ -96,8 +95,8 @@ typedef struct FileLayout
|
||||
|
||||
FileSelectParams* ED_fileselect_get_params(struct SpaceFile *sfile);
|
||||
|
||||
short ED_fileselect_set_params(struct SpaceFile *sfile, int type, const char *title, const char *path,
|
||||
short flag, short display, short filter);
|
||||
short ED_fileselect_set_params(struct SpaceFile *sfile, const char *title, const char *path,
|
||||
short flag, short display, short filter, short sort);
|
||||
|
||||
void ED_fileselect_reset_params(struct SpaceFile *sfile);
|
||||
|
||||
|
||||
@@ -444,12 +444,10 @@ void file_draw_list(const bContext *C, ARegion *ar)
|
||||
int colorid = 0;
|
||||
short sx, sy;
|
||||
int offset;
|
||||
short type;
|
||||
int i;
|
||||
float sw, spos;
|
||||
|
||||
numfiles = filelist_numfiles(files);
|
||||
type = filelist_gettype(files);
|
||||
|
||||
sx = ar->v2d.tot.xmin + layout->tile_border_x/2;
|
||||
sy = ar->v2d.cur.ymax - layout->tile_border_y;
|
||||
|
||||
@@ -63,6 +63,7 @@
|
||||
#define B_SORTIMASELLIST 1
|
||||
#define B_RELOADIMASELDIR 2
|
||||
#define B_FILTERIMASELDIR 3
|
||||
#define B_HIDEDOTFILES 4
|
||||
|
||||
/* ************************ header area region *********************** */
|
||||
|
||||
@@ -88,6 +89,14 @@ static void do_file_header_buttons(bContext *C, void *arg, int event)
|
||||
}
|
||||
}
|
||||
WM_event_add_notifier(C, NC_WINDOW, NULL);
|
||||
break;
|
||||
case B_HIDEDOTFILES:
|
||||
if(sfile->params) {
|
||||
filelist_free(sfile->files);
|
||||
filelist_hidedot(sfile->files, sfile->params->flag & FILE_HIDE_DOT);
|
||||
WM_event_add_notifier(C, NC_WINDOW, NULL);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -126,7 +135,6 @@ void file_header_buttons(const bContext *C, ARegion *ar)
|
||||
|
||||
xco += 5;
|
||||
|
||||
if (sfile->params->type != FILE_MAIN) {
|
||||
uiBlockBeginAlign(block);
|
||||
uiDefIconButS(block, ROW, B_RELOADIMASELDIR, ICON_SHORTDISPLAY, xco+=XIC, yco, XIC,YIC, ¶ms->display, 1.0, FILE_SHORTDISPLAY, 0, 0, "Displays short file description");
|
||||
uiDefIconButS(block, ROW, B_RELOADIMASELDIR, ICON_LONGDISPLAY, xco+=XIC, yco, XIC,YIC, ¶ms->display, 1.0, FILE_LONGDISPLAY, 0, 0, "Displays long file description");
|
||||
@@ -134,7 +142,7 @@ void file_header_buttons(const bContext *C, ARegion *ar)
|
||||
uiBlockEndAlign(block);
|
||||
|
||||
xco+=XIC;
|
||||
}
|
||||
|
||||
|
||||
uiBlockBeginAlign(block);
|
||||
uiDefIconButS(block, ROW, B_SORTIMASELLIST, ICON_SORTALPHA, xco+=XIC, yco, XIC,YIC, ¶ms->sort, 1.0, 0.0, 0, 0, "Sorts files alphabetically");
|
||||
@@ -144,17 +152,8 @@ void file_header_buttons(const bContext *C, ARegion *ar)
|
||||
uiBlockEndAlign(block);
|
||||
|
||||
xco+=XIC;
|
||||
|
||||
/* replace with consistent sub-region collapsing
|
||||
if (sfile->params->type != FILE_MAIN) {
|
||||
uiBlockBeginAlign(block);
|
||||
// uiDefIconButBitS(block, TOG, FILE_BOOKMARKS, B_RELOADIMASELDIR, ICON_BOOKMARKS,xco+=XIC,0,XIC,YIC, ¶ms->flag, 0, 0, 0, 0, "Toggles Bookmarks on/off");
|
||||
uiDefIconButO(block, TOG, "FILE_OT_bookmark_toggle", WM_OP_INVOKE_DEFAULT, ICON_BOOKMARKS, xco+XIC,yco,20,20, "Toggle Bookmarks");
|
||||
uiBlockEndAlign(block);
|
||||
uiDefIconButBitS(block, TOG, FILE_HIDE_DOT, B_HIDEDOTFILES, ICON_GHOST,xco+=XIC,yco,XIC,YIC, ¶ms->flag, 0, 0, 0, 0, "Hide dot files");
|
||||
xco+=XIC;
|
||||
}
|
||||
*/
|
||||
|
||||
uiDefIconButBitS(block, TOG, FILE_FILTER, B_FILTERIMASELDIR, ICON_FILTER,xco+=XIC,yco,XIC,YIC, ¶ms->flag, 0, 0, 0, 0, "Filter files");
|
||||
|
||||
if (params->flag & FILE_FILTER) {
|
||||
|
||||
@@ -113,7 +113,6 @@ typedef struct FileList
|
||||
int numfiles;
|
||||
int numfiltered;
|
||||
char dir[FILE_MAX];
|
||||
short type;
|
||||
int has_func;
|
||||
short prv_w;
|
||||
short prv_h;
|
||||
@@ -358,12 +357,6 @@ void filelist_free_icons()
|
||||
struct FileList* filelist_new()
|
||||
{
|
||||
FileList* p = MEM_callocN( sizeof(FileList), "filelist" );
|
||||
p->filelist = 0;
|
||||
p->numfiles = 0;
|
||||
p->dir[0] = '\0';
|
||||
p->type = 0;
|
||||
p->has_func = 0;
|
||||
p->filter = 0;
|
||||
return p;
|
||||
}
|
||||
|
||||
@@ -373,7 +366,6 @@ struct FileList* filelist_copy(struct FileList* filelist)
|
||||
BLI_strncpy(p->dir, filelist->dir, FILE_MAX);
|
||||
p->filelist = NULL;
|
||||
p->fidx = NULL;
|
||||
p->type = filelist->type;
|
||||
|
||||
return p;
|
||||
}
|
||||
@@ -413,6 +405,7 @@ void filelist_free(struct FileList* filelist)
|
||||
filelist->filelist = 0;
|
||||
filelist->filter = 0;
|
||||
filelist->numfiltered =0;
|
||||
filelist->hide_dot =0;
|
||||
}
|
||||
|
||||
int filelist_numfiles(struct FileList* filelist)
|
||||
@@ -510,8 +503,7 @@ void filelist_loadimage(struct FileList* filelist, int index)
|
||||
|
||||
if (!filelist->filelist[fidx].image)
|
||||
{
|
||||
if (filelist->type != FILE_MAIN)
|
||||
{
|
||||
|
||||
if ( (filelist->filelist[fidx].flags & IMAGEFILE) || (filelist->filelist[fidx].flags & MOVIEFILE) ) {
|
||||
imb = IMB_thumb_read(filelist->dir, filelist->filelist[fidx].relname, THB_NORMAL);
|
||||
}
|
||||
@@ -552,7 +544,6 @@ void filelist_loadimage(struct FileList* filelist, int index)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct ImBuf * filelist_getimage(struct FileList* filelist, int index)
|
||||
@@ -826,16 +817,6 @@ void filelist_swapselect(struct FileList* filelist)
|
||||
}
|
||||
}
|
||||
|
||||
void filelist_settype(struct FileList* filelist, int type)
|
||||
{
|
||||
filelist->type = type;
|
||||
}
|
||||
|
||||
short filelist_gettype(struct FileList* filelist)
|
||||
{
|
||||
return filelist->type;
|
||||
}
|
||||
|
||||
void filelist_sort(struct FileList* filelist, short sort)
|
||||
{
|
||||
struct direntry *file;
|
||||
|
||||
@@ -70,8 +70,7 @@ void filelist_readdir(struct FileList* filelist);
|
||||
int filelist_empty(struct FileList* filelist);
|
||||
void filelist_parent(struct FileList* filelist);
|
||||
void filelist_setfiletypes(struct FileList* filelist, short has_quicktime);
|
||||
void filelist_settype(struct FileList* filelist, int type);
|
||||
short filelist_gettype(struct FileList* filelist);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -84,13 +84,13 @@
|
||||
FileSelectParams* ED_fileselect_get_params(struct SpaceFile *sfile)
|
||||
{
|
||||
if (!sfile->params) {
|
||||
ED_fileselect_set_params(sfile, FILE_UNIX, "", "/", 0, FILE_SHORTDISPLAY, 0);
|
||||
ED_fileselect_set_params(sfile, "", "/", 0, FILE_SHORTDISPLAY, 0, FILE_SORTALPHA);
|
||||
}
|
||||
return sfile->params;
|
||||
}
|
||||
|
||||
short ED_fileselect_set_params(SpaceFile *sfile, int type, const char *title, const char *path,
|
||||
short flag, short display, short filter)
|
||||
short ED_fileselect_set_params(SpaceFile *sfile, const char *title, const char *path,
|
||||
short flag, short display, short filter, short sort)
|
||||
{
|
||||
char name[FILE_MAX], dir[FILE_MAX], file[FILE_MAX];
|
||||
FileSelectParams *params;
|
||||
@@ -101,39 +101,26 @@ short ED_fileselect_set_params(SpaceFile *sfile, int type, const char *title, co
|
||||
|
||||
params = sfile->params;
|
||||
|
||||
params->type = type;
|
||||
params->flag = flag;
|
||||
params->display = display;
|
||||
params->filter = filter;
|
||||
params->sort = sort;
|
||||
|
||||
BLI_strncpy(params->title, title, sizeof(params->title));
|
||||
|
||||
BLI_strncpy(name, path, sizeof(name));
|
||||
BLI_convertstringcode(name, G.sce);
|
||||
|
||||
switch(type) {
|
||||
case FILE_MAIN:
|
||||
break;
|
||||
case FILE_LOADLIB:
|
||||
break;
|
||||
case FILE_BLENDER:
|
||||
case FILE_LOADFONT:
|
||||
default:
|
||||
{
|
||||
BLI_split_dirfile(name, dir, file);
|
||||
BLI_strncpy(params->file, file, sizeof(params->file));
|
||||
BLI_strncpy(params->dir, dir, sizeof(params->dir));
|
||||
BLI_make_file_string(G.sce, params->dir, dir, ""); /* XXX needed ? - also solve G.sce */
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
void ED_fileselect_reset_params(SpaceFile *sfile)
|
||||
{
|
||||
sfile->params->type = FILE_UNIX;
|
||||
sfile->params->flag = 0;
|
||||
sfile->params->title[0] = '\0';
|
||||
}
|
||||
|
||||
@@ -156,7 +156,6 @@ static SpaceLink *file_duplicate(SpaceLink *sl)
|
||||
sfilen->params= MEM_dupallocN(sfileo->params);
|
||||
|
||||
filelist_setdir(sfilen->files, sfilen->params->dir);
|
||||
filelist_settype(sfilen->files, sfilen->params->type);
|
||||
}
|
||||
if (sfileo->layout) {
|
||||
sfilen->layout= MEM_dupallocN(sfileo->layout);
|
||||
@@ -193,7 +192,6 @@ static void file_main_area_draw(const bContext *C, ARegion *ar)
|
||||
if (!sfile->files) {
|
||||
sfile->files = filelist_new();
|
||||
filelist_setdir(sfile->files, params->dir);
|
||||
filelist_settype(sfile->files, params->type);
|
||||
params->active_file = -1; // added this so it opens nicer (ton)
|
||||
}
|
||||
|
||||
|
||||
@@ -773,12 +773,9 @@ static int wm_handler_fileselect_call(bContext *C, ListBase *handlers, wmEventHa
|
||||
case EVT_FILESELECT_OPEN:
|
||||
case EVT_FILESELECT_FULL_OPEN:
|
||||
{
|
||||
int filetype= FILE_BLENDER;
|
||||
short flag =0; short display =FILE_SHORTDISPLAY; short filter =0; short sort =FILE_SORTALPHA;
|
||||
char *path= RNA_string_get_alloc(handler->op->ptr, "filename", NULL, 0);
|
||||
|
||||
if(RNA_struct_find_property(handler->op->ptr, "filetype"))
|
||||
filetype= RNA_int_get(handler->op->ptr, "filetype");
|
||||
|
||||
if(event->val==EVT_FILESELECT_OPEN)
|
||||
ED_area_newspace(C, handler->op_area, SPACE_FILE);
|
||||
else
|
||||
@@ -788,7 +785,16 @@ static int wm_handler_fileselect_call(bContext *C, ListBase *handlers, wmEventHa
|
||||
sfile= (SpaceFile*)CTX_wm_space_data(C);
|
||||
sfile->op= handler->op;
|
||||
|
||||
ED_fileselect_set_params(sfile, filetype, handler->op->type->name, path, 0, FILE_SHORTDISPLAY, 0);
|
||||
/* XXX for now take the settings from the existing (previous) filebrowser
|
||||
should be stored in settings and passed via the operator */
|
||||
if (sfile->params) {
|
||||
flag = sfile->params->flag;
|
||||
filter = sfile->params->filter;
|
||||
display = sfile->params->display;
|
||||
sort = sfile->params->sort;
|
||||
}
|
||||
|
||||
ED_fileselect_set_params(sfile, handler->op->type->name, path, flag, display, filter, sort);
|
||||
MEM_freeN(path);
|
||||
|
||||
action= WM_HANDLER_BREAK;
|
||||
|
||||
Reference in New Issue
Block a user