Minor cleanup

This commit is contained in:
michael starke
2014-10-27 21:42:05 +01:00
parent 3e3a2bf644
commit a14b535d22
2 changed files with 1 additions and 15 deletions

View File

@@ -27,11 +27,6 @@
NSString *const kMPWindowTitleKey = @"kMPWindowTitleKey"; NSString *const kMPWindowTitleKey = @"kMPWindowTitleKey";
NSString *const kMPProcessIdentifierKey = @"kMPProcessIdentifierKey"; NSString *const kMPProcessIdentifierKey = @"kMPProcessIdentifierKey";
/*
Enable to activate autotype
*/
#define MP_AUTOTYPE
@interface MPAutotypeDaemon () @interface MPAutotypeDaemon ()
@property (nonatomic, assign) BOOL enabled; @property (nonatomic, assign) BOOL enabled;
@@ -76,23 +71,17 @@ NSString *const kMPProcessIdentifierKey = @"kMPProcessIdentifierKey";
- (void)setEnabled:(BOOL)enabled { - (void)setEnabled:(BOOL)enabled {
if(_enabled != enabled) { if(_enabled != enabled) {
_enabled = enabled; _enabled = enabled;
#ifdef MP_AUTOTYPE
self.enabled ? [self _registerHotKey] : [self _unregisterHotKey]; self.enabled ? [self _registerHotKey] : [self _unregisterHotKey];
#endif
} }
} }
- (void)setHotKeyData:(NSData *)hotKeyData { - (void)setHotKeyData:(NSData *)hotKeyData {
if(![_hotKeyData isEqualToData:hotKeyData]) { if(![_hotKeyData isEqualToData:hotKeyData]) {
#ifdef MP_AUTOTYPE
[self _unregisterHotKey]; [self _unregisterHotKey];
#endif
_hotKeyData = [hotKeyData copy]; _hotKeyData = [hotKeyData copy];
#ifdef MP_AUTOTYPE
if(self.enabled) { if(self.enabled) {
[self _registerHotKey]; [self _registerHotKey];
} }
#endif
} }
} }
@@ -178,9 +167,7 @@ NSString *const kMPProcessIdentifierKey = @"kMPProcessIdentifierKey";
NSArray *commands = [MPAutotypeCommand commandsForContext:context]; NSArray *commands = [MPAutotypeCommand commandsForContext:context];
if([MPAutotypeDaemon _orderApplicationToFront:self.targetPID]) { if([MPAutotypeDaemon _orderApplicationToFront:self.targetPID]) {
/* Sleep a bit after the app was activated */ /* Sleep a bit after the app was activated */
NSLog(@"App wasn't frontmost, did order it there. Waiting a bit.");
usleep(0.5 * NSEC_PER_MSEC); usleep(0.5 * NSEC_PER_MSEC);
NSLog(@"Done waiting.");
} }
for(MPAutotypeCommand *command in commands) { for(MPAutotypeCommand *command in commands) {
[command execute]; [command execute];

View File

@@ -49,7 +49,7 @@
[self.enableGlobalAutotypeCheckbutton bind:NSValueBinding toObject:defaultsController withKeyPath:enableGlobalAutotypeKeyPath options:nil]; [self.enableGlobalAutotypeCheckbutton bind:NSValueBinding toObject:defaultsController withKeyPath:enableGlobalAutotypeKeyPath options:nil];
[self.enableQuicklookCheckbutton bind:NSValueBinding toObject:defaultsController withKeyPath:quicklookKeyPath options:nil]; [self.enableQuicklookCheckbutton bind:NSValueBinding toObject:defaultsController withKeyPath:quicklookKeyPath options:nil];
[self.hotKeyTextField bind:NSEnabledBinding toObject:defaultsController withKeyPath:enableGlobalAutotypeKeyPath options:nil]; [self.hotKeyTextField bind:NSEnabledBinding toObject:defaultsController withKeyPath:enableGlobalAutotypeKeyPath options:nil];
[self.hotKeyTextField bind:NSStringFromSelector(@selector(hotKey)) toObject:self withKeyPath:NSStringFromSelector(@selector(hotKey)) options:nil]; self.hotKeyTextField.hotKey = self.hotKey;
} }
- (void)setHotKey:(DDHotKey *)hotKey { - (void)setHotKey:(DDHotKey *)hotKey {
@@ -65,5 +65,4 @@
_hotKey = hotKey; _hotKey = hotKey;
} }
@end @end