/
SUAutomaticUpdateAlert.m
68 lines (54 loc) · 1.69 KB
/
SUAutomaticUpdateAlert.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
//
// SUAutomaticUpdateAlert.m
// Sparkle
//
// Created by Andy Matuschak on 3/18/06.
// Copyright 2006 Andy Matuschak. All rights reserved.
//
#import "Sparkle.h"
#import "SUAutomaticUpdateAlert.h"
@implementation SUAutomaticUpdateAlert
- (id)initWithAppcastItem:(SUAppcastItem *)item hostBundle:(NSBundle *)hb;
{
updateItem = [item retain];
hostBundle = [hb retain];
NSString *path = [[NSBundle bundleForClass:[self class]] pathForResource:@"SUAutomaticUpdateAlert" ofType:@"nib"];
if (path == nil) // Slight hack to resolve issues with running Sparkle in debug configurations.
{
NSString *frameworkPath = [[hostBundle sharedFrameworksPath] stringByAppendingPathComponent:@"Sparkle.framework"];
NSBundle *framework = [NSBundle bundleWithPath:frameworkPath];
path = [framework pathForResource:@"SUAutomaticUpdateAlert" ofType:@"nib"];
}
self = [super initWithWindowNibPath:path owner:self];
[self setShouldCascadeWindows:NO];
return self;
}
- (void) dealloc
{
[hostBundle release];
[updateItem release];
[super dealloc];
}
- (IBAction)relaunchNow:sender
{
[self close];
[NSApp stopModalWithCode:NSAlertDefaultReturn];
}
- (IBAction)relaunchLater:sender
{
[self close];
[NSApp stopModalWithCode:NSAlertAlternateReturn];
}
- (NSImage *)applicationIcon
{
return [hostBundle icon];
}
- (NSString *)titleText
{
return [NSString stringWithFormat:SULocalizedString(@"A new version of %@ has been installed!", nil), [hostBundle name]];
}
- (NSString *)descriptionText
{
return [NSString stringWithFormat:SULocalizedString(@"%1$@ %2$@ has been installed and will be ready to use next time %1$@ starts! Would you like to relaunch now?", nil), [hostBundle name], [hostBundle displayVersion]];
}
@end