forked from gnachman/iTerm2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBounceTrigger.m
92 lines (75 loc) · 1.74 KB
/
BounceTrigger.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
//
// BounceTrigger.m
// iTerm
//
// Created by George Nachman on 9/23/11.
//
#import "BounceTrigger.h"
// How to bounce. The parameter takes an integer value equal to one of these. This is the tag.
enum {
kBounceTriggerParamTagBounceUntilFocus,
kBounceTriggerParamTagBounceOnce,
};
@implementation BounceTrigger
- (NSString *)title
{
return @"Bounce Dock Icon";
}
- (NSString *)paramPlaceholder
{
return @"";
}
- (BOOL)takesParameter
{
return YES;
}
- (BOOL)paramIsPopupButton
{
return YES;
}
- (int)indexOfTag:(int)theTag
{
int i = 0;
for (NSNumber *n in [self tagsSortedByValueInDict:[self menuItemsForPoupupButton]]) {
if ([n intValue] == theTag) {
return i;
}
i++;
}
return -1;
}
- (int)tagAtIndex:(int)index
{
int i = 0;
for (NSNumber *n in [self tagsSortedByValueInDict:[self menuItemsForPoupupButton]]) {
if (i == index) {
return [n intValue];
}
i++;
}
return -1;
}
- (NSDictionary *)menuItemsForPoupupButton
{
return @{ @(kBounceTriggerParamTagBounceUntilFocus): @"Bounce Until Activated",
@(kBounceTriggerParamTagBounceOnce): @"Bounce Once" };
}
- (NSRequestUserAttentionType)bounceType
{
switch ([self.param intValue]) {
case kBounceTriggerParamTagBounceUntilFocus:
return NSCriticalRequest;
case kBounceTriggerParamTagBounceOnce:
return NSInformationalRequest;
default:
return NSCriticalRequest;
}
}
- (void)performActionWithValues:(NSArray *)values inSession:(PTYSession *)aSession
{
[NSApp requestUserAttention:[self bounceType]];
}
- (int)defaultIndex {
return [self indexOfTag:kBounceTriggerParamTagBounceUntilFocus];
}
@end