Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDalai Felinto <dfelinto@gmail.com>2009-07-07 11:25:44 +0400
committerDalai Felinto <dfelinto@gmail.com>2009-07-07 11:25:44 +0400
commitcfd5046c9e4a6617a20cfc7e59519a84d3c18b9d (patch)
tree2c2c1180a69c5996ad7ebbca151234469cdf475a /source/blender/editors/space_file/filelist.c
parent79633056ac3848237d8bb8245523501905582f2e (diff)
2.5 filebrowser: previous/next + bugfix + elubie's changes and cleanup
* Previous/Next Folder browser * bugfix: "open most recently opened directory". * Previous and Next functionalities: - use BACKSPACE to navigate to previous folders - use SHIFT+BACKSPACE to navigate forward - once you change the folder by other ways the forward folder list is cleared * bug fix: the sfile->params->dir set through ED_fileselect_set_params wasn't correct. According to the code taking the settings from the existing (previous) filebrowser is a temp solution. In that case this is a fix for a temp solution :) (changes in: wm_event_system.c, filesel.c and ED_fileselect.h) ** Andrea(elubie): we can get away of the folderlist_clear_next test if we manually pass a boolean to file_change_dir (e.g. file_change_dir(sfile, true)). I tried not to mess up with your changes here. It's slightly slower (and maybe hacky) but its's more conservative IMHO. (my first commit to 2.5 ... that was a good reason to put my paper on hold :p)
Diffstat (limited to 'source/blender/editors/space_file/filelist.c')
-rw-r--r--source/blender/editors/space_file/filelist.c88
1 files changed, 87 insertions, 1 deletions
diff --git a/source/blender/editors/space_file/filelist.c b/source/blender/editors/space_file/filelist.c
index 573aed72728..ab5dac1a727 100644
--- a/source/blender/editors/space_file/filelist.c
+++ b/source/blender/editors/space_file/filelist.c
@@ -123,6 +123,12 @@ typedef struct FileList
ListBase threads;
} FileList;
+typedef struct FolderList
+{
+ struct FolderList *next, *prev;
+ char *foldername;
+} FolderList;
+
#define SPECIAL_IMG_SIZE 48
#define SPECIAL_IMG_ROWS 4
#define SPECIAL_IMG_COLS 4
@@ -354,6 +360,86 @@ void filelist_free_icons()
}
}
+//-----------------FOLDERLIST (previous/next) --------------//
+struct ListBase* folderlist_new()
+{
+ ListBase* p = MEM_callocN( sizeof(ListBase), "folderlist" );
+ return p;
+}
+
+void folderlist_popdir(struct ListBase* folderlist, const char *dir)
+{
+ const char *prev_dir;
+ struct FolderList *folder;
+ folder = folderlist->last;
+
+ if(folder){
+ // remove the current directory
+ MEM_freeN(folder->foldername);
+ BLI_freelinkN(folderlist, folder);
+
+ folder = folderlist->last;
+ if(folder){
+ prev_dir = folder->foldername;
+ BLI_strncpy(dir, prev_dir, FILE_MAXDIR);
+ }
+ }
+ // delete the folder next or use setdir directly before PREVIOUS OP
+}
+
+void folderlist_pushdir(ListBase* folderlist, const char *dir)
+{
+ struct FolderList *folder, *previous_folder;
+ previous_folder = folderlist->last;
+
+ // check if already exists
+ if(previous_folder){
+ if(! strcmp(previous_folder->foldername, dir)){
+ return;
+ }
+ }
+
+ // create next folder element
+ folder = (FolderList*)MEM_mallocN(sizeof(FolderList),"FolderList");
+ folder->foldername = (char*)MEM_mallocN(sizeof(char)*(strlen(dir)+1), "foldername");
+ folder->foldername[0] = '\0';
+
+ BLI_strncpy(folder->foldername, dir, FILE_MAXDIR);
+
+ // add it to the end of the list
+ BLI_addtail(folderlist, folder);
+}
+
+int folderlist_clear_next(struct SpaceFile *sfile)
+{
+ struct FolderList *folder;
+
+ // if there is no folder_next there is nothing we can clear
+ if (!sfile->folders_next)
+ return 0;
+
+ // if previous_folder, next_folder or refresh_folder operators are executed it doesn't clear folder_next
+ folder = sfile->folders_prev->last;
+ if ((!folder) ||(!strcmp(folder->foldername, sfile->params->dir)))
+ return 0;
+
+ // eventually clear flist->folders_next
+ return 1;
+}
+
+void folderlist_free(ListBase* folderlist)
+{
+ FolderList *folder;
+ if (folderlist){
+ for(folder= folderlist->last; folder; folder= folderlist->last) {
+ MEM_freeN(folder->foldername);
+ BLI_freelinkN(folderlist, folder);
+ }
+ }
+ folderlist= NULL;
+}
+
+//------------------FILELIST------------------------//
struct FileList* filelist_new()
{
FileList* p = MEM_callocN( sizeof(FileList), "filelist" );
@@ -375,7 +461,7 @@ void filelist_free(struct FileList* filelist)
int i;
if (!filelist) {
- printf("Attemtping to delete empty filelist.\n");
+ printf("Attempting to delete empty filelist.\n");
return;
}