Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 145 lines (119 sloc) 3.363 kb
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 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144
//
// SUStatusController.m
// Sparkle
//
// Created by Andy Matuschak on 3/14/06.
// Copyright 2006 Andy Matuschak. All rights reserved.
//

#import "SUUpdater.h"

#import "SUAppcast.h"
#import "SUAppcastItem.h"
#import "SUVersionComparisonProtocol.h"
#import "SUStatusController.h"
#import "SUHost.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], [host installationPath]]; }

- (void)awakeFromNib
{
    if ([host isBackgroundApplication]) {
        [[self window] setLevel:NSFloatingWindowLevel];
    }
    
[[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: (id)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" : @""];

// 06/05/2008 Alex: Avoid a crash when cancelling during the extraction
[self setButtonEnabled: (target != nil)];
}

- (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];
[progressBar setUsesThreadedAnimation: YES];
}

- (void)setStatusText:(NSString *)aStatusText
{
if (statusText != aStatusText)
{
[statusText release];
statusText = [aStatusText copy];
}
}

@end
Something went wrong with that request. Please try again.