diff --git a/ChangeLog b/ChangeLog index e83068a9..6b06f442 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,19 @@ +2005-01-22 12:14 Gregory John Casamento + + * GormDocument.m: In [GormDocument detachObject:] made + [GormDocument setObject:isVisibleAtLaunch:] called only when the + object is an NSWindow subclass. + * GormImageEditor.m: Added implementation of addObject: to + prevent addition of duplicate images. + * GormImage.h: Added isEqual: so that containsObject: can + find the image. + * GormImage.m: Added isEqual: declaration. + * GormSoundEditor.m: Added implementation of addObject to + prevent addition of duplicate sounds. + * GormSound.h: Added isEqual: so that containsObject can + find the sound. + * GormSound.m: Added isEqual: declaration. + 2005-01-11 22:04 Gregory John Casamento * GModelDecoder.m: Default NSWindows being imported from the diff --git a/GormDocument.m b/GormDocument.m index 4a01b854..901d2ad1 100644 --- a/GormDocument.m +++ b/GormDocument.m @@ -1004,10 +1004,13 @@ static NSImage *fileImage = nil; } /* - * Make sure this object isn't in the list of objects to be made visible + * Make sure this window isn't in the list of objects to be made visible * on nib loading. */ - [self setObject: anObject isVisibleAtLaunch: NO]; + if([anObject isKindOfClass: [NSWindow class]]) + { + [self setObject: anObject isVisibleAtLaunch: NO]; + } // some objects are given a name, some are not. The only ones we need // to worry about are those that have names. diff --git a/GormImage.h b/GormImage.h index edc5d7e0..46f20486 100644 --- a/GormImage.h +++ b/GormImage.h @@ -63,6 +63,7 @@ - (NSString *)inspectorClassName; - (NSImage *)image; - (NSImage *)normalImage; +- (BOOL) isEqual: (id)object; @end /** diff --git a/GormImage.m b/GormImage.m index 35d603c5..eb3ba41c 100644 --- a/GormImage.m +++ b/GormImage.m @@ -205,4 +205,18 @@ { return @"GormNotApplicableInspector"; } + +- (BOOL) isEqual: (id)object +{ + BOOL result = NO; + + if(object == self) + result = YES; + else if([object isKindOfClass: [self class]] == NO) + result = NO; + else if([[self imageName] isEqual: [object imageName]]) + result = YES; + + return result; +} @end diff --git a/GormImageEditor.m b/GormImageEditor.m index 3cdee613..fce42c2b 100644 --- a/GormImageEditor.m +++ b/GormImageEditor.m @@ -274,6 +274,22 @@ static int handled_mask= NSDragOperationCopy|NSDragOperationGeneric|NSDragOperat NSMapRemove(docMap,document); } +- (void) addObject: (id)anObject +{ + if([objects containsObject: anObject] == NO) + { + [super addObject: anObject]; + } + else + { + NSRunAlertPanel (_(@"Problem adding image"), + _(@"An image with the same name exists, remove it first."), + _(@"OK"), + nil, + nil); + } +} + - (void) makeSelectionVisible: (BOOL)flag { if (flag == YES && selected != nil) diff --git a/GormSound.h b/GormSound.h index 8c0587f6..8c255c19 100644 --- a/GormSound.h +++ b/GormSound.h @@ -59,6 +59,7 @@ - (void) setInWrapper: (BOOL)flag; - (BOOL) isInWrapper; - (NSString *)inspectorClassName; +- (BOOL) isEqual: (id)object; @end #endif diff --git a/GormSound.m b/GormSound.m index 561656b5..f83a47c3 100644 --- a/GormSound.m +++ b/GormSound.m @@ -136,4 +136,18 @@ { return @"GormNotApplicableInspector"; } + +- (BOOL) isEqual: (id)object +{ + BOOL result = NO; + + if(object == self) + result = YES; + else if([object isKindOfClass: [self class]] == NO) + result = NO; + else if([[self soundName] isEqual: [object soundName]]) + result = YES; + + return result; +} @end diff --git a/GormSoundEditor.m b/GormSoundEditor.m index 7eb7b0cb..18640349 100644 --- a/GormSoundEditor.m +++ b/GormSoundEditor.m @@ -265,6 +265,22 @@ static NSMapTable *docMap = 0; NSMapRemove(docMap,document); } +- (void) addObject: (id)anObject +{ + if([objects containsObject: anObject] == NO) + { + [super addObject: anObject]; + } + else + { + NSRunAlertPanel (_(@"Problem adding sound"), + _(@"An sound with the same name exists, remove it first."), + _(@"OK"), + nil, + nil); + } +} + - (void) makeSelectionVisible: (BOOL)flag { if (flag == YES && selected != nil)