diff options
author | Andrea Weikert <elubie@gmx.net> | 2009-01-08 21:47:16 +0300 |
---|---|---|
committer | Andrea Weikert <elubie@gmx.net> | 2009-01-08 21:47:16 +0300 |
commit | 879aa81743f165aabfe3c4f88b6394bc6c22308e (patch) | |
tree | 18ca05d82eb56c039419a7bdcfb857b841f31cee /source/blender/editors/space_file | |
parent | 38e263171e387c4d8ab0968c368c249355148739 (diff) |
2.5 filebrowser
cleanup of space initialisation
fix for filebrowser opening with wrong parameters from window pupmenu after having been opened with F1.
Diffstat (limited to 'source/blender/editors/space_file')
-rw-r--r-- | source/blender/editors/space_file/file_draw.c | 10 | ||||
-rw-r--r-- | source/blender/editors/space_file/file_header.c | 2 | ||||
-rw-r--r-- | source/blender/editors/space_file/file_ops.c | 4 | ||||
-rw-r--r-- | source/blender/editors/space_file/filesel.c | 23 | ||||
-rw-r--r-- | source/blender/editors/space_file/space_file.c | 30 |
5 files changed, 40 insertions, 29 deletions
diff --git a/source/blender/editors/space_file/file_draw.c b/source/blender/editors/space_file/file_draw.c index 78e4116faef..c45993d71cb 100644 --- a/source/blender/editors/space_file/file_draw.c +++ b/source/blender/editors/space_file/file_draw.c @@ -128,7 +128,7 @@ static void do_file_buttons(bContext *C, void *arg, int event) void file_draw_buttons(const bContext *C, ARegion *ar) { SpaceFile *sfile= (SpaceFile*)CTX_wm_space_data(C); - FileSelectParams* params = sfile->params; + FileSelectParams* params = ED_fileselect_get_params(sfile); uiBlock *block; int loadbutton; char name[20]; @@ -277,7 +277,7 @@ static int file_view_columns(SpaceFile* sfile, View2D *v2d) void file_calc_previews(const bContext *C, ARegion *ar) { SpaceFile *sfile= (SpaceFile*)CTX_wm_space_data(C); - FileSelectParams* params = sfile->params; + FileSelectParams* params = ED_fileselect_get_params(sfile); View2D *v2d= &ar->v2d; int width=0, height=0; int rows, columns; @@ -316,7 +316,7 @@ void file_calc_previews(const bContext *C, ARegion *ar) void file_draw_previews(const bContext *C, ARegion *ar) { SpaceFile *sfile= (SpaceFile*)CTX_wm_space_data(C); - FileSelectParams* params=sfile->params; + FileSelectParams* params= ED_fileselect_get_params(sfile); View2D *v2d= &ar->v2d; static double lasttime= 0; struct FileList* files = sfile->files; @@ -471,7 +471,7 @@ void file_draw_previews(const bContext *C, ARegion *ar) void file_draw_list(const bContext *C, ARegion *ar) { SpaceFile *sfile= (SpaceFile*)CTX_wm_space_data(C); - FileSelectParams* params = sfile->params; + FileSelectParams* params = ED_fileselect_get_params(sfile); struct FileList* files = sfile->files; struct direntry *file; int numfiles; @@ -558,7 +558,7 @@ void file_draw_list(const bContext *C, ARegion *ar) void file_draw_fsmenu(const bContext *C, ARegion *ar) { SpaceFile *sfile= (SpaceFile*)CTX_wm_space_data(C); - FileSelectParams* params = sfile->params; + FileSelectParams* params = ED_fileselect_get_params(sfile); char bookmark[FILE_MAX]; int nentries = fsmenu_get_nentries(); int linestep = U.fontsize*3/2; diff --git a/source/blender/editors/space_file/file_header.c b/source/blender/editors/space_file/file_header.c index 2aeb8ed0684..cbe36f28c9d 100644 --- a/source/blender/editors/space_file/file_header.c +++ b/source/blender/editors/space_file/file_header.c @@ -117,7 +117,7 @@ void file_header_buttons(const bContext *C, ARegion *ar) { ScrArea *sa= CTX_wm_area(C); SpaceFile *sfile= (SpaceFile*)CTX_wm_space_data(C); - FileSelectParams* params = sfile->params; + FileSelectParams* params = ED_fileselect_get_params(sfile); uiBlock *block; int xco, yco= 3; diff --git a/source/blender/editors/space_file/file_ops.c b/source/blender/editors/space_file/file_ops.c index d9e831c84da..49014a69b68 100644 --- a/source/blender/editors/space_file/file_ops.c +++ b/source/blender/editors/space_file/file_ops.c @@ -116,7 +116,7 @@ static void set_active_file(SpaceFile *sfile, FileSelectParams* params, struct A } -static void set_active_bookmark(SpaceFile *sfile, FileSelectParams* params, struct ARegion* ar, short y) +static void set_active_bookmark(FileSelectParams* params, struct ARegion* ar, short y) { int nentries = fsmenu_get_nentries(); short posy = ar->v2d.mask.ymax - TILE_BORDER_Y - y; @@ -187,7 +187,7 @@ static void mouse_select_bookmark(SpaceFile* sfile, ARegion* ar, short *mval) if(mval[0]>ar->v2d.mask.xmin && mval[0]<ar->v2d.mask.xmax && mval[1]>ar->v2d.mask.ymin && mval[1]<ar->v2d.mask.ymax) { char *selected; - set_active_bookmark(sfile, sfile->params, ar, mval[1]); + set_active_bookmark(sfile->params, ar, mval[1]); selected= fsmenu_get_entry(sfile->params->active_bookmark); /* which string */ if (selected) { diff --git a/source/blender/editors/space_file/filesel.c b/source/blender/editors/space_file/filesel.c index d1cfdb07c39..f2eb7ad58ea 100644 --- a/source/blender/editors/space_file/filesel.c +++ b/source/blender/editors/space_file/filesel.c @@ -76,15 +76,26 @@ #include "filelist.h" -short ED_fileselect_set_params(FileSelectParams *params, int type, const char *title, const char *path, +FileSelectParams* ED_fileselect_get_params(struct SpaceFile *sfile) +{ + if (!sfile->params) { + ED_fileselect_set_params(sfile, FILE_UNIX, "", "/", 0, 0, 0); + } + return sfile->params; +} + +short ED_fileselect_set_params(SpaceFile *sfile, int type, const char *title, const char *path, short flag, short display, short filter) { char name[FILE_MAX], dir[FILE_MAX], file[FILE_MAX]; + FileSelectParams *params; - if (!params) { - return 0; + if (!sfile->params) { + sfile->params= MEM_callocN(sizeof(FileSelectParams), "fileselparams"); } + params = sfile->params; + params->type = type; params->flag = flag; params->display = display; @@ -115,3 +126,9 @@ short ED_fileselect_set_params(FileSelectParams *params, int type, const char *t return 1; } +void ED_fileselect_reset_params(SpaceFile *sfile) +{ + sfile->params->type = FILE_UNIX; + sfile->params->flag = 0; + sfile->params->title[0] = '\0'; +} diff --git a/source/blender/editors/space_file/space_file.c b/source/blender/editors/space_file/space_file.c index 703d351af2b..aa364bfb093 100644 --- a/source/blender/editors/space_file/space_file.c +++ b/source/blender/editors/space_file/space_file.c @@ -74,13 +74,7 @@ static SpaceLink *file_new(const bContext *C) SpaceFile *sfile; sfile= MEM_callocN(sizeof(SpaceFile), "initfile"); - sfile->spacetype= SPACE_FILE; - sfile->params= MEM_callocN(sizeof(FileSelectParams), "fileselparams"); - sfile->files = filelist_new(); - - ED_fileselect_set_params(sfile->params, FILE_UNIX, "", "/", 0, 0, 0); - filelist_setdir(sfile->files, sfile->params->dir); - filelist_settype(sfile->files, sfile->params->type); + sfile->spacetype= SPACE_FILE; /* header */ ar= MEM_callocN(sizeof(ARegion), "header for file"); @@ -122,14 +116,14 @@ static void file_free(SpaceLink *sl) filelist_free(sfile->files); filelist_freelib(sfile->files); MEM_freeN(sfile->files); - sfile->files = 0; + sfile->files= NULL; } if (sfile->params) { if(sfile->params->pupmenu) MEM_freeN(sfile->params->pupmenu); MEM_freeN(sfile->params); - sfile->params = 0; + sfile->params= NULL; } if (sfile->op) { @@ -142,16 +136,15 @@ static void file_free(SpaceLink *sl) static void file_init(struct wmWindowManager *wm, ScrArea *sa) { SpaceFile *sfile= sa->spacedata.first; /* XXX get through context? */ - if (!sfile->params) { - sfile->params= MEM_callocN(sizeof(FileSelectParams), "fileselparams"); - ED_fileselect_set_params(sfile->params, FILE_UNIX, "", "/", 0, 0, 0); + if (sfile->params) { + ED_fileselect_reset_params(sfile); } - if (!sfile->files) { - sfile->files = filelist_new(); + if (sfile->files) { + filelist_free(sfile->files); + filelist_freelib(sfile->files); + MEM_freeN(sfile->files); + sfile->files= NULL; } - - filelist_setdir(sfile->files, sfile->params->dir); - filelist_settype(sfile->files, sfile->params->type); } static SpaceLink *file_duplicate(SpaceLink *sl) @@ -165,9 +158,10 @@ static SpaceLink *file_duplicate(SpaceLink *sl) sfilen->params= MEM_dupallocN(sfileo->params); if (!sfilen->params) { sfilen->params= MEM_callocN(sizeof(FileSelectParams), "fileselparams"); - ED_fileselect_set_params(sfilen->params, FILE_UNIX, "", "/", 0, 0, 0); + ED_fileselect_set_params(sfilen, FILE_UNIX, "", "/", 0, 0, 0); sfilen->params->pupmenu = NULL; } + sfilen->files = filelist_new(); filelist_setdir(sfilen->files, sfilen->params->dir); filelist_settype(sfilen->files, sfilen->params->type); |