Allow popup titlebar user driver to update other bundles

This commit is contained in:
Zorg committed 2016-08-13 08:49:47 -04:00
1 parent 6fb7b4a18b
commit b58773cb5e
6 files changed
+16 -10

No files matched your search

+1 -1
View File
@@ -13,6 +13,6 @@
@interface SUPopUpTitlebarUserDriver : NSObject <SPUUserDriver, SPUStandardUserDriverProtocol>
- (instancetype)initWithWindow:(NSWindow *)window delegate:(id<SPUStandardUserDriverDelegate>)delegate;
- (instancetype)initWithHostBundle:(NSBundle *)hostBundle window:(NSWindow *)window delegate:(id<SPUStandardUserDriverDelegate>)delegate;
@end
+6 -2
View File
@@ -14,6 +14,7 @@
@interface SUPopUpTitlebarUserDriver()
@property (nonatomic, readonly) NSBundle *hostBundle;
@property (nonatomic, readonly) NSWindow *window;
@property (nonatomic, readonly) SPUUserDriverCoreComponent *coreComponent;
@property (nonatomic) NSTitlebarAccessoryViewController *accessoryViewController;
@@ -28,6 +29,7 @@
@implementation SUPopUpTitlebarUserDriver
@synthesize delegate = _delegate;
@synthesize hostBundle = _hostBundle;
@synthesize window = _window;
@synthesize coreComponent = _coreComponent;
@synthesize accessoryViewController = _accessoryViewController;
@@ -37,10 +39,11 @@
@synthesize expectedContentLength = _expectedContentLength;
@synthesize contentLengthDownloaded = _contentLengthDownloaded;
- (instancetype)initWithWindow:(NSWindow *)window delegate:(id<SPUStandardUserDriverDelegate>)delegate
- (instancetype)initWithHostBundle:(NSBundle *)hostBundle window:(NSWindow *)window delegate:(id<SPUStandardUserDriverDelegate>)delegate
{
self = [super init];
if (self != nil) {
_hostBundle = hostBundle;
_window = window;
_delegate = delegate;
_coreComponent = [[SPUUserDriverCoreComponent alloc] initWithDelegate:delegate];
@@ -316,7 +319,8 @@
// In case our termination request fails or is delayed
[self removeUpdateButton];
[[NSApplication sharedApplication] terminate:nil];
NSRunningApplication *runningApplication = [SPUApplicationInfo runningApplicationWithBundle:self.hostBundle];
[runningApplication terminate];
});
}
@@ -29,18 +29,18 @@
- (void)windowDidLoad
{
NSBundle *mainBundle = [NSBundle mainBundle];
NSBundle *hostBundle = [NSBundle mainBundle];
// If the user is holding down command, we use the popup title user driver instead
id<SPUUserDriver, SPUStandardUserDriverProtocol> userDriver;
if (([NSEvent modifierFlags] & NSCommandKeyMask) != 0) {
userDriver = [[SUPopUpTitlebarUserDriver alloc] initWithWindow:self.window delegate:nil];
userDriver = [[SUPopUpTitlebarUserDriver alloc] initWithHostBundle:hostBundle window:self.window delegate:nil];
} else {
userDriver = [[SPUStandardUserDriver alloc] initWithHostBundle:mainBundle delegate:nil];
userDriver = [[SPUStandardUserDriver alloc] initWithHostBundle:hostBundle delegate:nil];
}
self.userDriver = userDriver;
self.updater = [[SPUUpdater alloc] initWithHostBundle:mainBundle userDriver:userDriver delegate:nil];
self.updater = [[SPUUpdater alloc] initWithHostBundle:hostBundle userDriver:userDriver delegate:nil];
NSError *updaterError = nil;
if (![self.updater startUpdater:&updaterError]) {