Corrected NSSavePanel file display filtering to handle case where _requiredFileType is nil or empty string by accepting any extension.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@20608 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Adrian Robert 2005-01-24 05:26:15 +00:00
parent 27333c9d4c
commit a2a12020db
2 changed files with 23 additions and 8 deletions

View file

@ -1,3 +1,12 @@
2005-01-24 Adrian Robert <arobert@cogsci.ucsd.edu>
* Source/NSSavePanel.m (-_shouldShowExtension:isDir:,
-setRequiredFileType:, -requiredFileType, -filename): For filename
display filtering, handle case where _requiredFileType is unset or
set to nil or "" by allowing any extension (including none), as
specified in Apple docs, instead of allowing no extensions, as it
was. Document.
2005-01-24 00:48 Alexander Malmberg <alexander@malmberg.org>
* Source/NSImageCell.m (-drawInteriorWithFrame:inView:): Draw
@ -5,6 +14,7 @@
bug #11712.
2005-01-22 Adrian Robert <arobert@cogsci.ucsd.edu>
* Source/NSFontManager.m (-fontWithFamily:traits:weight:size:)
Corrected logic in fallback approximate trait search for weight 5 or 6
(regular) fonts. Font w/approximate traits but originally-requested

View file

@ -524,7 +524,8 @@ selectCellWithString: (NSString*)title
{
if (*isDir == NO)
{
if ([extension isEqualToString: _requiredFileType] == NO)
if (_requiredFileType != nil && [_requiredFileType length] != 0
&& [extension isEqualToString: _requiredFileType] == NO)
return NO;
}
else if ([extension length] == 0)
@ -533,7 +534,8 @@ selectCellWithString: (NSString*)title
}
else if (_treatsFilePackagesAsDirectories == NO)
{
if ([extension isEqualToString: _requiredFileType] == YES)
if (_requiredFileType == nil || [_requiredFileType length] == 0
|| [extension isEqualToString: _requiredFileType] == YES)
*isDir = NO;
}
@ -856,14 +858,20 @@ selectCellWithString: (NSString*)title
* any selected files that don't already have that extension;
* The argument type should not include the period that begins
* the extension. Invoke this method each time the Save panel
* is used for another file type within the application.
* is used for another file type within the application. If
* you do not invoke it, or set it to empty string or nil, no
* extension will be appended, indicated by an empty string
* returned from -requiredFileType .
*/
- (void) setRequiredFileType: (NSString*)fileType
{
ASSIGN(_requiredFileType, fileType);
}
/** Returns the required file type. The default is no required file type. */
/**
* Returns the required file type. The default, indicated by empty string,
* is no required file type.
*/
- (NSString*) requiredFileType
{
return _requiredFileType;
@ -1008,12 +1016,9 @@ selectCellWithString: (NSString*)title
if (_fullFileName == nil)
return @"";
if (_requiredFileType == nil)
if (_requiredFileType == nil || [_requiredFileType isEqual: @""] == YES)
return _fullFileName;
if ([_requiredFileType isEqual: @""] == YES)
return _fullFileName;
// add filetype extension only if the filename does not include it already
if ([[_fullFileName pathExtension] isEqual: _requiredFileType] == YES)
return _fullFileName;