forked from pmougin/F-Script
-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathFSObjectBrowserToolbarItem.m
41 lines (34 loc) · 1.15 KB
/
FSObjectBrowserToolbarItem.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/* FSObjectBrowserToolbarItem.m Copyright (c) 2002-2009 Philippe Mougin. */
/* This software is open source. See the license. */
#import "FSObjectBrowserToolbarItem.h"
#import "FSObjectBrowserToolbarButton.h"
#import "FSBlock.h"
#import "FSObjectBrowserView.h"
@implementation FSObjectBrowserToolbarItem
- (void)validate
{
NSInteger argumentCount = 0; // intitialization of argumentCount in order to avoid a warning
NSString *identifier = [self itemIdentifier];
[self setEnabled:YES];
if ([[self view] isKindOfClass:[FSObjectBrowserToolbarButton class]])
{
@try
{
argumentCount = [[(FSObjectBrowserToolbarButton *)[self view] block] argumentCount];
}
@catch (id exception)
{
argumentCount = 0;
}
}
if ( [identifier isEqualToString:@"Name"]
|| [identifier isEqualToString:@"Self"]
|| [identifier isEqualToString:@"Inspect"]
|| [identifier isEqualToString:@"Browse"]
|| ([[self view] isKindOfClass:[FSObjectBrowserToolbarButton class]] && argumentCount != 0))
{
if ([[(NSButton *)[self view] target] selectedObject] == nil)
[self setEnabled:NO];
}
}
@end