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>
* GormCore/GormFilePrefsManager.m

View file

@ -180,6 +180,9 @@ static NSImage *fileImage = nil;
{
fileImage = [[NSImage alloc] initWithContentsOfFile: path];
}
// create the resource manager...
[IBResourceManager registerResourceManagerClass: [IBResourceManager class]];
[self setVersion: GNUSTEP_NIB_VERSION];
}
@ -259,6 +262,9 @@ static NSImage *fileImage = nil;
name: IBResourceManagerRegistryDidChangeNotification
object: nil];
// load resource managers
[self createResourceManagers];
// objects...
mainRect.origin = NSMakePoint(0,0);
scrollView = [[NSScrollView alloc] initWithFrame: scrollRect];
@ -386,9 +392,6 @@ static NSImage *fileImage = nil;
// document is open...
isDocumentOpen = YES;
// load resource managers
[self createResourceManagers];
}
else
{
@ -1262,7 +1265,7 @@ static NSImage *fileImage = nil;
id<IBConnectors> link;
editor = [[eClass alloc] initWithObject: anObject inDocument: self];
link = [GormObjectToEditor new];
link = AUTORELEASE([GormObjectToEditor new]);
[link setSource: anObject];
[link setDestination: editor];
[connections addObject: link];
@ -1272,7 +1275,6 @@ static NSImage *fileImage = nil;
[openEditors addObject: editor];
}
RELEASE(link);
if (anEditor == nil)
{
/*
@ -1286,11 +1288,10 @@ static NSImage *fileImage = nil;
/*
* Link to the parent of the editor.
*/
link = [GormEditorToParent new];
link = AUTORELEASE([GormEditorToParent new]);
[link setSource: editor];
[link setDestination: anEditor];
[connections addObject: link];
RELEASE(link);
}
else
{
@ -1298,6 +1299,7 @@ static NSImage *fileImage = nil;
}
[editor activate];
RELEASE((NSObject *)editor);
return editor;
}
else if ([links count] == 0)
@ -2261,8 +2263,9 @@ static NSImage *fileImage = nil;
else
{
NSEnumerator *enumerator = [objects objectEnumerator];
id obj;
NSRect frame;
id obj;
while ((obj = [enumerator nextObject]) != nil)
{
// 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 */
[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);
if (oldName != nil)
{
@ -2548,7 +2551,6 @@ static NSImage *fileImage = nil;
[cc setObject: className forKey: aName]; //nameCopy];
}
}
// RELEASE(nameCopy); // release the copy of the name which we made...
}
- (void) setObject: (id)anObject isVisibleAtLaunch: (BOOL)flag

View file

@ -90,9 +90,6 @@ static NSMapTable *docMap = 0;
docMap = NSCreateMapTable(NSObjectMapKeyCallBacks,
NSObjectMapValueCallBacks,
2);
// create the resource manager...
[IBResourceManager registerResourceManagerClass: [IBResourceManager class]];
}
}
@ -124,16 +121,12 @@ static NSMapTable *docMap = 0;
- (void) pasteInSelection
{
// not implemented
}
- (void) copySelection
{
if (selected != nil)
{
[document copyObjects: [self selection]
type: IBObjectPboardType
toPasteboard: [NSPasteboard generalPasteboard]];
}
// not implemented
}
- (void) deleteSelection
@ -216,11 +209,12 @@ static NSMapTable *docMap = 0;
{
NSArray *types;
NSString *type;
NSArray *resourceTypes = [resourceManager resourcePasteboardTypes];
dragPb = [sender draggingPasteboard];
types = [dragPb types];
resourceManager = [(GormDocument *)document resourceManagerForPasteboard: dragPb];
type = [[resourceManager resourcePasteboardTypes] firstObjectCommonWithArray: types];
type = [resourceTypes firstObjectCommonWithArray: types];
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
{
NSString *name = [aNotification name];
@ -295,6 +307,10 @@ static NSMapTable *docMap = 0;
NSDebugLog(@"Recieved notification");
[self setCellSize: defaultCellSize()];
}
else if([name isEqual: IBResourceManagerRegistryDidChangeNotification])
{
[self _registerForAllResourceManagers];
}
}
/*
@ -319,8 +335,9 @@ static NSMapTable *docMap = 0;
document = aDocument;
[self registerForDraggedTypes: [NSArray arrayWithObjects:
IBObjectPboardType, GormLinkPboardType, nil]];
[self _registerForAllResourceManagers];
// [self registerForDraggedTypes: [NSArray arrayWithObjects:
// IBObjectPboardType, GormLinkPboardType, nil]];
[self setAutosizesCells: NO];
[self setCellSize: defaultCellSize()];
@ -353,6 +370,12 @@ static NSMapTable *docMap = 0;
selector: @selector(handleNotification:)
name: GormResizeCellNotification
object: nil];
[[NSNotificationCenter defaultCenter]
addObserver: self
selector: @selector(handleNotification:)
name: IBResourceManagerRegistryDidChangeNotification
object: nil];
}
return self;
}
@ -434,20 +457,6 @@ static NSMapTable *docMap = 0;
{
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];
return YES;
}