mirror of
https://github.com/sparkle-project/Sparkle
synced 2026-11-24 04:38:16 +00:00
- changed some #include to #import - fixed some NULL -> nil Cocoa coding conventions - added new compiler warnings and fixed some warnings they generated - check for nil from NSTemporaryDirectory - added missing files to unit test and test app targets - added xcconfig files for unit test target - added @private to some ivars - changes some variables from signed to unsigned as appropriate - changed from base 2 to base 10 measurements of file size, consistent with both the actual meaning of metric prefixes and Apple's new policy as of 10.6 - reduced some unneeded copy-paste of code - fixed failure to check for null from malloc and unneeded check against null before calling free - OSErr was incorrectly used instead of OSStatus - added some consts & statics to global strings - fixed some issues discovered by static analysis - fixed some 64bit issues, mostly related to casting and the use of slightly incorrect types/sizes - some dealloc methods were using accessors, changed to access ivars directly, as per Apple guidelines - removed old NS_DURING, NS_HANDLER, NS_ENDHANDLER macros - fixed a bug where immutable data was being mutated - removed all instance of "== YES" as they are dangerous - removed some redundant nil checks - fixed some leaks - conditionally replaced deprecated method usage - cleanup CF/NSMakeCollectable usage - fixed bug in GC where memory could be collected too early due to lack of strong references when using UTF8String - prevent passing null to CFRelease
131 lines
2.9 KiB
Objective-C
131 lines
2.9 KiB
Objective-C
//
|
|
// SUStatusController.m
|
|
// Sparkle
|
|
//
|
|
// Created by Andy Matuschak on 3/14/06.
|
|
// Copyright 2006 Andy Matuschak. All rights reserved.
|
|
//
|
|
|
|
#import "Sparkle.h"
|
|
#import "SUStatusController.h"
|
|
|
|
@implementation SUStatusController
|
|
|
|
- (id)initWithHost:(SUHost *)aHost
|
|
{
|
|
self = [super initWithHost:aHost windowNibName:@"SUStatus"];
|
|
if (self)
|
|
{
|
|
host = [aHost retain];
|
|
[self setShouldCascadeWindows:NO];
|
|
}
|
|
return self;
|
|
}
|
|
|
|
- (void)dealloc
|
|
{
|
|
[host release];
|
|
[title release];
|
|
[statusText release];
|
|
[buttonTitle release];
|
|
[super dealloc];
|
|
}
|
|
|
|
- (NSString *)description { return [NSString stringWithFormat:@"%@ <%@>", [self class], [host bundlePath]]; }
|
|
|
|
- (void)awakeFromNib
|
|
{
|
|
[[self window] center];
|
|
[[self window] setFrameAutosaveName:@"SUStatusFrame"];
|
|
[progressBar setUsesThreadedAnimation:YES];
|
|
}
|
|
|
|
- (NSString *)windowTitle
|
|
{
|
|
return [NSString stringWithFormat:SULocalizedString(@"Updating %@", nil), [host name]];
|
|
}
|
|
|
|
- (NSImage *)applicationIcon
|
|
{
|
|
return [host icon];
|
|
}
|
|
|
|
- (void)beginActionWithTitle:(NSString *)aTitle maxProgressValue:(double)aMaxProgressValue statusText:(NSString *)aStatusText
|
|
{
|
|
[self willChangeValueForKey:@"title"];
|
|
title = [aTitle copy];
|
|
[self didChangeValueForKey:@"title"];
|
|
|
|
[self setMaxProgressValue:aMaxProgressValue];
|
|
[self setStatusText:aStatusText];
|
|
}
|
|
|
|
- (void)setButtonTitle:(NSString *)aButtonTitle target:target action:(SEL)action isDefault:(BOOL)isDefault
|
|
{
|
|
[self willChangeValueForKey:@"buttonTitle"];
|
|
if (buttonTitle != aButtonTitle)
|
|
{
|
|
[buttonTitle release];
|
|
buttonTitle = [aButtonTitle copy];
|
|
}
|
|
[self didChangeValueForKey:@"buttonTitle"];
|
|
|
|
[self window];
|
|
[actionButton sizeToFit];
|
|
// Except we're going to add 15 px for padding.
|
|
[actionButton setFrameSize:NSMakeSize([actionButton frame].size.width + 15, [actionButton frame].size.height)];
|
|
// Now we have to move it over so that it's always 15px from the side of the window.
|
|
[actionButton setFrameOrigin:NSMakePoint([[self window] frame].size.width - 15 - [actionButton frame].size.width, [actionButton frame].origin.y)];
|
|
// Redisplay superview to clean up artifacts
|
|
[[actionButton superview] display];
|
|
|
|
[actionButton setTarget:target];
|
|
[actionButton setAction:action];
|
|
[actionButton setKeyEquivalent:isDefault ? @"\r" : @""];
|
|
}
|
|
|
|
- (BOOL)progressBarShouldAnimate
|
|
{
|
|
return YES;
|
|
}
|
|
|
|
- (void)setButtonEnabled:(BOOL)enabled
|
|
{
|
|
[actionButton setEnabled:enabled];
|
|
}
|
|
|
|
- (double)progressValue
|
|
{
|
|
return progressValue;
|
|
}
|
|
|
|
- (void)setProgressValue:(double)value
|
|
{
|
|
progressValue = value;
|
|
}
|
|
|
|
- (double)maxProgressValue
|
|
{
|
|
return maxProgressValue;
|
|
}
|
|
|
|
- (void)setMaxProgressValue:(double)value
|
|
{
|
|
if (value < 0.0) value = 0.0;
|
|
maxProgressValue = value;
|
|
[self setProgressValue:0.0];
|
|
[progressBar setIndeterminate:(value == 0.0)];
|
|
[progressBar startAnimation:self];
|
|
}
|
|
|
|
- (void)setStatusText:(NSString *)aStatusText
|
|
{
|
|
if (statusText != aStatusText)
|
|
{
|
|
[statusText release];
|
|
statusText = [aStatusText copy];
|
|
}
|
|
}
|
|
|
|
@end
|