Skip to content

Commit

Permalink
Disable the keyboard shortcut for the install button for scheduled up…
Browse files Browse the repository at this point in the history
…dates to avoid accidental installs.
  • Loading branch information
gnachman committed Feb 14, 2017
1 parent e1f67cf commit 40347c0
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 3 deletions.
4 changes: 4 additions & 0 deletions Sparkle/SUScheduledUpdateDriver.m
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,8 @@ - (void)abortUpdateWithError:(NSError *)error
}
}

- (BOOL)shouldDisableKeyboardShortcutForInstallButton {
return YES;
}

@end
14 changes: 11 additions & 3 deletions Sparkle/SUUIBasedUpdateDriver.m
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,20 @@ - (void)didFindValidUpdate
}

// Only show the update alert if the app is active; otherwise, we'll wait until it is.
if ([NSApp isActive])
[[self.updateAlert window] makeKeyAndOrderFront:self];
else
if ([NSApp isActive]) {
NSWindow *window = [self.updateAlert window];
if ([self shouldDisableKeyboardShortcutForInstallButton]) {
[self.updateAlert disableKeyboardShortcutForInstallButton];
}
[window makeKeyAndOrderFront:self];
} else
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationDidBecomeActive:) name:NSApplicationDidBecomeActiveNotification object:NSApp];
}

- (BOOL)shouldDisableKeyboardShortcutForInstallButton {
return NO;
}

- (void)didNotFindUpdate
{
id<SUUpdaterPrivate> updater = self.updater;
Expand Down
1 change: 1 addition & 0 deletions Sparkle/SUUpdateAlert.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ typedef NS_ENUM(NSInteger, SUUpdateAlertChoice) {
- (IBAction)installUpdate:sender;
- (IBAction)skipThisVersion:sender;
- (IBAction)remindMeLater:sender;
- (void)disableKeyboardShortcutForInstallButton;

@end

Expand Down
3 changes: 3 additions & 0 deletions Sparkle/SUUpdateAlert.m
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@ - (instancetype)initWithAppcastItem:(SUAppcastItem *)item host:(SUHost *)aHost c

- (NSString *)description { return [NSString stringWithFormat:@"%@ <%@>", [self class], [self.host bundlePath]]; }

- (void)disableKeyboardShortcutForInstallButton {
self.installButton.keyEquivalent = @"";
}

- (void)endWithSelection:(SUUpdateAlertChoice)choice
{
Expand Down

0 comments on commit 40347c0

Please sign in to comment.