mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-05-21 03:01:13 +00:00
Add support for document types with a wild card extension to
NSDocumentController and NSDocument. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@30512 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
79ac03cdf1
commit
fc76fad1a0
3 changed files with 38 additions and 4 deletions
|
@ -769,7 +769,7 @@ TypeInfoForHumanReadableName (NSArray *types, NSString *typeName)
|
|||
[array addObjectsFromArray: [typeInfo objectForKey: CFBundleTypeExtensions]];
|
||||
}
|
||||
|
||||
return array;
|
||||
return [array containsObject: @"*"] == NO ? (NSArray *)array : (NSArray *)nil;
|
||||
}
|
||||
|
||||
/** Uses -runModalOpenPanel:forTypes: to allow the user to select
|
||||
|
@ -1215,7 +1215,8 @@ static BOOL _shouldClose = YES;
|
|||
- (NSString *) typeFromFileExtension: (NSString *)fileExtension
|
||||
{
|
||||
int i, count = [_types count];
|
||||
|
||||
|
||||
// Check for a document type with the supplied extension
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
NSDictionary *typeInfo = [_types objectAtIndex: i];
|
||||
|
@ -1236,7 +1237,28 @@ static BOOL _shouldClose = YES;
|
|||
return type;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// No exact match; check for a document type that supports any extension
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
NSDictionary *typeInfo = [_types objectAtIndex: i];
|
||||
|
||||
if ([[typeInfo objectForKey: NSUnixExtensionsKey] containsObject: @"*"]
|
||||
|| [[typeInfo objectForKey: NSDOSExtensionsKey] containsObject: @"*"]
|
||||
|| [[typeInfo objectForKey: CFBundleTypeExtensions]
|
||||
containsObject: @"*"])
|
||||
{
|
||||
NSString *type = [typeInfo objectForKey: NSNameKey];
|
||||
|
||||
if (type == nil)
|
||||
{
|
||||
type = [typeInfo objectForKey: CFBundleTypeName];
|
||||
}
|
||||
return type;
|
||||
}
|
||||
}
|
||||
|
||||
// No luck
|
||||
return nil;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue