Skip to content
Newer
Older
100644 145 lines (119 sloc) 3.28 KB
9fa3da5 Holy restructuring, batman! Watch out for falling folders.
andym authored
1 //
2 // SUStatusController.m
3 // Sparkle
4 //
5 // Created by Andy Matuschak on 3/14/06.
6 // Copyright 2006 Andy Matuschak. All rights reserved.
7 //
8
43a0a7d @uliwitness Merge of changes from SVN repository:
uliwitness authored
9 #import "SUUpdater.h"
10
11 #import "SUAppcast.h"
12 #import "SUAppcastItem.h"
13 #import "SUVersionComparisonProtocol.h"
9fa3da5 Holy restructuring, batman! Watch out for falling folders.
andym authored
14 #import "SUStatusController.h"
43a0a7d @uliwitness Merge of changes from SVN repository:
uliwitness authored
15 #import "SUHost.h"
16
5d44acb Finally got DMGs working properly on 10.5 through a somewhat less bri…
andym authored
17
9fa3da5 Holy restructuring, batman! Watch out for falling folders.
andym authored
18 @implementation SUStatusController
19
c42e3a3 @andymatuschak Fixed 251010
andymatuschak authored
20 - (id)initWithHost:(SUHost *)aHost
9fa3da5 Holy restructuring, batman! Watch out for falling folders.
andym authored
21 {
c42e3a3 @andymatuschak Fixed 251010
andymatuschak authored
22 self = [super initWithHost:aHost windowNibName:@"SUStatus"];
ef89e42 Fixed a potential buffer overrun, made sure to assign to self in -ini…
andym authored
23 if (self)
24 {
c42e3a3 @andymatuschak Fixed 251010
andymatuschak authored
25 host = [aHost retain];
ef89e42 Fixed a potential buffer overrun, made sure to assign to self in -ini…
andym authored
26 [self setShouldCascadeWindows:NO];
27 }
9fa3da5 Holy restructuring, batman! Watch out for falling folders.
andym authored
28 return self;
29 }
30
31 - (void)dealloc
32 {
98832c4 @andymatuschak Beginnings of insane SUHost-based refactoring to get rid of NSBundle+…
andymatuschak authored
33 [host release];
9fa3da5 Holy restructuring, batman! Watch out for falling folders.
andym authored
34 [title release];
35 [statusText release];
36 [buttonTitle release];
37 [super dealloc];
38 }
39
43a0a7d @uliwitness Merge of changes from SVN repository:
uliwitness authored
40 - (NSString *)description { return [NSString stringWithFormat:@"%@ <%@, %@>", [self class], [host bundlePath], [host installationPath]]; }
c386b70 @andymatuschak Partial fix for 245277: basic descriptions for some Sparkle classes. …
andymatuschak authored
41
9fa3da5 Holy restructuring, batman! Watch out for falling folders.
andym authored
42 - (void)awakeFromNib
43 {
2300f2b @ksuther Set the level of the update check status window to NSFloatingWindowLe…
ksuther authored
44 if ([host isBackgroundApplication]) {
45 [[self window] setLevel:NSFloatingWindowLevel];
46 }
47
9fa3da5 Holy restructuring, batman! Watch out for falling folders.
andym authored
48 [[self window] center];
49 [[self window] setFrameAutosaveName:@"SUStatusFrame"];
63011aa Beware of falling bricks! Huge refactoring commit #1: cleansing Spark…
andym authored
50 [progressBar setUsesThreadedAnimation:YES];
9fa3da5 Holy restructuring, batman! Watch out for falling folders.
andym authored
51 }
52
53 - (NSString *)windowTitle
54 {
98832c4 @andymatuschak Beginnings of insane SUHost-based refactoring to get rid of NSBundle+…
andymatuschak authored
55 return [NSString stringWithFormat:SULocalizedString(@"Updating %@", nil), [host name]];
9fa3da5 Holy restructuring, batman! Watch out for falling folders.
andym authored
56 }
57
58 - (NSImage *)applicationIcon
59 {
98832c4 @andymatuschak Beginnings of insane SUHost-based refactoring to get rid of NSBundle+…
andymatuschak authored
60 return [host icon];
9fa3da5 Holy restructuring, batman! Watch out for falling folders.
andym authored
61 }
62
63 - (void)beginActionWithTitle:(NSString *)aTitle maxProgressValue:(double)aMaxProgressValue statusText:(NSString *)aStatusText
64 {
65 [self willChangeValueForKey:@"title"];
66 title = [aTitle copy];
67 [self didChangeValueForKey:@"title"];
68
69 [self setMaxProgressValue:aMaxProgressValue];
70 [self setStatusText:aStatusText];
71 }
72
43a0a7d @uliwitness Merge of changes from SVN repository:
uliwitness authored
73 - (void)setButtonTitle:(NSString *)aButtonTitle target: (id)target action:(SEL)action isDefault:(BOOL)isDefault
9fa3da5 Holy restructuring, batman! Watch out for falling folders.
andym authored
74 {
75 [self willChangeValueForKey:@"buttonTitle"];
a5dcf94 @andymatuschak Fixed all setters to eliminate the possibility of accidentally releas…
andymatuschak authored
76 if (buttonTitle != aButtonTitle)
77 {
78 [buttonTitle release];
79 buttonTitle = [aButtonTitle copy];
80 }
9fa3da5 Holy restructuring, batman! Watch out for falling folders.
andym authored
81 [self didChangeValueForKey:@"buttonTitle"];
82
fe98a43 Fixed #6: status button now sizes to the localization. Thanks to Chri…
andym authored
83 [self window];
9fa3da5 Holy restructuring, batman! Watch out for falling folders.
andym authored
84 [actionButton sizeToFit];
85 // Except we're going to add 15 px for padding.
86 [actionButton setFrameSize:NSMakeSize([actionButton frame].size.width + 15, [actionButton frame].size.height)];
87 // Now we have to move it over so that it's always 15px from the side of the window.
88 [actionButton setFrameOrigin:NSMakePoint([[self window] frame].size.width - 15 - [actionButton frame].size.width, [actionButton frame].origin.y)];
89 // Redisplay superview to clean up artifacts
90 [[actionButton superview] display];
91
92 [actionButton setTarget:target];
93 [actionButton setAction:action];
94 [actionButton setKeyEquivalent:isDefault ? @"\r" : @""];
43a0a7d @uliwitness Merge of changes from SVN repository:
uliwitness authored
95
96 // 06/05/2008 Alex: Avoid a crash when cancelling during the extraction
27e8714 @uliwitness target is an ObjC object, so nil, not NULL.
uliwitness authored
97 [self setButtonEnabled: (target != nil)];
9fa3da5 Holy restructuring, batman! Watch out for falling folders.
andym authored
98 }
99
d6acd07 @andymatuschak Fixes 252733
andymatuschak authored
100 - (BOOL)progressBarShouldAnimate
101 {
102 return YES;
103 }
104
9fa3da5 Holy restructuring, batman! Watch out for falling folders.
andym authored
105 - (void)setButtonEnabled:(BOOL)enabled
106 {
107 [actionButton setEnabled:enabled];
108 }
109
110 - (double)progressValue
111 {
112 return progressValue;
113 }
114
115 - (void)setProgressValue:(double)value
116 {
117 progressValue = value;
118 }
119
120 - (double)maxProgressValue
121 {
122 return maxProgressValue;
123 }
124
125 - (void)setMaxProgressValue:(double)value
126 {
d7774c0 performed a code review, specifically:
Sean McBride authored
127 if (value < 0.0) value = 0.0;
9fa3da5 Holy restructuring, batman! Watch out for falling folders.
andym authored
128 maxProgressValue = value;
d7774c0 performed a code review, specifically:
Sean McBride authored
129 [self setProgressValue:0.0];
130 [progressBar setIndeterminate:(value == 0.0)];
3d7e8c6 @andymatuschak Fixes 244214
andymatuschak authored
131 [progressBar startAnimation:self];
983ad61 @uliwitness Maybe that makes the progress bar animate? No, it doesn't.
uliwitness authored
132 [progressBar setUsesThreadedAnimation: YES];
9fa3da5 Holy restructuring, batman! Watch out for falling folders.
andym authored
133 }
134
135 - (void)setStatusText:(NSString *)aStatusText
136 {
a5dcf94 @andymatuschak Fixed all setters to eliminate the possibility of accidentally releas…
andymatuschak authored
137 if (statusText != aStatusText)
138 {
139 [statusText release];
140 statusText = [aStatusText copy];
141 }
9fa3da5 Holy restructuring, batman! Watch out for falling folders.
andym authored
142 }
143
144 @end
Something went wrong with that request. Please try again.