diff --git a/source/blender/blenkernel/BKE_global.h b/source/blender/blenkernel/BKE_global.h index 29874fb05c5..fe48f88044e 100644 --- a/source/blender/blenkernel/BKE_global.h +++ b/source/blender/blenkernel/BKE_global.h @@ -87,6 +87,8 @@ typedef struct Global { /* strings: lastsaved */ char ima[160], sce[160], lib[160]; + + char recent[10][160]; /* totals */ short totobj, totlamp, totobjsel, totcurve, totmesh; diff --git a/source/blender/src/toets.c b/source/blender/src/toets.c index b043bc85370..463fe8ea6ef 100644 --- a/source/blender/src/toets.c +++ b/source/blender/src/toets.c @@ -352,6 +352,32 @@ int untitled(char * name) return(FALSE); } +char *recent_filelist(void) +{ + int event, i, ofs; + char pup[2048], *p; + + p= pup + sprintf(pup, "Open recent%%t"); + + if (G.sce[0]) { + p+= sprintf(p, "|%s %%x%d", G.sce, 1); + ofs = 1; + } else ofs = 0; + for (i=0; i<10 && (G.recent[i][0]); i++) { + if (strcmp(G.recent[i], G.sce)) { + p+= sprintf(p, "|%s %%x%d", G.recent[i], i+ofs+1); + } + } + event= pupmenu(pup); + if(event>0) { + if (ofs && (event==1)) + return(G.sce); + else + return(G.recent[event-1-ofs]); + } + else + return(NULL); +} int blenderqread(unsigned short event, short val) { @@ -365,6 +391,7 @@ int blenderqread(unsigned short event, short val) /* Changed str and dir size to 160, to make sure there is enough * space for filenames. */ char dir[FILE_MAXDIR * 2], str[FILE_MAXFILE * 2]; + char *recentfile; if(val==0) return 1; if(event==MOUSEY || event==MOUSEX) return 1; @@ -720,14 +747,9 @@ int blenderqread(unsigned short event, short val) case OKEY: if(textediting==0) { if(G.qual==LR_CTRLKEY) { - /* There seem to be crashes here sometimes.... String - * bound overwrites? I changed dir and str sizes, - * let's see if this reoccurs. */ - sprintf(str, "Open file: %s", G.sce); - - if(okee(str)) { - strcpy(dir, G.sce); - BIF_read_file(dir); + recentfile = recent_filelist(); + if(recentfile) { + BIF_read_file(recentfile); } return 0; } diff --git a/source/blender/src/usiblender.c b/source/blender/src/usiblender.c index ccc32c33a6e..0560b963c9c 100644 --- a/source/blender/src/usiblender.c +++ b/source/blender/src/usiblender.c @@ -461,14 +461,22 @@ static void readBlog(void) { char name[FILE_MAXDIR+FILE_MAXFILE], filename[FILE_MAXFILE]; LinkNode *l, *lines; + char *line; + int num; BLI_make_file_string("/", name, BLI_gethome(), ".Blog"); lines= BLI_read_file_as_lines(name); - if (lines && !BLI_streq(lines->link, "")) { - strcpy(G.sce, lines->link); - } else { - BLI_make_file_string("/", G.sce, BLI_gethome(), "untitled.blend"); + for (num= 0; num<10; num++) G.recent[num][0]=0; + for (l= lines, num= 0; l && (num<10); l= l->next, num++) { + line = l->link; + if (!BLI_streq(line, "")) { + if (num==0) strcpy(G.sce, line); + strcpy(G.recent[num], line); + } else { +// BLI_make_file_string("/", G.sce, BLI_gethome(), "untitled.blend"); + G.sce[0] = 0; + } } BLI_free_file_lines(lines); @@ -531,12 +539,19 @@ static void writeBlog(void) { char name[FILE_MAXDIR+FILE_MAXFILE]; FILE *fp; + int i, num; BLI_make_file_string("/", name, BLI_gethome(), ".Blog"); fp= fopen(name, "w"); if (fp) { - fprintf(fp, G.sce); + for (i=0, num=0; (num<10) && (G.recent[i][0]); i++, num++) { + if (i==0) { + fprintf(fp, "%s\n", G.sce); + num++; + } + if (strcmp(G.recent[i], G.sce)) fprintf(fp, "%s\n", G.recent[i]); + } fclose(fp); } }