Index: NSOpenPanel.m =================================================================== RCS file: /cvsroot/gnustep/gnustep/core/gui/Source/NSOpenPanel.m,v retrieving revision 1.35 diff -u -r1.35 NSOpenPanel.m --- NSOpenPanel.m 26 Nov 2002 00:18:01 -0000 1.35 +++ NSOpenPanel.m 27 Mar 2003 21:53:38 -0000 @@ -534,6 +534,8 @@ } } + [self _storeVisitedFile:_fullFileName]; + _OKButtonPressed = YES; [NSApp stopModal]; [self close]; Index: NSSavePanel.m =================================================================== RCS file: /cvsroot/gnustep/gnustep/core/gui/Source/NSSavePanel.m,v retrieving revision 1.69 diff -u -r1.69 NSSavePanel.m --- NSSavePanel.m 26 Nov 2002 00:17:44 -0000 1.69 +++ NSSavePanel.m 27 Mar 2003 21:53:46 -0000 @@ -475,6 +475,67 @@ return YES; } +- (NSArray *)_visitedFilesAtPath:(NSString *)path +{ + NSUserDefaults *defs = [NSUserDefaults standardUserDefaults]; + NSArray *pathArray = [defs objectForKey:@"NSFilePanelHistory"]; + NSEnumerator *enumerator; + NSString *visitedPath; + NSMutableArray *array = [NSMutableArray array]; + int components = [[path pathComponents] count]; + + enumerator = [pathArray objectEnumerator]; + + while((visitedPath = [enumerator nextObject])) + { + if([visitedPath hasPrefix:path]) + { + visitedPath = [[visitedPath pathComponents] + objectAtIndex:components]; + [array addObject:visitedPath]; + } + } + + return [NSArray arrayWithArray:array]; +} + +- (void)_storeVisitedFile:(NSString *)fileName +{ + NSUserDefaults *defs = [NSUserDefaults standardUserDefaults]; + NSEnumerator *enumerator; + NSArray *array; + NSRange range = {0, 3}; + int visitedCount; + + if(![defs boolForKey:@"NSFilePanelFontifyHistory"]) + { + return; + } + + array = [defs objectForKey:@"NSFilePanelHistory"]; + array = [NSMutableArray arrayWithArray:array]; + + visitedCount = [defs integerForKey:@"NSFilePanelHistorySize"]; + + if(!visitedCount) + { + visitedCount = 10; + } + + if([array containsObject:fileName]) + { + /* Remove it and reinsert it at the beginning */ + [array removeObject:fileName]; + } + + [array insertObject:fileName atIndex:0]; + + range.length = MIN(visitedCount, [array count]); + array = [array subarrayWithRange:range]; + + [defs setObject:array forKey:@"NSFilePanelHistory"]; +} + @end /* NSSavePanel (PrivateMethods) */ // @@ -944,6 +1005,8 @@ ASSIGN (_fullFileName, [_directory stringByAppendingPathComponent: [[_form cellAtIndex: 0] stringValue]]); + [self _storeVisitedFile:_fullFileName]; + if ([_fm fileExistsAtPath: [self filename] isDirectory: NULL]) { int result; @@ -1192,12 +1255,19 @@ NSString *progressString = nil; /* We create lot of objects in this method, so we use a pool */ NSAutoreleasePool *pool; - - pool = [NSAutoreleasePool new]; + NSArray *visitedFiles = nil; + pool = [NSAutoreleasePool new]; + path = [_browser pathToColumn: column]; files = [[NSFileManager defaultManager] directoryContentsAtPath: path]; + if([[NSUserDefaults standardUserDefaults] + boolForKey:@"NSFilePanelFontifyHistory"]) + { + visitedFiles = [self _visitedFilesAtPath:path]; + } + /* Remove hidden files. */ { NSString *h; @@ -1338,6 +1408,14 @@ cell = [matrix cellAtRow: addedRows column: 0]; [cell setStringValue: file]; + if([visitedFiles containsObject:file]) + { + NSFont *font = [cell font]; + font = [[NSFontManager sharedFontManager] convertFont:font + toHaveTrait:NSBoldFontMask]; + [cell setFont:font]; + } + if (isDir) [cell setLeaf: NO]; else