mirror of
https://github.com/textmate/textmate.git
synced 2026-04-06 03:01:29 -04:00
79 lines
2.8 KiB
Plaintext
79 lines
2.8 KiB
Plaintext
#import "SoftwareUpdatePreferences.h"
|
|
#import "Keys.h"
|
|
#import <CrashReporter/CrashReporter.h>
|
|
#import <OakAppKit/NSImage Additions.h>
|
|
#import <OakFoundation/NSDate Additions.h>
|
|
#import <OakFoundation/OakStringListTransformer.h>
|
|
#import <SoftwareUpdate/SoftwareUpdate.h>
|
|
|
|
// kUserDefaultsLastSoftwareUpdateCheckKey
|
|
// kUserDefaultsLastBundleUpdateCheckKey
|
|
|
|
@interface SoftwareUpdatePreferences ()
|
|
@property (nonatomic, assign) BOOL isChecking;
|
|
@property (nonatomic, retain) NSDate* lastPoll;
|
|
@property (nonatomic, retain) NSString* errorString;
|
|
|
|
@property (nonatomic, retain) NSString* lastPollString;
|
|
@property (nonatomic, retain) NSTimer* updateLastPollStringTimer;
|
|
@end
|
|
|
|
@implementation SoftwareUpdatePreferences
|
|
+ (NSSet*)keyPathsForValuesAffectingLastCheck { return [NSSet setWithObjects:@"isChecking", @"lastPollString", @"errorString", nil]; }
|
|
|
|
- (id)init
|
|
{
|
|
if(self = [super initWithNibName:@"SoftwareUpdatePreferences" label:@"Software Update" image:[NSImage imageNamed:@"Software Update" inSameBundleAsClass:[self class]]])
|
|
{
|
|
[OakStringListTransformer createTransformerWithName:@"OakSoftwareUpdateChannelTransformer" andObjectsArray:@[ kSoftwareUpdateChannelRelease, kSoftwareUpdateChannelBeta ]];
|
|
[self bind:@"isChecking" toObject:[SoftwareUpdate sharedInstance] withKeyPath:@"isChecking" options:nil];
|
|
[self bind:@"lastPoll" toObject:[SoftwareUpdate sharedInstance] withKeyPath:@"lastPoll" options:nil];
|
|
[self bind:@"errorString" toObject:[SoftwareUpdate sharedInstance] withKeyPath:@"errorString" options:nil];
|
|
|
|
self.defaultsProperties = [NSDictionary dictionaryWithObjectsAndKeys:
|
|
kUserDefaultsDisableSoftwareUpdatesKey, @"disableSoftwareUpdates",
|
|
kUserDefaultsDisableBundleUpdatesKey, @"disableBundleUpdates",
|
|
kUserDefaultsDisableCrashReportingKey, @"disableCrashReports",
|
|
kUserDefaultsSoftwareUpdateChannelKey, @"softwareUpdateChannel",
|
|
kUserDefaultsAskBeforeUpdatingKey, @"askBeforeDownloading",
|
|
kUserDefaultsSubmitUsageInfoKey, @"submitUsageInfo",
|
|
kUserDefaultsCrashReportsContactInfoKey, @"contactInfo",
|
|
nil];
|
|
}
|
|
return self;
|
|
}
|
|
|
|
- (IBAction)performSoftwareUpdateCheck:(id)sender
|
|
{
|
|
[[SoftwareUpdate sharedInstance] checkForUpdates:self];
|
|
}
|
|
|
|
- (NSString*)lastCheck
|
|
{
|
|
return _isChecking ? @"Checking…" : (_errorString ?: (_lastPollString ?: @"Never"));
|
|
}
|
|
|
|
- (void)updateLastPollString:(id)sender
|
|
{
|
|
self.lastPollString = [self.lastPoll humanReadableTimeElapsed];
|
|
}
|
|
|
|
- (void)setLastPoll:(NSDate*)aDate
|
|
{
|
|
_lastPoll = aDate;
|
|
[self updateLastPollString:self];
|
|
}
|
|
|
|
- (void)viewWillAppear
|
|
{
|
|
[self updateLastPollString:nil];
|
|
self.updateLastPollStringTimer = [NSTimer scheduledTimerWithTimeInterval:60 target:self selector:@selector(updateLastPollString:) userInfo:nil repeats:YES];
|
|
}
|
|
|
|
- (void)viewDidDisappear
|
|
{
|
|
[self.updateLastPollStringTimer invalidate];
|
|
self.updateLastPollStringTimer = nil;
|
|
}
|
|
@end
|