mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-05-30 13:50:37 +00:00
* Headers/AppKit/NSTokenFieldCell.h
* Headers/AppKit/NSTokenField.h: Headers for new class. * Source/GNUmakefile * Source/NSDocumentController.m: Added code to handle the CF keys as well as the NS keys for document oriented apps. * Source/NSTokenFieldCell.m * Source/NSTokenField.m: Start of implementation for this class git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@26801 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
fb69a9fd22
commit
975469ff71
7 changed files with 452 additions and 6 deletions
|
@ -54,6 +54,11 @@ static NSString *NSDOSExtensionsKey = @"NSDOSExtensions";
|
|||
//static NSString *NSMIMETypesKey = @"NSMIMETypes";
|
||||
static NSString *NSDocumentClassKey = @"NSDocumentClass";
|
||||
|
||||
static NSString *CFBundleDocumentTypes = @"CFBundleDocumentTypes";
|
||||
static NSString *CFBundleTypeExtensions = @"CFBundleTypeExtensions";
|
||||
static NSString *CFBundleTypeName = @"CFBundleTypeName";
|
||||
static NSString *CFBundleTypeRole = @"CFBundleTypeRole";
|
||||
|
||||
static NSString *NSRecentDocuments = @"NSRecentDocuments";
|
||||
static NSString *NSDefaultOpenDirectory = @"NSDefaultOpenDirectory";
|
||||
|
||||
|
@ -73,6 +78,10 @@ static NSDictionary *TypeInfoForName (NSArray *types, NSString *typeName)
|
|||
{
|
||||
return dict;
|
||||
}
|
||||
else if ([[dict objectForKey: CFBundleTypeName] isEqualToString: typeName])
|
||||
{
|
||||
return dict;
|
||||
}
|
||||
}
|
||||
|
||||
return nil;
|
||||
|
@ -89,6 +98,10 @@ static NSDictionary *TypeInfoForHumanReadableName (NSArray *types, NSString *typ
|
|||
{
|
||||
return dict;
|
||||
}
|
||||
else if ([[dict objectForKey: CFBundleTypeName] isEqualToString: typeName])
|
||||
{
|
||||
return dict;
|
||||
}
|
||||
}
|
||||
|
||||
return nil;
|
||||
|
@ -156,8 +169,9 @@ static NSDictionary *TypeInfoForHumanReadableName (NSArray *types, NSString *typ
|
|||
*/
|
||||
+ (BOOL) isDocumentBasedApplication
|
||||
{
|
||||
return ([[[NSBundle mainBundle] infoDictionary] objectForKey: NSTypesKey])
|
||||
? YES : NO;
|
||||
return ([[[NSBundle mainBundle] infoDictionary] objectForKey: NSTypesKey] ||
|
||||
[[[NSBundle mainBundle] infoDictionary] objectForKey: CFBundleDocumentTypes])
|
||||
? YES : NO;
|
||||
}
|
||||
|
||||
/** </init>Initializes the document controller class. The first
|
||||
|
@ -169,6 +183,12 @@ static NSDictionary *TypeInfoForHumanReadableName (NSArray *types, NSString *typ
|
|||
NSDictionary *customDict = [[NSBundle mainBundle] infoDictionary];
|
||||
|
||||
ASSIGN (_types, [customDict objectForKey: NSTypesKey]);
|
||||
|
||||
if(_types == nil)
|
||||
{
|
||||
ASSIGN(_types, [customDict objectForKey: CFBundleDocumentTypes]);
|
||||
}
|
||||
|
||||
_documents = [[NSMutableArray alloc] init];
|
||||
|
||||
/* Get list of recent documents */
|
||||
|
@ -344,12 +364,19 @@ static NSDictionary *TypeInfoForHumanReadableName (NSArray *types, NSString *typ
|
|||
|
||||
- (NSString*) defaultType
|
||||
{
|
||||
NSString *defaultName = nil;
|
||||
if ([_types count] == 0)
|
||||
{
|
||||
return nil; // raise exception?
|
||||
}
|
||||
|
||||
return [(NSDictionary*)[_types objectAtIndex: 0] objectForKey: NSNameKey];
|
||||
defaultName = [(NSDictionary*)[_types objectAtIndex: 0] objectForKey: NSNameKey];
|
||||
if(defaultName == nil)
|
||||
{
|
||||
defaultName = [(NSDictionary*)[_types objectAtIndex: 0] objectForKey: CFBundleTypeName];
|
||||
}
|
||||
|
||||
return defaultName;
|
||||
}
|
||||
|
||||
- (void) addDocument: (NSDocument *)document
|
||||
|
@ -577,6 +604,7 @@ static NSDictionary *TypeInfoForHumanReadableName (NSArray *types, NSString *typ
|
|||
NSDictionary *typeInfo = [_types objectAtIndex: i];
|
||||
[array addObjectsFromArray: [typeInfo objectForKey: NSUnixExtensionsKey]];
|
||||
[array addObjectsFromArray: [typeInfo objectForKey: NSDOSExtensionsKey]];
|
||||
[array addObjectsFromArray: [typeInfo objectForKey: CFBundleTypeExtensions]];
|
||||
}
|
||||
|
||||
return array;
|
||||
|
@ -943,9 +971,16 @@ static NSDictionary *TypeInfoForHumanReadableName (NSArray *types, NSString *typ
|
|||
if ([[typeInfo objectForKey:NSUnixExtensionsKey]
|
||||
containsObject: fileExtension] ||
|
||||
[[typeInfo objectForKey:NSDOSExtensionsKey]
|
||||
containsObject: fileExtension] ||
|
||||
[[typeInfo objectForKey:CFBundleTypeExtensions]
|
||||
containsObject: fileExtension])
|
||||
{
|
||||
return [typeInfo objectForKey: NSNameKey];
|
||||
NSString *type = [typeInfo objectForKey: NSNameKey];
|
||||
if(type == nil)
|
||||
{
|
||||
type = [typeInfo objectForKey: CFBundleTypeName];
|
||||
}
|
||||
return type;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1072,12 +1107,23 @@ static NSString *NSViewerRole = @"Viewer";
|
|||
NSString *className = [typeInfo objectForKey: NSDocumentClassKey];
|
||||
NSString *role = [typeInfo objectForKey: NSRoleKey];
|
||||
|
||||
// if the standard one isn't filled... check the CF key.
|
||||
if(role == nil)
|
||||
{
|
||||
role = [typeInfo objectForKey: CFBundleTypeRole];
|
||||
}
|
||||
|
||||
if ([docClassName isEqualToString: className]
|
||||
&& (role == nil
|
||||
|| [role isEqual: NSEditorRole]
|
||||
|| [role isEqual: NSViewerRole]))
|
||||
{
|
||||
[types addObject: [typeInfo objectForKey: NSNameKey]];
|
||||
NSString *name = [typeInfo objectForKey: NSNameKey];
|
||||
if(name == nil)
|
||||
{
|
||||
name = [typeInfo objectForKey: CFBundleTypeName];
|
||||
}
|
||||
[types addObject: name];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1099,7 +1145,12 @@ static NSString *NSViewerRole = @"Viewer";
|
|||
if ([docClassName isEqualToString: className] &&
|
||||
(role == nil || [role isEqual: NSEditorRole]))
|
||||
{
|
||||
[types addObject: [typeInfo objectForKey: NSNameKey]];
|
||||
NSString *name = [typeInfo objectForKey: NSNameKey];
|
||||
if(name == nil)
|
||||
{
|
||||
name = [typeInfo objectForKey: CFBundleTypeName];
|
||||
}
|
||||
[types addObject: name];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue