[5] | 1 | //
|
---|
| 2 | // DockCamStatus.m
|
---|
| 3 | // DockCam
|
---|
| 4 | //
|
---|
| 5 | // Created by Nicholas Riley on Thu Jun 27 2002.
|
---|
| 6 | // Copyright (c) 2002 Nicholas Riley. All rights reserved.
|
---|
| 7 | //
|
---|
| 8 |
|
---|
| 9 | #import "DockCamStatus.h"
|
---|
| 10 | #import "DockCamPrefs.h"
|
---|
| 11 |
|
---|
| 12 | @implementation DockCamStatus
|
---|
| 13 |
|
---|
| 14 | - (void)awakeFromNib;
|
---|
| 15 | {
|
---|
| 16 | NSEnumerator *e = [[statusForm cells] objectEnumerator];
|
---|
| 17 | NSCell *cell;
|
---|
| 18 | while ( (cell = [e nextObject]) != nil) {
|
---|
| 19 | [cell setFont: [NSFont systemFontOfSize: [NSFont smallSystemFontSize]]];
|
---|
| 20 | }
|
---|
| 21 |
|
---|
| 22 | // XXX workaround for bug in 10.1.5 (and earlier?): autosave name set in IB doesn't show up
|
---|
| 23 | [self setWindowFrameAutosaveName: @"DockCam Status"];
|
---|
| 24 | [[self window] setHidesOnDeactivate: YES];
|
---|
| 25 |
|
---|
| 26 | if ([DockCamPrefs boolForPref: DCShowStatus])
|
---|
| 27 | [self showWindow: self];
|
---|
| 28 | }
|
---|
| 29 |
|
---|
| 30 | - (IBAction)showWindow:(id)sender;
|
---|
| 31 | {
|
---|
| 32 | [DockCamPrefs setBool: YES forPref: DCShowStatus];
|
---|
| 33 | [showHideStatusItem setAction: @selector(hideWindow:)];
|
---|
| 34 | [showHideStatusItem setTitle: @"Hide Status"];
|
---|
| 35 | // No need to subscribe to notifications, as the delegate we're already subscribed
|
---|
| 36 | [[self window] orderFront: self];
|
---|
| 37 | }
|
---|
| 38 |
|
---|
| 39 | - (IBAction)hideWindow:(id)sender;
|
---|
| 40 | {
|
---|
| 41 | [[self window] orderOut: sender];
|
---|
| 42 | [DockCamPrefs setBool: NO forPref: DCShowStatus];
|
---|
| 43 | [showHideStatusItem setAction: @selector(showWindow:)];
|
---|
| 44 | [showHideStatusItem setTitle: @"Show Status"];
|
---|
| 45 | }
|
---|
| 46 |
|
---|
| 47 | - (void)windowWillClose:(NSNotification *)aNotification;
|
---|
| 48 | {
|
---|
| 49 | [self hideWindow: self];
|
---|
| 50 | }
|
---|
| 51 |
|
---|
| 52 | #pragma mark status changes
|
---|
| 53 |
|
---|
| 54 | - (void)setLocation:(NSURL *)location;
|
---|
| 55 | {
|
---|
| 56 | [locationCell setStringValue: [location absoluteString]];
|
---|
| 57 | [actualSize setStringValue: @""];
|
---|
| 58 | [retrievedDate setStringValue: @"never"];
|
---|
| 59 | [failedDate setStringValue: @"never"];
|
---|
| 60 | [failedReason setStringValue: @""];
|
---|
| 61 | }
|
---|
| 62 |
|
---|
| 63 | - (void)setStatus:(NSString *)status;
|
---|
| 64 | {
|
---|
| 65 | [statusCell setStringValue: status];
|
---|
| 66 | }
|
---|
| 67 |
|
---|
| 68 | - (void)setRetrievedWithSize:(NSSize)size;
|
---|
| 69 | {
|
---|
| 70 | static const unichar timesUnichar = 0x00d7;
|
---|
| 71 | [retrievedDate setObjectValue: [NSDate date]];
|
---|
| 72 | [self setStatus: @"Image retrieved successfully"];
|
---|
| 73 | [actualSize setStringValue: [NSString stringWithFormat: @"%.0f %@ %.0f pixels",
|
---|
| 74 | size.width, [NSString stringWithCharacters: ×Unichar length: 1], size.height]];
|
---|
| 75 | }
|
---|
| 76 |
|
---|
| 77 | - (void)setFailedWithReason:(NSString *)reason;
|
---|
| 78 | {
|
---|
| 79 | [failedDate setObjectValue: [NSDate date]];
|
---|
| 80 | [failedReason setStringValue: reason];
|
---|
| 81 | [self setStatus: @"Image retrieval failed"];
|
---|
| 82 | if (![[self window] isVisible])
|
---|
| 83 | [self showWindow: self];
|
---|
| 84 | }
|
---|
| 85 |
|
---|
| 86 | @end
|
---|