Index: NSSavePanel.m =================================================================== RCS file: /cvsroot/gnustep/gnustep/core/gui/Source/NSSavePanel.m,v retrieving revision 1.77 diff -u -r1.77 NSSavePanel.m --- NSSavePanel.m 28 Oct 2003 20:27:54 -0000 1.77 +++ NSSavePanel.m 11 Jan 2004 00:31:21 -0000 @@ -532,6 +532,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 isEqual: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"]; +} + - (void) _windowResized: (NSNotification*)n { [_browser setMaxVisibleColumns: [_browser frame].size.width / 140]; @@ -1031,6 +1092,8 @@ filename]); } + [self _storeVisitedFile:_fullFileName]; + filename = [_fullFileName stringByDeletingLastPathComponent]; if ([_fm fileExistsAtPath: filename isDirectory: &isDir] == NO) { @@ -1064,6 +1127,7 @@ ); return; } + if ([_fm fileExistsAtPath: [self filename] isDirectory: NULL]) { int result; @@ -1308,12 +1372,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; @@ -1454,6 +1525,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 Index: NSOpenPanel.m =================================================================== RCS file: /cvsroot/gnustep/gnustep/core/gui/Source/NSOpenPanel.m,v retrieving revision 1.40 diff -u -r1.40 NSOpenPanel.m --- NSOpenPanel.m 28 Oct 2003 16:52:14 -0000 1.40 +++ NSOpenPanel.m 11 Jan 2004 00:31:21 -0000 @@ -556,6 +556,8 @@ } } + [self _storeVisitedFile:_fullFileName]; + _OKButtonPressed = YES; [NSApp stopModal];