mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-23 15:11:37 +00:00
Change the extension of the file name entered into a NSSavePanel's
text form when the set of allowed file types is changed and the current extension is no longer allowed. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@27266 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
ea51783cbb
commit
239a9af20a
2 changed files with 24 additions and 0 deletions
|
@ -1,3 +1,8 @@
|
|||
2008-12-09 Wolfgang Lux <wolfgang.lux@gmail.com>
|
||||
|
||||
* Source/NSSavePanel.m (-setAllowedFileTypes:): Change extension
|
||||
of the file name if the current extension is no longer allowed.
|
||||
|
||||
2008-12-08 Fred Kiefer <FredKiefer@gmx.de>
|
||||
|
||||
* Headers/AppKit/NSTextFieldCell.h: Declare new private method
|
||||
|
|
|
@ -965,11 +965,30 @@ selectCellWithString: (NSString*)title
|
|||
{
|
||||
if (types != _allowedFileTypes)
|
||||
{
|
||||
BOOL hasAllowedExtension = NO;
|
||||
NSString *filename, *extension;
|
||||
|
||||
filename = [[_form cellAtIndex: 0] stringValue];
|
||||
extension = [filename pathExtension];
|
||||
if ([extension length] && [_allowedFileTypes count] &&
|
||||
[_allowedFileTypes indexOfObject: extension] != NSNotFound)
|
||||
hasAllowedExtension = YES;
|
||||
|
||||
if ([types count] == 0)
|
||||
DESTROY(_allowedFileTypes);
|
||||
else
|
||||
ASSIGN(_allowedFileTypes, types);
|
||||
[self _reloadBrowser];
|
||||
|
||||
if (hasAllowedExtension && [types count] &&
|
||||
[types indexOfObject: extension] == NSNotFound &&
|
||||
[types indexOfObject: @""] == NSNotFound)
|
||||
{
|
||||
extension = [types objectAtIndex: 0];
|
||||
filename = [filename stringByDeletingPathExtension];
|
||||
filename = [filename stringByAppendingPathExtension: extension];
|
||||
[[_form cellAtIndex: 0] setStringValue: filename];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue