mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-06-01 09:42:11 +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
ab99ab06c6
commit
bed8731d61
3 changed files with 38 additions and 4 deletions
|
@ -1,3 +1,11 @@
|
||||||
|
2010-05-31 Wolfgang Lux <wolfgang.lux@gmail.com>
|
||||||
|
|
||||||
|
* Source/NSDocumentController.m (-_openableFileExtensions,
|
||||||
|
-typeFromFileExtension:):
|
||||||
|
* Source/NSDocument.m (-_runSavePanelForSaveOperation:,
|
||||||
|
-changeSaveType:, -fileNameExtensionForType:saveOperation:):
|
||||||
|
Implement support for document types with a wild card extension.
|
||||||
|
|
||||||
2010-05-31 David Wetzel <dave@turbocat.de>
|
2010-05-31 David Wetzel <dave@turbocat.de>
|
||||||
* Source/NSViewController.m
|
* Source/NSViewController.m
|
||||||
* Headers/AppKit/NSViewController.h
|
* Headers/AppKit/NSViewController.h
|
||||||
|
|
|
@ -1052,6 +1052,8 @@ originalContentsURL: (NSURL *)orig
|
||||||
|
|
||||||
ASSIGN(_save_type, [[sender selectedItem] representedObject]);
|
ASSIGN(_save_type, [[sender selectedItem] representedObject]);
|
||||||
extensions = [controller fileExtensionsFromType: _save_type];
|
extensions = [controller fileExtensionsFromType: _save_type];
|
||||||
|
if ([extensions containsObject: @"*"])
|
||||||
|
extensions = nil;
|
||||||
[(NSSavePanel *)[sender window] setAllowedFileTypes: extensions];
|
[(NSSavePanel *)[sender window] setAllowedFileTypes: extensions];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1157,6 +1159,8 @@ originalContentsURL: (NSURL *)orig
|
||||||
if ([types count] > 0)
|
if ([types count] > 0)
|
||||||
{
|
{
|
||||||
NSArray *extensions = [controller fileExtensionsFromType: [self fileType]];
|
NSArray *extensions = [controller fileExtensionsFromType: [self fileType]];
|
||||||
|
if ([extensions containsObject: @"*"])
|
||||||
|
extensions = nil;
|
||||||
[savePanel setAllowedFileTypes: extensions];
|
[savePanel setAllowedFileTypes: extensions];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1272,7 +1276,7 @@ originalContentsURL: (NSURL *)orig
|
||||||
NSArray *exts = [[NSDocumentController sharedDocumentController]
|
NSArray *exts = [[NSDocumentController sharedDocumentController]
|
||||||
fileExtensionsFromType: typeName];
|
fileExtensionsFromType: typeName];
|
||||||
|
|
||||||
if ([exts count])
|
if ([exts count] && ![exts containsObject: @"*"])
|
||||||
return (NSString *)[exts objectAtIndex: 0];
|
return (NSString *)[exts objectAtIndex: 0];
|
||||||
|
|
||||||
return @"";
|
return @"";
|
||||||
|
|
|
@ -769,7 +769,7 @@ TypeInfoForHumanReadableName (NSArray *types, NSString *typeName)
|
||||||
[array addObjectsFromArray: [typeInfo objectForKey: CFBundleTypeExtensions]];
|
[array addObjectsFromArray: [typeInfo objectForKey: CFBundleTypeExtensions]];
|
||||||
}
|
}
|
||||||
|
|
||||||
return array;
|
return [array containsObject: @"*"] == NO ? (NSArray *)array : (NSArray *)nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Uses -runModalOpenPanel:forTypes: to allow the user to select
|
/** Uses -runModalOpenPanel:forTypes: to allow the user to select
|
||||||
|
@ -1215,7 +1215,8 @@ static BOOL _shouldClose = YES;
|
||||||
- (NSString *) typeFromFileExtension: (NSString *)fileExtension
|
- (NSString *) typeFromFileExtension: (NSString *)fileExtension
|
||||||
{
|
{
|
||||||
int i, count = [_types count];
|
int i, count = [_types count];
|
||||||
|
|
||||||
|
// Check for a document type with the supplied extension
|
||||||
for (i = 0; i < count; i++)
|
for (i = 0; i < count; i++)
|
||||||
{
|
{
|
||||||
NSDictionary *typeInfo = [_types objectAtIndex: i];
|
NSDictionary *typeInfo = [_types objectAtIndex: i];
|
||||||
|
@ -1236,7 +1237,28 @@ static BOOL _shouldClose = YES;
|
||||||
return type;
|
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;
|
return nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue