Corrections for IBResourceManager.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/apps/gorm/trunk@21084 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Gregory John Casamento 2005-04-11 04:05:30 +00:00
parent 99380cf45a
commit 1465667ceb
3 changed files with 54 additions and 36 deletions

View file

@ -1,3 +1,10 @@
2005-04-10 23:59 Gregory John Casamento <greg_casamento@yahoo.com>
* GormCore/GormDocument.m: Moved call to register IBResourceManager
here and also correct a memory problem.
* GormCore/GormObjectEditor.m: Corrected a problem with
registering the types.
2005-04-10 22:42 Gregory John Casamento <greg_casamento@yahoo.com> 2005-04-10 22:42 Gregory John Casamento <greg_casamento@yahoo.com>
* GormCore/GormFilePrefsManager.m * GormCore/GormFilePrefsManager.m

View file

@ -181,6 +181,9 @@ static NSImage *fileImage = nil;
fileImage = [[NSImage alloc] initWithContentsOfFile: path]; fileImage = [[NSImage alloc] initWithContentsOfFile: path];
} }
// create the resource manager...
[IBResourceManager registerResourceManagerClass: [IBResourceManager class]];
[self setVersion: GNUSTEP_NIB_VERSION]; [self setVersion: GNUSTEP_NIB_VERSION];
} }
} }
@ -259,6 +262,9 @@ static NSImage *fileImage = nil;
name: IBResourceManagerRegistryDidChangeNotification name: IBResourceManagerRegistryDidChangeNotification
object: nil]; object: nil];
// load resource managers
[self createResourceManagers];
// objects... // objects...
mainRect.origin = NSMakePoint(0,0); mainRect.origin = NSMakePoint(0,0);
scrollView = [[NSScrollView alloc] initWithFrame: scrollRect]; scrollView = [[NSScrollView alloc] initWithFrame: scrollRect];
@ -386,9 +392,6 @@ static NSImage *fileImage = nil;
// document is open... // document is open...
isDocumentOpen = YES; isDocumentOpen = YES;
// load resource managers
[self createResourceManagers];
} }
else else
{ {
@ -1262,7 +1265,7 @@ static NSImage *fileImage = nil;
id<IBConnectors> link; id<IBConnectors> link;
editor = [[eClass alloc] initWithObject: anObject inDocument: self]; editor = [[eClass alloc] initWithObject: anObject inDocument: self];
link = [GormObjectToEditor new]; link = AUTORELEASE([GormObjectToEditor new]);
[link setSource: anObject]; [link setSource: anObject];
[link setDestination: editor]; [link setDestination: editor];
[connections addObject: link]; [connections addObject: link];
@ -1272,7 +1275,6 @@ static NSImage *fileImage = nil;
[openEditors addObject: editor]; [openEditors addObject: editor];
} }
RELEASE(link);
if (anEditor == nil) if (anEditor == nil)
{ {
/* /*
@ -1286,11 +1288,10 @@ static NSImage *fileImage = nil;
/* /*
* Link to the parent of the editor. * Link to the parent of the editor.
*/ */
link = [GormEditorToParent new]; link = AUTORELEASE([GormEditorToParent new]);
[link setSource: editor]; [link setSource: editor];
[link setDestination: anEditor]; [link setDestination: anEditor];
[connections addObject: link]; [connections addObject: link];
RELEASE(link);
} }
else else
{ {
@ -1298,6 +1299,7 @@ static NSImage *fileImage = nil;
} }
[editor activate]; [editor activate];
RELEASE((NSObject *)editor); RELEASE((NSObject *)editor);
return editor; return editor;
} }
else if ([links count] == 0) else if ([links count] == 0)
@ -2261,8 +2263,9 @@ static NSImage *fileImage = nil;
else else
{ {
NSEnumerator *enumerator = [objects objectEnumerator]; NSEnumerator *enumerator = [objects objectEnumerator];
id obj;
NSRect frame; NSRect frame;
id obj;
while ((obj = [enumerator nextObject]) != nil) while ((obj = [enumerator nextObject]) != nil)
{ {
// check to see if the object has a frame. If so, then // check to see if the object has a frame. If so, then
@ -2526,7 +2529,7 @@ static NSImage *fileImage = nil;
} }
// nameCopy = [aName copy]; /* Make sure it's immutable */ // nameCopy = [aName copy]; /* Make sure it's immutable */
[nameTable setObject: object forKey: aName]; [nameTable setObject: object forKey: aName];
RELEASE(object); // make sure that when it's removed from the table, it's released. // RELEASE(object); // TODO: Make sure whether we do or do not need this.
NSMapInsert(objToName, (void*)object, (void*) aName); //nameCopy); NSMapInsert(objToName, (void*)object, (void*) aName); //nameCopy);
if (oldName != nil) if (oldName != nil)
{ {
@ -2548,7 +2551,6 @@ static NSImage *fileImage = nil;
[cc setObject: className forKey: aName]; //nameCopy]; [cc setObject: className forKey: aName]; //nameCopy];
} }
} }
// RELEASE(nameCopy); // release the copy of the name which we made...
} }
- (void) setObject: (id)anObject isVisibleAtLaunch: (BOOL)flag - (void) setObject: (id)anObject isVisibleAtLaunch: (BOOL)flag

View file

@ -90,9 +90,6 @@ static NSMapTable *docMap = 0;
docMap = NSCreateMapTable(NSObjectMapKeyCallBacks, docMap = NSCreateMapTable(NSObjectMapKeyCallBacks,
NSObjectMapValueCallBacks, NSObjectMapValueCallBacks,
2); 2);
// create the resource manager...
[IBResourceManager registerResourceManagerClass: [IBResourceManager class]];
} }
} }
@ -124,16 +121,12 @@ static NSMapTable *docMap = 0;
- (void) pasteInSelection - (void) pasteInSelection
{ {
// not implemented
} }
- (void) copySelection - (void) copySelection
{ {
if (selected != nil) // not implemented
{
[document copyObjects: [self selection]
type: IBObjectPboardType
toPasteboard: [NSPasteboard generalPasteboard]];
}
} }
- (void) deleteSelection - (void) deleteSelection
@ -216,11 +209,12 @@ static NSMapTable *docMap = 0;
{ {
NSArray *types; NSArray *types;
NSString *type; NSString *type;
NSArray *resourceTypes = [resourceManager resourcePasteboardTypes];
dragPb = [sender draggingPasteboard]; dragPb = [sender draggingPasteboard];
types = [dragPb types]; types = [dragPb types];
resourceManager = [(GormDocument *)document resourceManagerForPasteboard: dragPb]; resourceManager = [(GormDocument *)document resourceManagerForPasteboard: dragPb];
type = [[resourceManager resourcePasteboardTypes] firstObjectCommonWithArray: types]; type = [resourceTypes firstObjectCommonWithArray: types];
if (type != nil) if (type != nil)
{ {
@ -286,6 +280,24 @@ static NSMapTable *docMap = 0;
{ {
} }
- (void) _registerForAllResourceManagers
{
NSMutableArray *allTypes = [[NSMutableArray alloc] initWithObjects: GormLinkPboardType, nil];
NSArray *mgrs = [(GormDocument *)document resourceManagers];
NSEnumerator *en = [mgrs objectEnumerator];
IBResourceManager *mgr = nil;
AUTORELEASE(allTypes);
while((mgr = [en nextObject]) != nil)
{
NSArray *pbTypes = [mgr resourcePasteboardTypes];
[allTypes addObjectsFromArray: pbTypes];
}
[self registerForDraggedTypes: allTypes];
}
- (void) handleNotification: (NSNotification*)aNotification - (void) handleNotification: (NSNotification*)aNotification
{ {
NSString *name = [aNotification name]; NSString *name = [aNotification name];
@ -295,6 +307,10 @@ static NSMapTable *docMap = 0;
NSDebugLog(@"Recieved notification"); NSDebugLog(@"Recieved notification");
[self setCellSize: defaultCellSize()]; [self setCellSize: defaultCellSize()];
} }
else if([name isEqual: IBResourceManagerRegistryDidChangeNotification])
{
[self _registerForAllResourceManagers];
}
} }
/* /*
@ -319,8 +335,9 @@ static NSMapTable *docMap = 0;
document = aDocument; document = aDocument;
[self registerForDraggedTypes: [NSArray arrayWithObjects: [self _registerForAllResourceManagers];
IBObjectPboardType, GormLinkPboardType, nil]]; // [self registerForDraggedTypes: [NSArray arrayWithObjects:
// IBObjectPboardType, GormLinkPboardType, nil]];
[self setAutosizesCells: NO]; [self setAutosizesCells: NO];
[self setCellSize: defaultCellSize()]; [self setCellSize: defaultCellSize()];
@ -353,6 +370,12 @@ static NSMapTable *docMap = 0;
selector: @selector(handleNotification:) selector: @selector(handleNotification:)
name: GormResizeCellNotification name: GormResizeCellNotification
object: nil]; object: nil];
[[NSNotificationCenter defaultCenter]
addObserver: self
selector: @selector(handleNotification:)
name: IBResourceManagerRegistryDidChangeNotification
object: nil];
} }
return self; return self;
} }
@ -434,20 +457,6 @@ static NSMapTable *docMap = 0;
{ {
if ([[resourceManager resourcePasteboardTypes] containsObject: dragType]) if ([[resourceManager resourcePasteboardTypes] containsObject: dragType])
{ {
// NSArray *array;
// NSEnumerator *enumerator;
// id obj;
/*
* Ask the document to get the dragged objects from the pasteboard and
* add them to it's collection of known objects.
*/
/*
array = [document pasteType: IBObjectPboardType
fromPasteboard: dragPb
parent: [objects objectAtIndex: 0]];
*/
[resourceManager addResourcesFromPasteboard: dragPb]; [resourceManager addResourcesFromPasteboard: dragPb];
return YES; return YES;
} }