NSSavePanel and NSOpenPanel now use the information provided by

NSWorkspace in order to identify file packages.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@27232 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Wolfgang Lux 2008-12-06 19:05:38 +00:00
parent 290b38361d
commit 978d3ef1fb
3 changed files with 28 additions and 46 deletions

View file

@ -1,3 +1,11 @@
2008-12-06 Wolfgang Lux <wolfgang.lux@gmail.com>
* Source/NSSavePanel.m (-_shouldShowExtension:isDir:,
-browser:createRowsForColumn:inMatrix:):
* Source/NSOpenPanel.m (-_shouldShowExtension:isDir:): The panels
now use the information provided by NSWorkspace in order to
identify file packages.
2008-12-06 Wolfgang Lux <wolfgang.lux@gmail.com>
* Source/NSSavePanel.m (-_reloadBrowser:, -setRequiredFileType:,

View file

@ -79,7 +79,7 @@ static NSOpenPanel *_gs_gui_open_panel = nil;
- (void) _selectTextInColumn: (int)column;
- (void) _setupForDirectory: (NSString *)path file: (NSString *)filename;
- (void) _setupForTypes: (NSArray *)fileTypes; /* I'm cheating here... */
- (BOOL) _shouldShowExtension: (NSString *)extension isDir: (BOOL *)isDir;
- (BOOL) _shouldShowExtension: (NSString *)extension;
- (NSComparisonResult) _compareFilename: (NSString *)n1 with: (NSString *)n2;
@end
@ -95,29 +95,12 @@ static NSOpenPanel *_gs_gui_open_panel = nil;
}
- (BOOL) _shouldShowExtension: (NSString *)extension
isDir: (BOOL *)isDir;
{
BOOL found = YES;
if (_canChooseFiles == NO ||
(_fileTypes != nil && [_fileTypes containsObject: extension] == NO))
return NO;
if (_fileTypes != nil)
{
if ([_fileTypes containsObject: extension] == YES)
{
if ([self treatsFilePackagesAsDirectories] == NO)
{
*isDir = NO;
}
}
else
{
found = NO;
}
}
if (*isDir == YES || (found == YES && _canChooseFiles == YES))
return YES;
return NO;
return YES;
}
- (void) _selectTextInColumn: (int)column

View file

@ -118,7 +118,7 @@ setPath(NSBrowser *browser, NSString *path)
- (void) _selectTextInColumn: (int)column;
- (void) _selectCellName: (NSString *)title;
- (void) _setupForDirectory: (NSString *)path file: (NSString *)name;
- (BOOL) _shouldShowExtension: (NSString *)extension isDir: (BOOL *)isDir;
- (BOOL) _shouldShowExtension: (NSString *)extension;
- (void) _windowResized: (NSNotification*)n;
- (NSComparisonResult) _compareFilename: (NSString *)n1 with: (NSString *)n2;
@end /* NSSavePanel (PrivateMethods) */
@ -592,25 +592,11 @@ selectCellWithString: (NSString*)title
}
- (BOOL) _shouldShowExtension: (NSString *)extension
isDir: (BOOL *)isDir;
{
if (*isDir == NO)
{
if (_allowedFileTypes != nil
&& [_allowedFileTypes indexOfObject: extension] == NSNotFound
&& [_allowedFileTypes indexOfObject: @""] == NSNotFound)
return NO;
}
else if ([extension length] == 0)
{
/* Automatic YES */
}
else if (_treatsFilePackagesAsDirectories == NO)
{
if (_allowedFileTypes == nil
|| [_allowedFileTypes indexOfObject: extension] != NSNotFound)
*isDir = NO;
}
if (_allowedFileTypes != nil
&& [_allowedFileTypes indexOfObject: extension] == NSNotFound
&& [_allowedFileTypes indexOfObject: @""] == NSNotFound)
return NO;
return YES;
}
@ -1508,11 +1494,12 @@ createRowsForColumn: (int)column
unsigned base_frac = 1;
BOOL display_progress = NO;
NSString *progressString = nil;
NSWorkspace *ws;
/* We create lot of objects in this method, so we use a pool */
NSAutoreleasePool *pool;
pool = [NSAutoreleasePool new];
ws = [NSWorkspace sharedWorkspace];
path = pathToColumn(_browser, column);
#if defined(__MINGW32__)
if (column == 0)
@ -1520,7 +1507,7 @@ createRowsForColumn: (int)column
NSMutableArray *m;
unsigned i;
files = [[NSWorkspace sharedWorkspace] mountedLocalVolumePaths];
files = [ws mountedLocalVolumePaths];
m = [files mutableCopy];
i = [m count];
while (i-- > 0)
@ -1653,16 +1640,20 @@ createRowsForColumn: (int)column
pathAndFile = [path stringByAppendingPathComponent: file];
exists = [_fm fileExistsAtPath: pathAndFile
isDirectory: &isDir];
if (isDir && !_treatsFilePackagesAsDirectories
&& [ws isFilePackageAtPath: pathAndFile])
{
isDir = NO;
}
if (_delegateHasShowFilenameFilter)
{
exists = [_delegate panel: self
shouldShowFilename: pathAndFile];
}
if (exists)
if (exists && !isDir)
{
exists = [self _shouldShowExtension: extension isDir: &isDir];
exists = [self _shouldShowExtension: extension];
}
if (exists)