mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-05-31 13:10:48 +00:00
GSNibContainer version 2 changes. New method declarations for customClasses, visibleWindows and deferredWindows. Changes to init, initWithCoder: and encodeWithCoder: to handle the new data.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@23150 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
f6fb00fad1
commit
d0ecdaea11
4 changed files with 135 additions and 43 deletions
12
ChangeLog
12
ChangeLog
|
@ -1,3 +1,15 @@
|
||||||
|
2006-07-09 10:50 Gregory John Casamento <greg_casamento@yahoo.com>
|
||||||
|
|
||||||
|
* Headers/Additions/GNUstepGUI/GSNibTemplates.h: Declaration for
|
||||||
|
new methods: visibleWindows, deferredWindows, & customClasses.
|
||||||
|
* Source/GSNibTemplates.m: Simplification of awakeFromContext: code
|
||||||
|
due to new gorm format changes. Also, changes to init to initialize
|
||||||
|
the new ivars, dealloc to release them and modifications to
|
||||||
|
initWithCoder: and encodeWithCoder: to decode and encode the new
|
||||||
|
data. Added new methods: visibleWindows, deferredWindows, &
|
||||||
|
customClasses.
|
||||||
|
* Source/NSView.m: Minor cleanup.
|
||||||
|
|
||||||
2006-07-06 21:35 Gregory John Casamento <greg_casamento@yahoo.com>
|
2006-07-06 21:35 Gregory John Casamento <greg_casamento@yahoo.com>
|
||||||
|
|
||||||
* Source/NSBrowser.m:
|
* Source/NSBrowser.m:
|
||||||
|
|
|
@ -36,7 +36,7 @@
|
||||||
#include "GNUstepGUI/GSNibContainer.h"
|
#include "GNUstepGUI/GSNibContainer.h"
|
||||||
|
|
||||||
// version of the nib container and the templates.
|
// version of the nib container and the templates.
|
||||||
#define GNUSTEP_NIB_VERSION 1
|
#define GNUSTEP_NIB_VERSION 2
|
||||||
#define GSSWAPPER_VERSION 0
|
#define GSSWAPPER_VERSION 0
|
||||||
#define GSWINDOWT_VERSION 1
|
#define GSWINDOWT_VERSION 1
|
||||||
#define GSVIEWT_VERSION 0
|
#define GSVIEWT_VERSION 0
|
||||||
|
@ -67,9 +67,15 @@ enum {
|
||||||
{
|
{
|
||||||
NSMutableDictionary *nameTable;
|
NSMutableDictionary *nameTable;
|
||||||
NSMutableArray *connections;
|
NSMutableArray *connections;
|
||||||
|
NSMutableArray *visibleWindows;
|
||||||
|
NSMutableArray *deferredWindows;
|
||||||
NSMutableSet *topLevelObjects;
|
NSMutableSet *topLevelObjects;
|
||||||
|
NSMutableDictionary *customClasses;
|
||||||
BOOL isAwake;
|
BOOL isAwake;
|
||||||
}
|
}
|
||||||
|
- (NSMutableArray*) visibleWindows;
|
||||||
|
- (NSMutableArray*) deferredWindows;
|
||||||
|
- (NSMutableDictionary *) customClasses;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -158,7 +158,6 @@ static NSString *GSInternalNibItemAddedNotification = @"_GSInternalNibItemAddedN
|
||||||
NSEnumerator *enumerator;
|
NSEnumerator *enumerator;
|
||||||
NSNibConnector *connection;
|
NSNibConnector *connection;
|
||||||
NSString *key;
|
NSString *key;
|
||||||
NSArray *visible;
|
|
||||||
NSMenu *menu;
|
NSMenu *menu;
|
||||||
NSMutableArray *topObjects;
|
NSMutableArray *topObjects;
|
||||||
id obj;
|
id obj;
|
||||||
|
@ -248,12 +247,10 @@ static NSString *GSInternalNibItemAddedNotification = @"_GSInternalNibItemAddedN
|
||||||
if ([context objectForKey: key] == nil ||
|
if ([context objectForKey: key] == nil ||
|
||||||
[key isEqualToString: @"NSOwner"]) // we want to send the message to the owner
|
[key isEqualToString: @"NSOwner"]) // we want to send the message to the owner
|
||||||
{
|
{
|
||||||
if ([key isEqualToString: @"NSWindowsMenu"] == NO && // we don't want to send a message to these menus twice,
|
// we don't want to send a message to these menus twice, if they're custom classes.
|
||||||
[key isEqualToString: @"NSServicesMenu"] == NO && // if they're custom classes.
|
if ([key isEqualToString: @"NSWindowsMenu"] == NO &&
|
||||||
[key isEqualToString: @"NSVisible"] == NO && // also exclude any other special parts of the nameTable.
|
[key isEqualToString: @"NSServicesMenu"] == NO &&
|
||||||
[key isEqualToString: @"NSDeferred"] == NO &&
|
[key isEqualToString: @"NSTopLevelObjects"] == NO)
|
||||||
[key isEqualToString: @"NSTopLevelObjects"] == NO &&
|
|
||||||
[key isEqualToString: @"GSCustomClassMap"] == NO)
|
|
||||||
{
|
{
|
||||||
id o = [nameTable objectForKey: key];
|
id o = [nameTable objectForKey: key];
|
||||||
|
|
||||||
|
@ -305,15 +302,12 @@ static NSString *GSInternalNibItemAddedNotification = @"_GSInternalNibItemAddedN
|
||||||
* This is the last thing we should do since changes might be made
|
* This is the last thing we should do since changes might be made
|
||||||
* in the awakeFromNib methods which are called on all of the objects.
|
* in the awakeFromNib methods which are called on all of the objects.
|
||||||
*/
|
*/
|
||||||
visible = [nameTable objectForKey: @"NSVisible"];
|
if (visibleWindows != nil)
|
||||||
if (visible != nil
|
|
||||||
&& [visible isKindOfClass: [NSArray class]] == YES)
|
|
||||||
{
|
{
|
||||||
unsigned pos = [visible count];
|
unsigned pos = [visibleWindows count];
|
||||||
|
|
||||||
while (pos-- > 0)
|
while (pos-- > 0)
|
||||||
{
|
{
|
||||||
NSWindow *win = [visible objectAtIndex: pos];
|
NSWindow *win = [visibleWindows objectAtIndex: pos];
|
||||||
if ([NSApp isActive])
|
if ([NSApp isActive])
|
||||||
[win orderFront: self];
|
[win orderFront: self];
|
||||||
else
|
else
|
||||||
|
@ -336,26 +330,12 @@ static NSString *GSInternalNibItemAddedNotification = @"_GSInternalNibItemAddedN
|
||||||
RELEASE(nameTable);
|
RELEASE(nameTable);
|
||||||
RELEASE(connections);
|
RELEASE(connections);
|
||||||
RELEASE(topLevelObjects);
|
RELEASE(topLevelObjects);
|
||||||
|
RELEASE(visibleWindows);
|
||||||
|
RELEASE(deferredWindows);
|
||||||
|
RELEASE(customClasses);
|
||||||
[super dealloc];
|
[super dealloc];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) encodeWithCoder: (NSCoder*)aCoder
|
|
||||||
{
|
|
||||||
int version = [GSNibContainer version];
|
|
||||||
if (version == GNUSTEP_NIB_VERSION)
|
|
||||||
{
|
|
||||||
[aCoder encodeObject: nameTable];
|
|
||||||
[aCoder encodeObject: connections];
|
|
||||||
[aCoder encodeObject: topLevelObjects];
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// encode it as a version 0 file...
|
|
||||||
[aCoder encodeObject: nameTable];
|
|
||||||
[aCoder encodeObject: connections];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
- (id) init
|
- (id) init
|
||||||
{
|
{
|
||||||
if ((self = [super init]) != nil)
|
if ((self = [super init]) != nil)
|
||||||
|
@ -363,28 +343,89 @@ static NSString *GSInternalNibItemAddedNotification = @"_GSInternalNibItemAddedN
|
||||||
nameTable = [[NSMutableDictionary alloc] initWithCapacity: 8];
|
nameTable = [[NSMutableDictionary alloc] initWithCapacity: 8];
|
||||||
connections = [[NSMutableArray alloc] initWithCapacity: 8];
|
connections = [[NSMutableArray alloc] initWithCapacity: 8];
|
||||||
topLevelObjects = [[NSMutableSet alloc] initWithCapacity: 8];
|
topLevelObjects = [[NSMutableSet alloc] initWithCapacity: 8];
|
||||||
|
customClasses = [[NSMutableDictionary alloc] initWithCapacity: 8];
|
||||||
// add special objects...
|
deferredWindows = [[NSMutableArray alloc] initWithCapacity: 8];
|
||||||
[nameTable setObject: [NSMutableDictionary dictionary]
|
visibleWindows = [[NSMutableArray alloc] initWithCapacity: 8];
|
||||||
forKey: @"GSCustomClassMap"];
|
|
||||||
[nameTable setObject: [NSMutableArray array]
|
|
||||||
forKey: @"NSDeferred"];
|
|
||||||
[nameTable setObject: [NSMutableArray array]
|
|
||||||
forKey: @"NSVisible"];
|
|
||||||
}
|
}
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void) encodeWithCoder: (NSCoder*)aCoder
|
||||||
|
{
|
||||||
|
int version = [GSNibContainer version];
|
||||||
|
if (version == GNUSTEP_NIB_VERSION)
|
||||||
|
{
|
||||||
|
[aCoder encodeObject: topLevelObjects];
|
||||||
|
[aCoder encodeObject: visibleWindows];
|
||||||
|
[aCoder encodeObject: deferredWindows];
|
||||||
|
[aCoder encodeObject: nameTable];
|
||||||
|
[aCoder encodeObject: connections];
|
||||||
|
[aCoder encodeObject: customClasses];
|
||||||
|
}
|
||||||
|
else if (version == 1)
|
||||||
|
{
|
||||||
|
NSMutableDictionary *nt = [NSMutableDictionary dictionaryWithDictionary: nameTable];
|
||||||
|
[nt setObject: [NSMutableArray arrayWithArray: visibleWindows]
|
||||||
|
forKey: @"NSVisible"];
|
||||||
|
[nt setObject: [NSMutableArray arrayWithArray: deferredWindows]
|
||||||
|
forKey: @"NSDeferred"];
|
||||||
|
[nt setObject: [NSMutableDictionary dictionaryWithDictionary: customClasses]
|
||||||
|
forKey: @"GSCustomClassMap"];
|
||||||
|
[aCoder encodeObject: nt];
|
||||||
|
[aCoder encodeObject: connections];
|
||||||
|
[aCoder encodeObject: topLevelObjects];
|
||||||
|
}
|
||||||
|
else if (version == 0)
|
||||||
|
{
|
||||||
|
NSMutableDictionary *nt = [NSMutableDictionary dictionaryWithDictionary: nameTable];
|
||||||
|
[nt setObject: [NSMutableArray arrayWithArray: visibleWindows]
|
||||||
|
forKey: @"NSVisible"];
|
||||||
|
[nt setObject: [NSMutableArray arrayWithArray: deferredWindows]
|
||||||
|
forKey: @"NSDeferred"];
|
||||||
|
[nt setObject: [NSMutableDictionary dictionaryWithDictionary: customClasses]
|
||||||
|
forKey: @"GSCustomClassMap"];
|
||||||
|
[aCoder encodeObject: nt];
|
||||||
|
[aCoder encodeObject: connections];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
[NSException raise: NSInternalInconsistencyException
|
||||||
|
format: @"Unable to write GSNibContainer version #%d. GSNibContainer version for the installed gui lib is %d.", version, GNUSTEP_NIB_VERSION];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
- (id) initWithCoder: (NSCoder*)aCoder
|
- (id) initWithCoder: (NSCoder*)aCoder
|
||||||
{
|
{
|
||||||
int version = [aCoder versionForClassName: @"GSNibContainer"];
|
int version = [aCoder versionForClassName: @"GSNibContainer"];
|
||||||
|
|
||||||
// save the version to the ivar, we need it later.
|
// save the version to the ivar, we need it later.
|
||||||
if (version == GNUSTEP_NIB_VERSION)
|
if (version == GNUSTEP_NIB_VERSION)
|
||||||
|
{
|
||||||
|
[aCoder decodeValueOfObjCType: @encode(id) at: &topLevelObjects];
|
||||||
|
[aCoder decodeValueOfObjCType: @encode(id) at: &visibleWindows];
|
||||||
|
[aCoder decodeValueOfObjCType: @encode(id) at: &deferredWindows];
|
||||||
|
[aCoder decodeValueOfObjCType: @encode(id) at: &nameTable];
|
||||||
|
[aCoder decodeValueOfObjCType: @encode(id) at: &connections];
|
||||||
|
[aCoder decodeValueOfObjCType: @encode(id) at: &customClasses];
|
||||||
|
}
|
||||||
|
else if (version == 1)
|
||||||
{
|
{
|
||||||
[aCoder decodeValueOfObjCType: @encode(id) at: &nameTable];
|
[aCoder decodeValueOfObjCType: @encode(id) at: &nameTable];
|
||||||
[aCoder decodeValueOfObjCType: @encode(id) at: &connections];
|
[aCoder decodeValueOfObjCType: @encode(id) at: &connections];
|
||||||
[aCoder decodeValueOfObjCType: @encode(id) at: &topLevelObjects];
|
[aCoder decodeValueOfObjCType: @encode(id) at: &topLevelObjects];
|
||||||
|
|
||||||
|
// initialize with special entries...
|
||||||
|
ASSIGN(visibleWindows, [NSMutableArray arrayWithArray:
|
||||||
|
[nameTable objectForKey: @"NSVisible"]]);
|
||||||
|
ASSIGN(deferredWindows, [NSMutableArray arrayWithArray:
|
||||||
|
[nameTable objectForKey: @"NSDeferred"]]);
|
||||||
|
ASSIGN(customClasses, [NSMutableDictionary dictionaryWithDictionary:
|
||||||
|
[nameTable objectForKey: @"GSCustomClassMap"]]);
|
||||||
|
|
||||||
|
// then remove them from the name table.
|
||||||
|
[nameTable removeObjectForKey: @"NSVisible"];
|
||||||
|
[nameTable removeObjectForKey: @"NSDeferred"];
|
||||||
|
[nameTable removeObjectForKey: @"GSCustomClassMap"];
|
||||||
}
|
}
|
||||||
else if (version == 0)
|
else if (version == 0)
|
||||||
{
|
{
|
||||||
|
@ -412,6 +453,20 @@ static NSString *GSInternalNibItemAddedNotification = @"_GSInternalNibItemAddedN
|
||||||
[topLevelObjects addObject: o]; // if it's a top level object, add it.
|
[topLevelObjects addObject: o]; // if it's a top level object, add it.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// initialize with special entries...
|
||||||
|
ASSIGN(visibleWindows, [NSMutableArray arrayWithArray:
|
||||||
|
[nameTable objectForKey: @"NSVisible"]]);
|
||||||
|
ASSIGN(deferredWindows, [NSMutableArray arrayWithArray:
|
||||||
|
[nameTable objectForKey: @"NSDeferred"]]);
|
||||||
|
ASSIGN(customClasses, [NSMutableDictionary dictionaryWithDictionary:
|
||||||
|
[nameTable objectForKey: @"GSCustomClassMap"]]);
|
||||||
|
|
||||||
|
|
||||||
|
// then remove them from the name table.
|
||||||
|
[nameTable removeObjectForKey: @"NSVisible"];
|
||||||
|
[nameTable removeObjectForKey: @"NSDeferred"];
|
||||||
|
[nameTable removeObjectForKey: @"GSCustomClassMap"];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -436,6 +491,21 @@ static NSString *GSInternalNibItemAddedNotification = @"_GSInternalNibItemAddedN
|
||||||
{
|
{
|
||||||
return connections;
|
return connections;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (NSMutableArray*) visibleWindows
|
||||||
|
{
|
||||||
|
return visibleWindows;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSMutableArray*) deferredWindows
|
||||||
|
{
|
||||||
|
return visibleWindows;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSMutableDictionary *) customClasses
|
||||||
|
{
|
||||||
|
return customClasses;
|
||||||
|
}
|
||||||
@end
|
@end
|
||||||
|
|
||||||
// The first standin objects here are for views and normal objects like controllers
|
// The first standin objects here are for views and normal objects like controllers
|
||||||
|
|
|
@ -4017,8 +4017,10 @@ static NSView* findByTag(NSView *view, int aTag, unsigned *level)
|
||||||
e = [subs objectEnumerator];
|
e = [subs objectEnumerator];
|
||||||
while ((sub = [e nextObject]) != nil)
|
while ((sub = [e nextObject]) != nil)
|
||||||
{
|
{
|
||||||
NSAssert([sub window] == nil, NSInternalInconsistencyException);
|
NSAssert([sub window] == nil,
|
||||||
NSAssert([sub superview] == nil, NSInternalInconsistencyException);
|
NSInternalInconsistencyException);
|
||||||
|
NSAssert([sub superview] == nil,
|
||||||
|
NSInternalInconsistencyException);
|
||||||
[sub viewWillMoveToWindow: _window];
|
[sub viewWillMoveToWindow: _window];
|
||||||
[sub viewWillMoveToSuperview: self];
|
[sub viewWillMoveToSuperview: self];
|
||||||
[sub setNextResponder: self];
|
[sub setNextResponder: self];
|
||||||
|
@ -4096,8 +4098,10 @@ static NSView* findByTag(NSView *view, int aTag, unsigned *level)
|
||||||
e = [subs objectEnumerator];
|
e = [subs objectEnumerator];
|
||||||
while ((sub = [e nextObject]) != nil)
|
while ((sub = [e nextObject]) != nil)
|
||||||
{
|
{
|
||||||
NSAssert([sub window] == nil, NSInternalInconsistencyException);
|
NSAssert([sub window] == nil,
|
||||||
NSAssert([sub superview] == nil, NSInternalInconsistencyException);
|
NSInternalInconsistencyException);
|
||||||
|
NSAssert([sub superview] == nil,
|
||||||
|
NSInternalInconsistencyException);
|
||||||
[sub viewWillMoveToWindow: _window];
|
[sub viewWillMoveToWindow: _window];
|
||||||
[sub viewWillMoveToSuperview: self];
|
[sub viewWillMoveToSuperview: self];
|
||||||
[sub setNextResponder: self];
|
[sub setNextResponder: self];
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue