mirror of
https://github.com/gnustep/apps-gorm.git
synced 2025-04-22 22:20:44 +00:00
Gorm/nib support fixes.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/apps/gorm/trunk@23057 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
09fbac4ce3
commit
da0073d8c8
5 changed files with 202 additions and 182 deletions
|
@ -1,3 +1,11 @@
|
|||
2006-06-14 22:45 Gregory John Casamento <greg_casamento@yahoo.com>
|
||||
|
||||
* GormCore/GormDocument.[hm]: Added new deactivateEditors and
|
||||
reactivateEditors methods.
|
||||
* GormCore/GormGormWrapperBuilder.m: Moved connection
|
||||
name/object swap here for gorm format.
|
||||
* Gorm.m: Calling new deactivate/reactivateEditors
|
||||
|
||||
2006-06-14 01:42 Gregory John Casamento <greg_casamento@yahoo.com>
|
||||
|
||||
* GormCore/GNUmakefile: Addition of GormNibWrapperLoader to the
|
||||
|
|
4
Gorm.m
4
Gorm.m
|
@ -429,7 +429,7 @@
|
|||
isTesting = YES;
|
||||
[self setApplicationIconImage: testingImage];
|
||||
archiver = [[NSArchiver alloc] init];
|
||||
[activeDoc beginArchiving];
|
||||
[activeDoc deactivateEditors];
|
||||
[archiver encodeClassName: @"GormCustomView"
|
||||
intoClassName: @"GormTestCustomView"];
|
||||
|
||||
|
@ -454,7 +454,7 @@
|
|||
[GSClassSwapper setIsInInterfaceBuilder: YES];
|
||||
[archiver encodeRootObject: activeDoc];
|
||||
data = RETAIN([archiver archiverData]); // Released below...
|
||||
[activeDoc endArchiving];
|
||||
[activeDoc reactivateEditors];
|
||||
RELEASE(archiver);
|
||||
[GSClassSwapper setIsInInterfaceBuilder: NO];
|
||||
|
||||
|
|
|
@ -33,6 +33,18 @@
|
|||
|
||||
@class GormClassManager, GormClassEditor, GormObjectProxy, GormFilesOwner, GormFilePrefsManager;
|
||||
|
||||
/*
|
||||
* Trivial classes for connections from objects to their editors, and from
|
||||
* child editors to their parents. This does nothing special, but we can
|
||||
* use the fact that it's a different class to search for it in the connections
|
||||
* array.
|
||||
*/
|
||||
@interface GormObjectToEditor : NSNibConnector
|
||||
@end
|
||||
|
||||
@interface GormEditorToParent : NSNibConnector
|
||||
@end
|
||||
|
||||
/*
|
||||
* Each document has a GormFirstResponder object that is used as a placeholder
|
||||
* for the first responder at any instant.
|
||||
|
@ -86,18 +98,6 @@
|
|||
NSMutableSet *deferredWindows;
|
||||
}
|
||||
|
||||
/* Archiving objects */
|
||||
|
||||
/**
|
||||
* Start the archiving process.
|
||||
*/
|
||||
- (void) beginArchiving;
|
||||
|
||||
/**
|
||||
* Stop the archiving process.
|
||||
*/
|
||||
- (void) endArchiving;
|
||||
|
||||
/* Handle notifications */
|
||||
|
||||
/**
|
||||
|
@ -361,17 +361,45 @@
|
|||
*/
|
||||
- (NSSet *) deferredWindows;
|
||||
|
||||
/**
|
||||
* Set the document open flag.
|
||||
*/
|
||||
- (void) setDocumentOpen: (BOOL) flag;
|
||||
|
||||
/**
|
||||
* Return the document open flag.
|
||||
*/
|
||||
- (BOOL) isDocumentOpen;
|
||||
|
||||
/**
|
||||
* Set the file info for this document.
|
||||
*/
|
||||
- (void) setInfoData: (NSData *)data;
|
||||
|
||||
/**
|
||||
* return the file info.
|
||||
*/
|
||||
- (NSData *) infoData;
|
||||
|
||||
/**
|
||||
* Set the "older archive" flag.
|
||||
*/
|
||||
- (void) setOlderArchive: (BOOL)flag;
|
||||
|
||||
/**
|
||||
* Return YES if this is an older archive.
|
||||
*/
|
||||
- (BOOL) isOlderArchive;
|
||||
|
||||
/**
|
||||
* Deactivate the editors for archiving..
|
||||
*/
|
||||
- (void) deactivateEditors;
|
||||
|
||||
/**
|
||||
* Reactivate all of the editors...
|
||||
*/
|
||||
- (void) reactivateEditors;
|
||||
@end
|
||||
|
||||
@interface GormDocument (MenuValidation)
|
||||
|
|
|
@ -139,24 +139,16 @@
|
|||
}
|
||||
@end
|
||||
|
||||
/*
|
||||
* Trivial classes for connections from objects to their editors, and from
|
||||
* child editors to their parents. This does nothing special, but we can
|
||||
* use the fact that it's a different class to search for it in the connections
|
||||
* array.
|
||||
*/
|
||||
@interface GormObjectToEditor : NSNibConnector
|
||||
@end
|
||||
|
||||
//
|
||||
// Implementation of trivial classes.
|
||||
//
|
||||
@implementation GormObjectToEditor
|
||||
@end
|
||||
|
||||
@interface GormEditorToParent : NSNibConnector
|
||||
@end
|
||||
|
||||
@implementation GormEditorToParent
|
||||
@end
|
||||
|
||||
|
||||
@implementation GormDocument
|
||||
|
||||
static NSImage *objectsImage = nil;
|
||||
|
@ -1626,119 +1618,6 @@ static NSImage *fileImage = nil;
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Start the process of archiving.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Start the process of archiving.
|
||||
*/
|
||||
- (void) beginArchiving
|
||||
{
|
||||
NSEnumerator *enumerator;
|
||||
id<IBConnectors> con;
|
||||
id obj;
|
||||
|
||||
/*
|
||||
* Map all connector sources and destinations to their name strings.
|
||||
* Deactivate editors so they won't be archived.
|
||||
*/
|
||||
|
||||
enumerator = [connections objectEnumerator];
|
||||
while ((con = [enumerator nextObject]) != nil)
|
||||
{
|
||||
if ([con isKindOfClass: [GormObjectToEditor class]])
|
||||
{
|
||||
[savedEditors addObject: con];
|
||||
[[con destination] deactivate];
|
||||
}
|
||||
else if ([con isKindOfClass: [GormEditorToParent class]])
|
||||
{
|
||||
[savedEditors addObject: con];
|
||||
}
|
||||
else
|
||||
{
|
||||
NSString *name;
|
||||
obj = [con source];
|
||||
name = [self nameForObject: obj];
|
||||
[con setSource: name];
|
||||
obj = [con destination];
|
||||
name = [self nameForObject: obj];
|
||||
[con setDestination: name];
|
||||
}
|
||||
}
|
||||
[connections removeObjectsInArray: savedEditors];
|
||||
|
||||
/*
|
||||
* Remove objects and connections that shouldn't be archived.
|
||||
*/
|
||||
NSMapRemove(objToName, (void*)[nameTable objectForKey: @"NSOwner"]);
|
||||
[nameTable removeObjectForKey: @"NSOwner"];
|
||||
NSMapRemove(objToName, (void*)[nameTable objectForKey: @"NSFirst"]);
|
||||
[nameTable removeObjectForKey: @"NSFirst"];
|
||||
|
||||
/* Add information about the NSOwner to the archive */
|
||||
NSMapInsert(objToName, (void*)[filesOwner className], (void*)@"NSOwner");
|
||||
[nameTable setObject: [filesOwner className] forKey: @"NSOwner"];
|
||||
|
||||
/*
|
||||
* Set the appropriate profile so that we save the right versions of
|
||||
* the classes for older GNUstep releases.
|
||||
*/
|
||||
[filePrefsManager setClassVersions];
|
||||
}
|
||||
|
||||
/**
|
||||
* Stop the archiving process.
|
||||
*/
|
||||
- (void) endArchiving
|
||||
{
|
||||
NSEnumerator *enumerator;
|
||||
id<IBConnectors> con;
|
||||
id obj;
|
||||
|
||||
/*
|
||||
* Restore class versions.
|
||||
*/
|
||||
[filePrefsManager restoreClassVersions];
|
||||
|
||||
/*
|
||||
* Restore removed objects.
|
||||
*/
|
||||
[nameTable setObject: filesOwner forKey: @"NSOwner"];
|
||||
NSMapInsert(objToName, (void*)filesOwner, (void*)@"NSOwner");
|
||||
|
||||
[nameTable setObject: firstResponder forKey: @"NSFirst"];
|
||||
NSMapInsert(objToName, (void*)firstResponder, (void*)@"NSFirst");
|
||||
|
||||
/*
|
||||
* Map all connector source and destination names to their objects.
|
||||
*/
|
||||
enumerator = [connections objectEnumerator];
|
||||
while ((con = [enumerator nextObject]) != nil)
|
||||
{
|
||||
NSString *name;
|
||||
name = (NSString*)[con source];
|
||||
obj = [self objectForName: name];
|
||||
[con setSource: obj];
|
||||
name = (NSString*)[con destination];
|
||||
obj = [self objectForName: name];
|
||||
[con setDestination: obj];
|
||||
}
|
||||
|
||||
/*
|
||||
* Restore editor links and reactivate the editors.
|
||||
*/
|
||||
[connections addObjectsFromArray: savedEditors];
|
||||
enumerator = [savedEditors objectEnumerator];
|
||||
while ((con = [enumerator nextObject]) != nil)
|
||||
{
|
||||
if ([[con source] isKindOfClass: [NSView class]] == NO)
|
||||
[[con destination] activate];
|
||||
}
|
||||
[savedEditors removeAllObjects];
|
||||
}
|
||||
|
||||
/**
|
||||
* Forces the closing of all editors in the document.
|
||||
*/
|
||||
|
@ -3431,10 +3310,10 @@ static NSImage *fileImage = nil;
|
|||
postNotificationName: IBWillSaveDocumentNotification
|
||||
object: self];
|
||||
|
||||
// [self beginArchiving];
|
||||
// build the archive...
|
||||
[self deactivateEditors];
|
||||
result = [builder buildFileWrapperWithDocument: self];
|
||||
// [self endArchiving];
|
||||
|
||||
[self reactivateEditors];
|
||||
if(result)
|
||||
{
|
||||
/*
|
||||
|
@ -3644,6 +3523,57 @@ static NSImage *fileImage = nil;
|
|||
[o orderFront: self];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Deactivate the editors for archiving..
|
||||
*/
|
||||
- (void) deactivateEditors
|
||||
{
|
||||
NSEnumerator *enumerator;
|
||||
id<IBConnectors> con;
|
||||
|
||||
/*
|
||||
* Map all connector sources and destinations to their name strings.
|
||||
* Deactivate editors so they won't be archived.
|
||||
*/
|
||||
|
||||
enumerator = [connections objectEnumerator];
|
||||
while ((con = [enumerator nextObject]) != nil)
|
||||
{
|
||||
if ([con isKindOfClass: [GormObjectToEditor class]])
|
||||
{
|
||||
[savedEditors addObject: con];
|
||||
[[con destination] deactivate];
|
||||
}
|
||||
else if ([con isKindOfClass: [GormEditorToParent class]])
|
||||
{
|
||||
[savedEditors addObject: con];
|
||||
}
|
||||
}
|
||||
[connections removeObjectsInArray: savedEditors];
|
||||
}
|
||||
|
||||
/**
|
||||
* Reactivate all of the editors...
|
||||
*/
|
||||
- (void) reactivateEditors
|
||||
{
|
||||
NSEnumerator *enumerator;
|
||||
id<IBConnectors> con;
|
||||
|
||||
/*
|
||||
* Restore editor links and reactivate the editors.
|
||||
*/
|
||||
[connections addObjectsFromArray: savedEditors];
|
||||
enumerator = [savedEditors objectEnumerator];
|
||||
while ((con = [enumerator nextObject]) != nil)
|
||||
{
|
||||
if ([[con source] isKindOfClass: [NSView class]] == NO)
|
||||
[[con destination] activate];
|
||||
}
|
||||
[savedEditors removeAllObjects];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation GormDocument (MenuValidation)
|
||||
|
|
|
@ -34,10 +34,100 @@
|
|||
#include <GormCore/GormProtocol.h>
|
||||
#include <GormCore/GormPalettesManager.h>
|
||||
|
||||
@interface GormDocument (BuilderAdditions)
|
||||
- (void) prepareConnections;
|
||||
- (void) resetConnections;
|
||||
@end
|
||||
|
||||
@implementation GormDocument (BuilderAdditions)
|
||||
/**
|
||||
* Start the process of archiving.
|
||||
*/
|
||||
- (void) prepareConnections
|
||||
{
|
||||
NSEnumerator *enumerator;
|
||||
id<IBConnectors> con;
|
||||
id obj;
|
||||
|
||||
/*
|
||||
* Map all connector sources and destinations to their name strings.
|
||||
* Deactivate editors so they won't be archived.
|
||||
*/
|
||||
|
||||
enumerator = [connections objectEnumerator];
|
||||
while ((con = [enumerator nextObject]) != nil)
|
||||
{
|
||||
NSString *name;
|
||||
obj = [con source];
|
||||
name = [self nameForObject: obj];
|
||||
[con setSource: name];
|
||||
obj = [con destination];
|
||||
name = [self nameForObject: obj];
|
||||
[con setDestination: name];
|
||||
}
|
||||
|
||||
/*
|
||||
* Remove objects and connections that shouldn't be archived.
|
||||
*/
|
||||
NSMapRemove(objToName, (void*)[nameTable objectForKey: @"NSOwner"]);
|
||||
[nameTable removeObjectForKey: @"NSOwner"];
|
||||
NSMapRemove(objToName, (void*)[nameTable objectForKey: @"NSFirst"]);
|
||||
[nameTable removeObjectForKey: @"NSFirst"];
|
||||
|
||||
/* Add information about the NSOwner to the archive */
|
||||
NSMapInsert(objToName, (void*)[filesOwner className], (void*)@"NSOwner");
|
||||
[nameTable setObject: [filesOwner className] forKey: @"NSOwner"];
|
||||
|
||||
/*
|
||||
* Set the appropriate profile so that we save the right versions of
|
||||
* the classes for older GNUstep releases.
|
||||
*/
|
||||
[filePrefsManager setClassVersions];
|
||||
}
|
||||
|
||||
/**
|
||||
* Stop the archiving process.
|
||||
*/
|
||||
- (void) resetConnections
|
||||
{
|
||||
NSEnumerator *enumerator;
|
||||
id<IBConnectors> con;
|
||||
id obj;
|
||||
|
||||
/*
|
||||
* Restore class versions.
|
||||
*/
|
||||
[filePrefsManager restoreClassVersions];
|
||||
|
||||
/*
|
||||
* Restore removed objects.
|
||||
*/
|
||||
[nameTable setObject: filesOwner forKey: @"NSOwner"];
|
||||
NSMapInsert(objToName, (void*)filesOwner, (void*)@"NSOwner");
|
||||
|
||||
[nameTable setObject: firstResponder forKey: @"NSFirst"];
|
||||
NSMapInsert(objToName, (void*)firstResponder, (void*)@"NSFirst");
|
||||
|
||||
/*
|
||||
* Map all connector source and destination names to their objects.
|
||||
*/
|
||||
enumerator = [connections objectEnumerator];
|
||||
while ((con = [enumerator nextObject]) != nil)
|
||||
{
|
||||
NSString *name;
|
||||
name = (NSString*)[con source];
|
||||
obj = [self objectForName: name];
|
||||
[con setSource: obj];
|
||||
name = (NSString*)[con destination];
|
||||
obj = [self objectForName: name];
|
||||
[con setDestination: obj];
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@interface GSNibContainer (BuilderAdditions)
|
||||
- (id) initWithDocument: (GormDocument *)document;
|
||||
- (void) prepareConnectionsWithDocument: (GormDocument *)document;
|
||||
- (void) resetConnectionsWithDocument: (GormDocument *)document;
|
||||
@end;
|
||||
|
||||
@implementation GSNibContainer (BuilderAdditions)
|
||||
|
@ -61,42 +151,6 @@
|
|||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void) prepareConnectionsWithDocument: (GormDocument *)document
|
||||
{
|
||||
NSEnumerator *enumerator = [connections objectEnumerator];
|
||||
id conn = nil;
|
||||
while ((conn = [enumerator nextObject]) != nil)
|
||||
{
|
||||
NSString *name = nil;
|
||||
id obj = nil;
|
||||
|
||||
obj = [conn source];
|
||||
name = [document nameForObject: obj];
|
||||
[conn setSource: name];
|
||||
obj = [conn destination];
|
||||
name = [document nameForObject: obj];
|
||||
[conn setDestination: name];
|
||||
}
|
||||
}
|
||||
|
||||
- (void) resetConnectionsWithDocument: (GormDocument *)document
|
||||
{
|
||||
NSEnumerator *enumerator = [connections objectEnumerator];
|
||||
id conn = nil;
|
||||
while ((conn = [enumerator nextObject]) != nil)
|
||||
{
|
||||
NSString *name = nil;
|
||||
id obj = nil;
|
||||
|
||||
name = (NSString*)[conn source];
|
||||
obj = [document objectForName: name];
|
||||
[conn setSource: obj];
|
||||
name = (NSString*)[conn destination];
|
||||
obj = [document objectForName: name];
|
||||
[conn setDestination: obj];
|
||||
}
|
||||
}
|
||||
@end
|
||||
|
||||
@interface GormGormWrapperBuilder : GormWrapperBuilder
|
||||
|
@ -187,7 +241,7 @@
|
|||
GormFilePrefsManager *filePrefsManager = [document filePrefsManager];
|
||||
GSNibContainer *container = nil;
|
||||
|
||||
[document beginArchiving];
|
||||
[document prepareConnections];
|
||||
container = [[GSNibContainer alloc] initWithDocument: document];
|
||||
|
||||
/*
|
||||
|
@ -236,7 +290,7 @@
|
|||
|
||||
// release the container...
|
||||
RELEASE(container);
|
||||
[document endArchiving];
|
||||
[document resetConnections];
|
||||
}
|
||||
|
||||
return fileWrappers;
|
||||
|
|
Loading…
Reference in a new issue