General bugfixes and enhancements.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/apps/gorm/trunk@15007 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Gregory John Casamento 2002-11-18 06:15:06 +00:00
parent 46b43b7f73
commit f671380f5a
6 changed files with 72 additions and 59 deletions

5
Gorm.m
View file

@ -490,7 +490,6 @@ static NSButtonType _buttonTypeForObject( id button )
- (void) dealloc
{
RELEASE(name);
[super dealloc];
}
@ -1560,6 +1559,8 @@ NSLog(@"StartupTime %f", [startDate timeIntervalSinceNow]);
NSData *d;
NSArchiver *archiver;
isTesting = YES; // set here, so that beginArchiving and endArchiving do not use templates.
archiver = [[NSArchiver alloc] init];
[a beginArchiving];
[archiver encodeClassName: @"GormNSWindow"
@ -1580,8 +1581,6 @@ NSLog(@"StartupTime %f", [startDate timeIntervalSinceNow]);
[nc postNotificationName: IBWillBeginTestingInterfaceNotification
object: self];
isTesting = YES;
if ([selectionOwner conformsToProtocol: @protocol(IBEditors)] == YES)
{
[(id<IBEditors>)selectionOwner makeSelectionVisible: NO];

View file

@ -63,8 +63,8 @@
- (void) setCustomClass: (NSString *)className
forObject: (id)object;
- (void) removeCustomClassForObject: (id) object;
- (NSDictionary *) customClassMap;
- (void) setCustomClassMap: (NSDictionary *)dict;
- (NSMutableDictionary *) customClassMap;
- (void) setCustomClassMap: (NSMutableDictionary *)dict;
- (BOOL) isCustomClassMapEmpty;
- (NSString *) nonCustomSuperClassOf: (NSString *)className;
@end

View file

@ -1228,6 +1228,7 @@ NSString *IBClassNameChangedNotification = @"IBClassNameChangedNotification";
- (void) setCustomClass: (NSString *)className
forObject: (id)object
{
// NSString *name = [NSString stringWithString: className];
[customClassMap setObject: className forKey: object];
}
@ -1236,17 +1237,17 @@ NSString *IBClassNameChangedNotification = @"IBClassNameChangedNotification";
[customClassMap removeObjectForKey: object];
}
- (NSDictionary *)customClassMap
- (NSMutableDictionary *)customClassMap
{
return customClassMap;
}
- (void)setCustomClassMap: (NSDictionary *)dict
- (void)setCustomClassMap: (NSMutableDictionary *)dict
{
// copy the dictionary..
NSLog(@"dictionary = %@",dict);
[customClassMap removeAllObjects];
[customClassMap addEntriesFromDictionary: dict];
ASSIGN(customClassMap, dict);
RETAIN(customClassMap);
}
- (BOOL)isCustomClassMapEmpty

View file

@ -149,12 +149,22 @@
- (void) select: (id)sender
{
NSCell *cell = [browser selectedCellInColumn: 0];
NSString *stringValue = RETAIN([cell stringValue]);
NSString *stringValue = [NSString stringWithString: [cell stringValue]];
NSString *nameForObject = [_document nameForObject: _currentSelection];
/* insert your code here */
[_classManager setCustomClass: stringValue
forObject: nameForObject];
NSString *classForObject = NSStringFromClass([_currentSelection class]);
NSDebugLog(@"selected = %@, class = %@",stringValue,nameForObject);
/* add or remove the mapping as necessary. */
if(![stringValue isEqualToString: classForObject])
{
[_classManager setCustomClass: stringValue
forObject: nameForObject];
}
else
{
[_classManager removeCustomClassForObject: nameForObject];
}
}
// Browser delegate

View file

@ -48,6 +48,7 @@
NSMutableArray *hidden;
NSMutableArray *deferredWindows;
NSMutableSet *sounds;
// NSFileWrapper *wrapper;
}
- (void) addConnector: (id<IBConnectors>)aConnector;
- (NSArray*) allConnectors;

View file

