Added some code to disable menu items. Simplified isTopLevelObject: method.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/apps/gorm/trunk@19869 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Gregory John Casamento 2004-08-13 01:37:18 +00:00
parent 0855692228
commit f31d2c70e3
3 changed files with 51 additions and 26 deletions

View file

@ -1,3 +1,12 @@
2004-08-12 21:41 Gregory John Casamento <greg_casamento@yahoo.com>
* Gorm.m: [Gorm validateMenuItem:] deselect the cut, delete,
paste, etc. items for top level objects which cannot be
removed.
* GormDocument.m: Simplified implementation of
[GormDocument isTopLevelObject:] to simply check in the
set of top level objects.
2004-08-11 22:41 Gregory John Casamento <greg_casamento@yahoo.com>
* GormDocument.[hm]: Added back isTopLevelObject:.

47
Gorm.m
View file

@ -1234,6 +1234,7 @@ NSString *GormResizeCellNotification = @"GormResizeCellNotification";
GormDocument *active = (GormDocument*)[self activeDocument];
SEL action = [item action];
GormClassManager *cm = [active classManager];
NSArray *s = [selectionOwner selection];
if (sel_eq(action, @selector(close:))
|| sel_eq(action, @selector(miniaturize:))
@ -1257,30 +1258,66 @@ NSString *GormResizeCellNotification = @"GormResizeCellNotification";
}
else if (sel_eq(action, @selector(copy:)))
{
if ([[selectionOwner selection] count] == 0)
if ([s count] == 0)
return NO;
else
{
id o = [s objectAtIndex: 0];
NSString *n = [active nameForObject: o];
if ([n isEqual: @"NSOwner"] || [n isEqual: @"NSFirst"])
{
return NO;
}
}
return [selectionOwner respondsToSelector: @selector(copySelection)];
}
else if (sel_eq(action, @selector(cut:)))
{
if ([[selectionOwner selection] count] == 0)
if ([s count] == 0)
return NO;
else
{
id o = [s objectAtIndex: 0];
NSString *n = [active nameForObject: o];
if ([n isEqual: @"NSOwner"] || [n isEqual: @"NSFirst"])
{
return NO;
}
}
return ([selectionOwner respondsToSelector: @selector(copySelection)]
&& [selectionOwner respondsToSelector: @selector(deleteSelection)]);
}
else if (sel_eq(action, @selector(delete:)))
{
if ([[selectionOwner selection] count] == 0)
if ([s count] == 0)
return NO;
else
{
id o = [s objectAtIndex: 0];
NSString *n = [active nameForObject: o];
if ([n isEqual: @"NSOwner"] || [n isEqual: @"NSFirst"])
{
return NO;
}
}
return [selectionOwner respondsToSelector: @selector(deleteSelection)];
}
else if (sel_eq(action, @selector(paste:)))
{
id o = [s objectAtIndex: 0];
NSString *n = [active nameForObject: o];
if ([n isEqual: @"NSOwner"] || [n isEqual: @"NSFirst"])
{
return NO;
}
return [selectionOwner respondsToSelector: @selector(pasteInSelection)];
}
else if (sel_eq(action, @selector(setName:)))
{
NSArray *s = [selectionOwner selection];
NSString *n;
id o;
@ -1347,7 +1384,6 @@ NSString *GormResizeCellNotification = @"GormResizeCellNotification";
sel_eq(action, @selector(createClassFiles:)) ||
sel_eq(action, @selector(remove:)))
{
NSArray *s = [selectionOwner selection];
id o = nil;
NSString *name = nil;
@ -1373,7 +1409,6 @@ NSString *GormResizeCellNotification = @"GormResizeCellNotification";
if(sel_eq(action, @selector(instantiateClass:)))
{
NSArray *s = [selectionOwner selection];
id o = nil;
NSString *name = nil;

View file

@ -3523,26 +3523,7 @@ static NSImage *fileImage = nil;
- (BOOL) isTopLevelObject: (id)obj
{
BOOL result = NO;
if ([obj isKindOfClass: [NSMenu class]] == YES)
{
if ([self objectForName: @"NSMenu"] == obj)
{
result = YES;
}
}
else if ([obj isKindOfClass: [NSWindow class]] == YES)
{
result = YES;
}
else if ([obj isKindOfClass: [GSNibItem class]] == YES &&
[obj isKindOfClass: [GormCustomView class]] == NO)
{
result = YES;
}
return result;
return [topLevelObjects containsObject: obj];
}
- (id) firstResponder