source: trunk/Cocoa/DockCam/DockCamStatus.m@ 141

Last change on this file since 141 was 5, checked in by Nicholas Riley, 22 years ago

Initial import.

File size: 2.4 KB
Line 
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
47w
48- (void)windowWillClose:(NSNotification *)aNotification;
49{
50 [self hideWindow: self];
51}
52
53#pragma mark status changes
54
55- (void)setLocation:(NSURL *)location;
56{
57 [locationCell setStringValue: [location absoluteString]];
58 [actualSize setStringValue: @""];
59 [retrievedDate setStringValue: @"never"];
60 [failedDate setStringValue: @"never"];
61 [failedReason setStringValue: @""];
62}
63
64- (void)setStatus:(NSString *)status;
65{
66 [statusCell setStringValue: status];
67}
68
69- (void)setRetrievedWithSize:(NSSize)size;
70{
71 static const unichar timesUnichar = 0x00d7;
72 [retrievedDate setObjectValue: [NSDate date]];
73 [self setStatus: @"Image retrieved successfully"];
74 [actualSize setStringValue: [NSString stringWithFormat: @"%.0f %@ %.0f pixels",
75 size.width, [NSString stringWithCharacters: &timesUnichar length: 1], size.height]];
76}
77
78- (void)setFailedWithReason:(NSString *)reason;
79{
80 [failedDate setObjectValue: [NSDate date]];
81 [failedReason setStringValue: reason];
82 [self setStatus: @"Image retrieval failed"];
83 if (![[self window] isVisible])
84 [self showWindow: self];
85}
86
87@end
Note: See TracBrowser for help on using the repository browser.