@ -136,6 +136,8 @@ static NSImage *classesImage = nil;
{
classesImage = [[NSImage alloc] initWithContentsOfFile: path];
}
[self setVersion: GNUSTEP_NIB_VERSION];
}
}
@ -256,10 +258,7 @@ static NSImage *classesImage = nil;
// sound support
- (GormSound *)_createSoundPlaceHolder: (NSString *)path
{
NSMutableDictionary *dict = [NSMutableDictionary dictionary];
NSString *name = [[path lastPathComponent] stringByDeletingPathExtension];
// [dict setObject: path forKey: @"Path"];
// [dict setObject: name forKey: @"Name"];
return AUTORELEASE([[GormSound alloc] initWithName: name path: path]);
}
@ -329,7 +328,6 @@ static NSImage *classesImage = nil;
className: className];
}
RETAIN(template);
[nameTable setObject: template forKey: key];
}
}
@ -375,8 +373,15 @@ static NSImage *classesImage = nil;
/*
* Method to replace custom objects with templates for archiving.
*/
[self _replaceObjectsWithTemplates];
NSDebugLog(@"*** customClassMap = %@",[classManager customClassMap]);
// ASSIGN(customClasses, [classManager customClassMap]); // assign the custom classes in the class manager
// RETAIN(customClasses);
if(![(Gorm *)NSApp isTestingInterface]) // if we arent testing the interface, substitute the templates when appropriate.
{
[self _replaceObjectsWithTemplates];
}
// [customClasses setObject: @"TestValue" forKey: @"TestKey"]; // temporary
NSLog(@"*** customClassMap = %@",[classManager customClassMap]);
[nameTable setObject: [classManager customClassMap] forKey: @"GSCustomClassMap"];
/*
@ -1128,17 +1133,14 @@ static NSImage *classesImage = nil;
/*
* Restore removed objects.
*/
// NSMapRemove(objToName, (void*)[nameTable objectForKey: @"NSOwner"]);
[nameTable setObject: filesOwner forKey: @"NSOwner"];
NSMapInsert(objToName, (void*)filesOwner, (void*)@"NSOwner");
// NSMapRemove(objToName, (void*)[nameTable objectForKey: @"NSFirst"]);
[nameTable setObject: firstResponder forKey: @"NSFirst"];
NSMapInsert(objToName, (void*)firstResponder, (void*)@"NSFirst");
if (fontManager != nil)
{
// NSMapRemove(objToName, (void*)[nameTable objectForKey: @"NSFont"]);
[nameTable setObject: fontManager forKey: @"NSFont"];
NSMapInsert(objToName, (void*)fontManager, (void*)@"NSFont");
}
@ -1146,8 +1148,10 @@ static NSImage *classesImage = nil;
/*
* Method to replace custom templates with objects for archiving.
*/
[self _replaceTemplatesWithObjects];
[nameTable removeObjectForKey: @"GSCustomClassMap"];
if(![(Gorm *)NSApp isTestingInterface]) // do not use templates if we are testing.
{
[self _replaceTemplatesWithObjects];
}
/*
* Map all connector source and destination names to their objects.
@ -1684,7 +1688,10 @@ static NSImage *classesImage = nil;
@"OK", NULL, NULL);
return nil;
}
// retrieve the custom class data...
[classManager setCustomClassMap: [[c nameTable] objectForKey: @"GSCustomClassMap"]];
if(isDir == NO)
{
if (![classManager loadCustomClasses: [[aFile stringByDeletingPathExtension]
@ -1718,10 +1725,8 @@ static NSImage *classesImage = nil;
[[c nameTable] setObject: filesOwner forKey: @"NSOwner"];
[[c nameTable] setObject: firstResponder forKey: @"NSFirst"];
/* Iterate over the contents of nameTable and create the connections */
nt = [c nameTable];
//NSLog(@"nt : %@", nt);
//NSLog(@"--------------");
//NSLog(@"con : %@", [c connections]);
enumerator = [[c connections] objectEnumerator];
while ((con = [enumerator nextObject]) != nil)
{
@ -1777,10 +1782,10 @@ static NSImage *classesImage = nil;
}
// get the custom class map and set it into the class manager...
NSDebugLog(@"GSCustomClassMap = %@",[[c nameTable] objectForKey: @"GSCustomClassMap"]);
[classManager setCustomClassMap: [[c nameTable] objectForKey: @"GSCustomClassMap"]];
NSDebugLog(@"nameTable = %@",[c nameTable]);
// NSLog(@"customClasses = %@",customClasses);
// [classManager setCustomClassMap: customClasses];
NSLog(@"nameTable = %@",[c nameTable]);
return self;
}
@ -2036,7 +2041,7 @@ static NSImage *classesImage = nil;
}
[aWindow setFrameTopLeftPoint:
NSMakePoint(220, frame.size.height-100)];
[aWindow setTitle: @"My Window"];
[aWindow setTitle: @"My Window"];
[self setName: @"My Window" forObject: aWindow];
[self attachObject: aWindow toParent: nil];
[self setObject: aWindow isVisibleAtLaunch: YES];
@ -2314,33 +2319,34 @@ static NSImage *classesImage = nil;
[self beginArchiving];
NSDebugLog(@"nametable : %@", nameTable);
// set up the necessary paths...
gormPath = [documentPath stringByAppendingPathComponent: @"objects.gorm"];
classesPath = [documentPath stringByAppendingPathComponent: @"data.classes"];
classesPath = [documentPath stringByAppendingPathComponent: @"data.classes"];
archiverData = [NSMutableData dataWithCapacity: 0];
archiver = [[NSArchiver alloc] initForWritingWithMutableData: archiverData];
[archiver encodeClassName: @"GormObjectProxy" intoClassName: @"GSNibItem"];
[archiver encodeClassName: @"GormCustomView"
intoClassName: @"GSCustomView"];
[archiver encodeClassName: @"GormNSMenu"
intoClassName: @"NSMenu"];
[archiver encodeClassName: @"GormNSWindow"
intoClassName: @"NSWindow"];
[archiver encodeClassName: @"GormNSBrowser"
intoClassName: @"NSBrowser"];
[archiver encodeClassName: @"GormNSTableView"
intoClassName: @"NSTableView"];
[archiver encodeClassName: @"GormNSOutlineView"
intoClassName: @"NSOutlineView"];
[archiver encodeClassName: @"GormNSPopUpButton"
intoClassName: @"NSPopUpButton"];
[archiver encodeClassName: @"GormNSPopUpButtonCell"
intoClassName: @"NSPopUpButtonCell"];
// templates
/* Special gorm classes to their archive equivalents. */
[archiver encodeClassName: @"GormObjectProxy"
intoClassName: @"GSNibItem"];
[archiver encodeClassName: @"GormCustomView"
intoClassName: @"GSCustomView"];
[archiver encodeClassName: @"GormNSMenu"
intoClassName: @"NSMenu"];
[archiver encodeClassName: @"GormNSWindow"
intoClassName: @"NSWindow"];
[archiver encodeClassName: @"GormNSBrowser"
intoClassName: @"NSBrowser"];
[archiver encodeClassName: @"GormNSTableView"
intoClassName: @"NSTableView"];
[archiver encodeClassName: @"GormNSOutlineView"
intoClassName: @"NSOutlineView"];
[archiver encodeClassName: @"GormNSPopUpButton"
intoClassName: @"NSPopUpButton"];
[archiver encodeClassName: @"GormNSPopUpButtonCell"
intoClassName: @"NSPopUpButtonCell"];
/* Templates */
[archiver encodeClassName: @"GormNSWindowTemplate"
intoClassName: @"NSWindowTemplate"];
[archiver encodeClassName: @"GormNSViewTemplate"
@ -2546,15 +2552,12 @@ static NSImage *classesImage = nil;
else if ([editor respondsToSelector:
@selector(windowAndRect:forObject:)])
{
// NSLog(@"temp != nil");
return [editor windowAndRect: r forObject: object];
}
}
else if ([object isKindOfClass: [NSTableColumn class]] == YES)
{
// dirty hack
NSTableView *tv = [[(NSTableColumn*)object dataCell] controlView];
NSTableHeaderView *th = [tv headerView];
int index;
@ -2576,7 +2579,6 @@ static NSImage *classesImage = nil;
*r = [th convertRect: [th headerRectOfColumn: index]
toView: nil];
// NSLog(@"%@", NSStringFromRect(*r));
return [th window];
}
else