diff --git a/ChangeLog b/ChangeLog index 7c1dfbbe..3ddb1935 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2005-04-22 17:15 Gregory John Casamento + + * GormCore/GormDocument.h: Changed signature. + * GormCore/GormDocument.m: Add another parameter on the new + method added previously. + * GormCore/GormObjectEditor.m: Get the ext to pass and call + changeToTopLevelEditorAcceptingTypes:andFileTypes: if the + type is NSFilenamePboardType. + * GormCore/GormResourceEditor.m: Get the ext to pass and call + changeToTopLevelEditorAcceptingTypes:andFileTypes: + 2005-04-22 15:57 Gregory John Casamento * GormCore/GormDocument.h: Added new method. diff --git a/GormCore/GormDocument.h b/GormCore/GormDocument.h index ca7318fe..b937debc 100644 --- a/GormCore/GormDocument.h +++ b/GormCore/GormDocument.h @@ -105,7 +105,8 @@ - (void) createResourceManagers; - (NSArray *) resourceManagers; - (IBResourceManager *) resourceManagerForPasteboard: (NSPasteboard *)pboard; -- (void) changeToTopLevelEditorAcceptingTypes: (NSArray *)types; +- (void) changeToTopLevelEditorAcceptingTypes: (NSArray *)types + andFileType: (NSString *)fileType; /* Managing classes */ - (GormClassManager*) classManager; diff --git a/GormCore/GormDocument.m b/GormCore/GormDocument.m index b7dc2767..6b2923bc 100644 --- a/GormCore/GormDocument.m +++ b/GormCore/GormDocument.m @@ -813,23 +813,29 @@ static NSImage *fileImage = nil; } - (void) changeToTopLevelEditorAcceptingTypes: (NSArray *)types + andFileType: (NSString *)fileType { if([objectsView acceptsTypeFromArray: types]) { [self changeToViewWithTag: 0]; } - else if([imagesView acceptsTypeFromArray: types]) + else if([imagesView acceptsTypeFromArray: types] && + [[imagesView fileTypes] containsObject: fileType]) { [self changeToViewWithTag: 1]; } - else if([soundsView acceptsTypeFromArray: types]) + else if([soundsView acceptsTypeFromArray: types] && + [[soundsView fileTypes] containsObject: fileType]) { [self changeToViewWithTag: 2]; } - else if([classesView acceptsTypeFromArray: types]) + /* + else if([classesView acceptsTypeFromArray: types] && + [[classesView fileTypes] containsObject: fileType]) { [self changeToViewWithTag: 3]; } + */ } /** diff --git a/GormCore/GormObjectEditor.m b/GormCore/GormObjectEditor.m index a1c19bf5..1f8550b3 100644 --- a/GormCore/GormObjectEditor.m +++ b/GormCore/GormObjectEditor.m @@ -232,9 +232,18 @@ static NSMapTable *docMap = 0; { dragType = GormLinkPboardType; } + else if ([pbTypes containsObject: NSFilenamesPboardType] == YES) + { + NSArray *data = [dragPb propertyListForType: NSFilenamesPboardType]; + NSString *fileName = [data objectAtIndex: 0]; + NSString *ext = [fileName pathExtension]; + + [(GormDocument *)document changeToTopLevelEditorAcceptingTypes: pbTypes + andFileType: ext]; + dragType = nil; + } else { - [(GormDocument *)document changeToTopLevelEditorAcceptingTypes: pbTypes]; dragType = nil; } @@ -289,7 +298,8 @@ static NSMapTable *docMap = 0; - (void) _registerForAllResourceManagers { - NSMutableArray *allTypes = [[NSMutableArray alloc] initWithObjects: GormLinkPboardType, nil]; + NSMutableArray *allTypes = [[NSMutableArray alloc] initWithObjects: NSFilenamesPboardType, + GormLinkPboardType, nil]; NSArray *mgrs = [(GormDocument *)document resourceManagers]; NSEnumerator *en = [mgrs objectEnumerator]; IBResourceManager *mgr = nil; diff --git a/GormCore/GormResourceEditor.m b/GormCore/GormResourceEditor.m index 60dd3bf6..9e41f921 100644 --- a/GormCore/GormResourceEditor.m +++ b/GormCore/GormResourceEditor.m @@ -60,6 +60,8 @@ static int handled_mask= NSDragOperationCopy | NSDragOperationGeneric | NSDragOp NSPasteboard *pb = [sender draggingPasteboard]; NSArray *pbTypes = [pb types]; unsigned int mask = [sender draggingSourceOperationMask]; + unsigned int oper = NSDragOperationNone; + NSString *ext = nil; if ((mask & handled_mask) && [pbTypes containsObject: NSFilenamesPboardType]) { @@ -77,25 +79,27 @@ static int handled_mask= NSDragOperationCopy | NSDragOperationGeneric | NSDragOp en = [data objectEnumerator]; while((fileName = (NSString *)[en nextObject]) != nil) { - NSString *ext = [fileName pathExtension]; + ext = [fileName pathExtension]; if([types containsObject: ext] == YES) { - return NSDragOperationCopy; + oper = NSDragOperationCopy; + break; } else { - return NSDragOperationNone; + oper = NSDragOperationNone; + break; } } - - return NSDragOperationCopy; } - else + + if(oper == NSDragOperationNone) { - [(GormDocument *)document changeToTopLevelEditorAcceptingTypes: pbTypes]; + [(GormDocument *)document changeToTopLevelEditorAcceptingTypes: pbTypes + andFileType: ext]; } - return NSDragOperationNone; + return oper; } - (unsigned int) draggingUpdated: (id)sender