-
Notifications
You must be signed in to change notification settings - Fork 1
/
aLgrTepy2eAppDelegate.m
71 lines (58 loc) · 1.89 KB
/
aLgrTepy2eAppDelegate.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
//
// aLgrTepy2eAppDelegate.m
//
// Created 2009.09.01.
// Copyright 2009-2016 Dominic Yu. All rights reserved.
//
#import "aLgrTepy2eAppDelegate.h"
#import "DYLargeTextView.h"
@interface aLgrTepy2eAppDelegate () {
BOOL launchedAsService;
}
@end
@implementation aLgrTepy2eAppDelegate
- (void)largeType:(NSPasteboard *)pboard
userData:(NSString *)userData error:(NSString **)error {
launchedAsService = YES;
// Test for strings on the pasteboard.
if (![pboard canReadObjectForClasses:@[[NSString class]]
options:@{}]) {
*error = NSLocalizedString(@"Error: couldn't encrypt text.",
@"pboard couldn't give string.");
return;
}
// Get the string.
NSString *s = [pboard stringForType:NSPasteboardTypeString];
[_window.contentView setDisplayString:s demo:NO];
}
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
NSUserDefaults *standardDefaults = [NSUserDefaults standardUserDefaults];
NSString *argumentString = [standardDefaults stringForKey:@"s"];
if (argumentString) {
launchedAsService = YES;
[_window.contentView setDisplayString:argumentString demo:NO];
[NSApp activateIgnoringOtherApps:YES];
}
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(largeTextDone:)
name:NSWindowDidResignKeyNotification
object:_window];
NSApp.servicesProvider = self;
[NSTimer scheduledTimerWithTimeInterval:1.0 target:self
selector:@selector(showPrefsWindow:)
userInfo:nil repeats:NO];
}
- (void)showPrefsWindow:(NSTimer *)t {
if (launchedAsService)
return;
[_window.contentView setDisplayString:@"A noble spirit\nembiggens the smallest man."
demo:YES];
[_prefsWindow center];
[_prefsWindow makeKeyAndOrderFront:nil];
[NSApp activateIgnoringOtherApps:YES];
}
- (void)largeTextDone:(NSNotification *)n {
if (launchedAsService)
[NSApp terminate:nil];
}
@end