Removed update alert delegate

This commit is contained in:
Kornel Lesiński committed 2015-04-25 20:37:01 +01:00
1 parent 3680b0bb67
commit 35dfed44de
4 files changed
+14 -24

No files matched your search

+1 -1
View File
@@ -15,7 +15,7 @@
@class SUStatusController;
@interface SUUIBasedUpdateDriver : SUBasicUpdateDriver <SUUnarchiverDelegate, SUUpdateAlertDelegate>
@interface SUUIBasedUpdateDriver : SUBasicUpdateDriver <SUUnarchiverDelegate>
- (void)showModalAlert:(NSAlert *)alert;
- (IBAction)cancelDownload:(id)sender;
+6 -7
View File
@@ -28,8 +28,9 @@
- (void)didFindValidUpdate
{
self.updateAlert = [[SUUpdateAlert alloc] initWithAppcastItem:self.updateItem host:self.host];
[self.updateAlert setDelegate:self];
self.updateAlert = [[SUUpdateAlert alloc] initWithAppcastItem:self.updateItem host:self.host completionBlock:^(SUUpdateAlertChoice choice) {
[self updateAlertFinishedWithChoice:choice];
}];
id<SUVersionDisplay> versDisp = nil;
if ([[self.updater delegate] respondsToSelector:@selector(versionDisplayerForUpdater:)]) {
@@ -44,8 +45,7 @@
// If the app is a menubar app or the like, we need to focus it first and alter the
// update prompt to behave like a normal window. Otherwise if the window were hidden
// there may be no way for the application to be activated to make it visible again.
if ([self.host isBackgroundApplication])
{
if ([self.host isBackgroundApplication]) {
[[self.updateAlert window] setHidesOnDeactivate:NO];
[NSApp activateIgnoringOtherApps:YES];
}
@@ -78,12 +78,11 @@
[[NSNotificationCenter defaultCenter] removeObserver:self name:NSApplicationDidBecomeActiveNotification object:NSApp];
}
- (void)updateAlert:(SUUpdateAlert *)__unused alert finishedWithChoice:(SUUpdateAlertChoice)choice
- (void)updateAlertFinishedWithChoice:(SUUpdateAlertChoice)choice
{
self.updateAlert = nil;
[self.host setObject:nil forUserDefaultsKey:SUSkippedVersionKey];
switch (choice)
{
switch (choice) {
case SUInstallUpdateChoice:
self.statusController = [[SUStatusController alloc] initWithHost:self.host];
[self.statusController beginActionWithTitle:SULocalizedString(@"Downloading update...", @"Take care not to overflow the status window.") maxProgressValue:0.0 statusText:nil];
+1 -8
View File
@@ -24,10 +24,9 @@ typedef NS_ENUM(NSInteger, SUUpdateAlertChoice) {
@class WebView, SUAppcastItem, SUHost;
@interface SUUpdateAlert : SUWindowController
@property (weak) id<SUUpdateAlertDelegate> delegate;
@property (weak) id<SUVersionDisplay> versionDisplayer;
- (instancetype)initWithAppcastItem:(SUAppcastItem *)item host:(SUHost *)host;
- (instancetype)initWithAppcastItem:(SUAppcastItem *)item host:(SUHost *)host completionBlock:(void(^)(SUUpdateAlertChoice))c;
- (IBAction)installUpdate:sender;
- (IBAction)skipThisVersion:sender;
@@ -35,10 +34,4 @@ typedef NS_ENUM(NSInteger, SUUpdateAlertChoice) {
@end
@protocol SUUpdateAlertDelegate <NSObject>
- (void)updateAlert:(SUUpdateAlert *)updateAlert finishedWithChoice:(SUUpdateAlertChoice)updateChoice;
@optional
- (void)updateAlert:(SUUpdateAlert *)updateAlert shouldAllowAutoUpdate:(BOOL *)shouldAllowAutoUpdate;
@end
#endif
+6 -8
View File
@@ -21,6 +21,7 @@
@property (strong) SUAppcastItem *updateItem;
@property (strong) SUHost *host;
@property (strong) void(^completionBlock)(SUUpdateAlertChoice);
@property (strong) NSProgressIndicator *releaseNotesSpinner;
@property (assign) BOOL webViewFinishedLoading;
@@ -36,7 +37,7 @@
@implementation SUUpdateAlert
@synthesize delegate;
@synthesize completionBlock;
@synthesize versionDisplayer;
@synthesize updateItem;
@@ -52,11 +53,12 @@
@synthesize skipButton;
@synthesize laterButton;
- (instancetype)initWithAppcastItem:(SUAppcastItem *)item host:(SUHost *)aHost
- (instancetype)initWithAppcastItem:(SUAppcastItem *)item host:(SUHost *)aHost completionBlock:(void (^)(SUUpdateAlertChoice))block
{
self = [super initWithWindowNibName:@"SUUpdateAlert"];
if (self)
{
self.completionBlock = block;
host = aHost;
updateItem = item;
[self setShouldCascadeWindows:NO];
@@ -79,8 +81,8 @@
[self.releaseNotesView setPolicyDelegate:nil];
[self.releaseNotesView removeFromSuperview]; // Otherwise it gets sent Esc presses (why?!) and gets very confused.
[self close];
if ([self.delegate respondsToSelector:@selector(updateAlert:finishedWithChoice:)])
[self.delegate updateAlert:self finishedWithChoice:choice];
self.completionBlock(choice);
self.completionBlock = nil;
}
- (IBAction)installUpdate:(id)__unused sender
@@ -164,10 +166,6 @@
if ([self.host objectForInfoDictionaryKey:SUAllowsAutomaticUpdatesKey])
allowAutoUpdates = [self.host boolForInfoDictionaryKey:SUAllowsAutomaticUpdatesKey];
// Give delegate a chance to modify this choice:
if (self.delegate && [self.delegate respondsToSelector:@selector(updateAlert:shouldAllowAutoUpdate:)])
[self.delegate updateAlert:self shouldAllowAutoUpdate:&allowAutoUpdates];
return allowAutoUpdates;
}