diff options
author | Andrea Weikert <elubie@gmx.net> | 2009-01-06 17:42:54 +0300 |
---|---|---|
committer | Andrea Weikert <elubie@gmx.net> | 2009-01-06 17:42:54 +0300 |
commit | b1cb844e0539376cb41cd15bf802aea62848b90a (patch) | |
tree | 5e67be9915d4a76afd9e894cc2e0783d439c41be /source/blender/editors/space_file/filesel.c | |
parent | 10e6566aebec1c1c623cd88c3887db7c113d5af9 (diff) |
2.5 - Start of filebrowser.
- basic drawing of list and thumbnail view (switchable through 'favourits' icon in header)
- selection of files and directories (bookmarks) works with the RMB (right mouse button)
- load operator for files still unstable (no check for correct file type) and incomplete. (WM_operator_free missing)
immediate TODOS:
- fix load file operator
- finish drawing of buttons in header
- drawing of detailed list with all file info.
- finish selection and execute operators (LMB and MMB execute)
later todos:
- parent dir
- keymap for all the shortcuts
- append/link and databrowse
- ...
Diffstat (limited to 'source/blender/editors/space_file/filesel.c')
-rw-r--r-- | source/blender/editors/space_file/filesel.c | 80 |
1 files changed, 69 insertions, 11 deletions
diff --git a/source/blender/editors/space_file/filesel.c b/source/blender/editors/space_file/filesel.c index ea20758884d..9e991fc861e 100644 --- a/source/blender/editors/space_file/filesel.c +++ b/source/blender/editors/space_file/filesel.c @@ -56,9 +56,11 @@ #include "BKE_context.h" #include "BKE_screen.h" +#include "BKE_global.h" #include "ED_screen.h" #include "ED_util.h" +#include "ED_fileselect.h" #include "WM_api.h" #include "WM_types.h" @@ -71,22 +73,78 @@ #include "UI_view2d.h" #include "file_intern.h" +#include "filelist.h" -void freefilelist(SpaceFile *sfile) +FileSelectParams* ED_fileselect_get_params(const struct bContext *C) { - int num; - - num= sfile->totfile-1; + SpaceLink *sl= CTX_wm_space_data(C); + SpaceFile *sfile; + FileSelectParams *params = 0; + + if (sl->spacetype == SPACE_FILE) { + sfile= (SpaceFile*)sl; + params = sfile->params; + } + return params; +} + +short ED_fileselect_set_params(const struct bContext *C, int type, const char *title, const char *path, + short flag, short display, short filter) +{ + char group[32], name[FILE_MAX], temp[FILE_MAX], dir[FILE_MAX], file[FILE_MAX]; + SpaceLink *sl= CTX_wm_space_data(C); + SpaceFile *sfile; + FileSelectParams *params; + + if (sl->spacetype != SPACE_FILE) { + return 0; + } + sfile= (SpaceFile*)sl; + + if (!sfile->params) { + sfile->params = MEM_callocN(sizeof(FileSelectParams), "fileselparams"); + sfile->params->files = filelist_new(); + } + params = sfile->params; + + params->type = type; + params->flag = flag; + params->display = display; + params->filter = filter; + + BLI_strncpy(params->title, title, sizeof(params->title)); - if (sfile->filelist==0) return; + BLI_strncpy(name, path, sizeof(name)); + BLI_convertstringcode(name, G.sce); - for(; num>=0; num--){ - MEM_freeN(sfile->filelist[num].relname); - - if (sfile->filelist[num].string) MEM_freeN(sfile->filelist[num].string); + 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 */ + + filelist_settype(params->files, type); + filelist_setdir(params->files, params->dir); + BLI_cleanup_dir(G.sce, params->dir); /* XXX solve G.sce */ + + /* free: filelist and libfiledata became incorrect */ + if (params->files) { + filelist_free(params->files); + filelist_freelib(params->files); + } + } + break; } - free(sfile->filelist); - sfile->filelist= 0; + + return 1; } |