X-Git-Url: https://git.yukkurigames.com/?p=enjoyable.git;a=blobdiff_plain;f=Classes%2FEnjoyableApplicationDelegate.m;h=017926a807e0bf64d644bc3bf115e18f787a92f5;hp=b21ee77ec4fff58d8ad699b2a26b0ecd86f33e5c;hb=0a8d6333a3ac4684b70ab7f3581a93bf96638d6f;hpb=479e7966da759a6b113850961bde029407b277be diff --git a/Classes/EnjoyableApplicationDelegate.m b/Classes/EnjoyableApplicationDelegate.m index b21ee77..017926a 100644 --- a/Classes/EnjoyableApplicationDelegate.m +++ b/Classes/EnjoyableApplicationDelegate.m @@ -5,8 +5,6 @@ // Created by Sam McCall on 4/05/09. // -#import - #import "EnjoyableApplicationDelegate.h" #import "NJMapping.h" @@ -112,6 +110,8 @@ - (void)eventSimulationStarted:(NSNotification *)note { self.simulatingEventsButton.state = NSOnState; statusItem.image = [NSImage imageNamed:@"Status Menu Icon"]; + [NSProcessInfo.processInfo + disableAutomaticTermination:@"Event simulation running."]; [NSWorkspace.sharedWorkspace.notificationCenter addObserver:self selector:@selector(didSwitchApplication:) @@ -122,6 +122,8 @@ - (void)eventSimulationStopped:(NSNotification *)note { self.simulatingEventsButton.state = NSOffState; statusItem.image = [NSImage imageNamed:@"Status Menu Icon Disabled"]; + [NSProcessInfo.processInfo + enableAutomaticTermination:@"Event simulation running."]; [NSWorkspace.sharedWorkspace.notificationCenter removeObserver:self name:NSWorkspaceDidActivateApplicationNotification @@ -201,47 +203,6 @@ [self.mvc mappingTriggerClicked:self]; } -- (void)loginItemPromptDidEnd:(NSWindow *)sheet - returnCode:(int)returnCode - contextInfo:(void *)contextInfo { - if (returnCode == NSAlertDefaultReturn) { - [NSRunningApplication.currentApplication addToLoginItems]; - // If we're going to automatically start, don't bug the user - // about automatic updates next boot - they probably want it, - // and if they don't they probably want a prompt for it less. - SUUpdater.sharedUpdater.automaticallyChecksForUpdates = YES; - } -} - -- (void)loginItemPromptDidDismiss:(NSWindow *)sheet - returnCode:(int)returnCode - contextInfo:(void *)contextInfo { - [NSUserDefaults.standardUserDefaults setBool:YES forKey:@"explained login items"]; - [self.window performClose:sheet]; -} - -- (BOOL)windowShouldClose:(NSWindow *)sender { - if (sender != self.window - || NSRunningApplication.currentApplication.isLoginItem - || [NSUserDefaults.standardUserDefaults boolForKey:@"explained login items"]) - return YES; - NSBeginAlertSheet( - NSLocalizedString(@"login items prompt", @"alert prompt for adding to login items"), - NSLocalizedString(@"login items add button", @"button to add to login items"), - NSLocalizedString(@"login items don't add button", @"button to not add to login items"), - nil, self.window, self, - @selector(loginItemPromptDidEnd:returnCode:contextInfo:), - @selector(loginItemPromptDidDismiss:returnCode:contextInfo:), - NULL, - NSLocalizedString(@"login items explanation", @"a brief explanation of login items") - ); - for (int i = 0; i < 10; ++i) - [self performSelector:@selector(flashStatusItem) - withObject:self - afterDelay:0.5 * i]; - return NO; -} - - (void)importMappingClicked:(id)sender { NSOpenPanel *panel = [NSOpenPanel openPanel]; panel.allowedFileTypes = @[ @"enjoyable", @"json", @"txt" ]; @@ -338,8 +299,7 @@ - (void)mappingsViewController:(NJMappingsViewController *)mvc renameMappingAtIndex:(NSInteger)index toName:(NSString *)name { - [self.ic renameMapping:self.ic.mappings[index] - to:name]; + [self.ic renameMapping:self.ic.mappings[index] to:name]; } - (BOOL)mappingsViewController:(NJMappingsViewController *)mvc