- Timestamp:
- 11/23/07 04:58:05 (17 years ago)
- Location:
- trunk/Cocoa/Pester/Source
- Files:
-
- 8 added
- 3 deleted
- 24 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Cocoa/Pester/Source/English.lproj/MainMenu.nib/classes.nib
r133 r355 1 { 2 IBClasses = ( 3 {CLASS = FirstResponder; LANGUAGE = ObjC; SUPERCLASS = NSObject; }, 4 {CLASS = NJRDateFormatter; LANGUAGE = ObjC; SUPERCLASS = NSDateFormatter; }, 5 { 6 ACTIONS = {select = id; }; 7 CLASS = NJRFSObjectSelector; 8 LANGUAGE = ObjC; 9 SUPERCLASS = NSButton; 10 }, 11 { 12 ACTIONS = {clearAllEntries = id; removeEntry = id; }; 13 CLASS = NJRHistoryTrackingComboBox; 14 LANGUAGE = ObjC; 15 SUPERCLASS = NSComboBox; 16 }, 17 {CLASS = NJRIntegerFilter; LANGUAGE = ObjC; SUPERCLASS = NSNumberFormatter; }, 18 { 19 CLASS = NJRIntervalField; 20 LANGUAGE = ObjC; 21 OUTLETS = {intervalUnits = NSPopUpButton; }; 22 SUPERCLASS = NSTextField; 23 }, 24 { 25 ACTIONS = {stopSoundPreview = id; }; 26 CLASS = NJRQTMediaPopUpButton; 27 LANGUAGE = ObjC; 28 OUTLETS = {preview = NSMovieView; }; 29 SUPERCLASS = NSPopUpButton; 30 }, 31 {CLASS = NJRUnfocusableMovieView; LANGUAGE = ObjC; SUPERCLASS = NSMovieView; }, 32 { 33 ACTIONS = {stopVoicePreview = id; }; 34 CLASS = NJRVoicePopUpButton; 35 LANGUAGE = ObjC; 36 SUPERCLASS = NSPopUpButton; 37 }, 38 {CLASS = NSDisclosureButtonCell; LANGUAGE = ObjC; SUPERCLASS = NSButtonCell; }, 39 {CLASS = NSObject; LANGUAGE = ObjC; }, 40 { 41 ACTIONS = { 42 dateCompleted = id; 43 doScriptChanged = id; 44 doSpeakChanged = id; 45 editAlertChanged = id; 46 inAtChanged = id; 47 playSoundChanged = id; 48 setAlarm = id; 49 setSoundRepetitionCount = id; 50 showCalendar = id; 51 showVolume = id; 52 silence = id; 53 toggleAlertEditor = id; 54 update = id; 55 }; 56 CLASS = PSAlarmSetController; 57 LANGUAGE = ObjC; 58 OUTLETS = { 59 alertTabs = NSTabView; 60 alertView = NSTextField; 61 bounceDockIcon = NSButton; 62 cancelButton = NSButton; 63 displayMessage = NSButtonCell; 64 doScript = NSButtonCell; 65 doSpeak = NSButtonCell; 66 editAlert = NSButtonCell; 67 inAtMatrix = NSMatrix; 68 messageField = NSTextField; 69 playSound = NSButtonCell; 70 script = NJRFSObjectSelector; 71 scriptSelectButton = NSButton; 72 setButton = NSButton; 73 sound = NJRQTMediaPopUpButton; 74 soundRepetitionStepper = NSStepper; 75 soundRepetitions = NSTextField; 76 soundRepetitionsLabel = NSTextField; 77 soundVolumeButton = NSButton; 78 timeCalendarButton = NSButton; 79 timeDate = NSTextField; 80 timeDateCompletions = NSPopUpButton; 81 timeInterval = NJRIntervalField; 82 timeIntervalRepeats = NSButton; 83 timeIntervalUnits = NSPopUpButton; 84 timeOfDay = NSTextField; 85 timeSummary = NSTextField; 86 voice = NJRVoicePopUpButton; 87 wakeUp = NSButtonCell; 88 }; 89 SUPERCLASS = NSWindowController; 90 }, 91 { 92 CLASS = PSAlarmsController; 93 LANGUAGE = ObjC; 94 OUTLETS = {tableView = NSTableView; }; 95 SUPERCLASS = NSWindowController; 96 }, 97 { 98 ACTIONS = { 99 orderFrontAlarmsPanel = id; 100 orderFrontPreferencesPanel = id; 101 orderFrontSetAlarmPanel = id; 102 stopAlerts = id; 103 }; 104 CLASS = PSApplication; 105 LANGUAGE = ObjC; 106 OUTLETS = {alarmSetController = PSAlarmSetController; }; 107 SUPERCLASS = NSApplication; 108 } 109 ); 110 IBVersion = 1; 111 } 1 <?xml version="1.0" encoding="UTF-8"?> 2 <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> 3 <plist version="1.0"> 4 <dict> 5 <key>IBClasses</key> 6 <array> 7 <dict> 8 <key>ACTIONS</key> 9 <dict> 10 <key>stopVoicePreview</key> 11 <string>id</string> 12 </dict> 13 <key>CLASS</key> 14 <string>NJRVoicePopUpButton</string> 15 <key>LANGUAGE</key> 16 <string>ObjC</string> 17 <key>SUPERCLASS</key> 18 <string>NSPopUpButton</string> 19 </dict> 20 <dict> 21 <key>ACTIONS</key> 22 <dict> 23 <key>dateCompleted</key> 24 <string>NSPopUpButton</string> 25 <key>doScriptChanged</key> 26 <string>id</string> 27 <key>doSpeakChanged</key> 28 <string>id</string> 29 <key>editAlertChanged</key> 30 <string>id</string> 31 <key>inAtChanged</key> 32 <string>id</string> 33 <key>playSoundChanged</key> 34 <string>id</string> 35 <key>setAlarm</key> 36 <string>NSButton</string> 37 <key>setSoundRepetitionCount</key> 38 <string>id</string> 39 <key>showCalendar</key> 40 <string>NSButton</string> 41 <key>showVolume</key> 42 <string>NSButton</string> 43 <key>silence</key> 44 <string>id</string> 45 <key>toggleAlertEditor</key> 46 <string>id</string> 47 <key>update</key> 48 <string>id</string> 49 </dict> 50 <key>CLASS</key> 51 <string>PSAlarmSetController</string> 52 <key>LANGUAGE</key> 53 <string>ObjC</string> 54 <key>OUTLETS</key> 55 <dict> 56 <key>alertTabs</key> 57 <string>NSTabView</string> 58 <key>alertView</key> 59 <string>NSTextField</string> 60 <key>bounceDockIcon</key> 61 <string>NSButton</string> 62 <key>cancelButton</key> 63 <string>NSButton</string> 64 <key>displayMessage</key> 65 <string>NSButtonCell</string> 66 <key>doScript</key> 67 <string>NSButtonCell</string> 68 <key>doSpeak</key> 69 <string>NSButtonCell</string> 70 <key>editAlert</key> 71 <string>NSButtonCell</string> 72 <key>inAtMatrix</key> 73 <string>NSMatrix</string> 74 <key>messageField</key> 75 <string>NSTextField</string> 76 <key>playSound</key> 77 <string>NSButtonCell</string> 78 <key>script</key> 79 <string>NJRFSObjectSelector</string> 80 <key>scriptSelectButton</key> 81 <string>NSButton</string> 82 <key>setButton</key> 83 <string>NSButton</string> 84 <key>sound</key> 85 <string>NJRQTMediaPopUpButton</string> 86 <key>soundRepetitionStepper</key> 87 <string>NSStepper</string> 88 <key>soundRepetitions</key> 89 <string>NSTextField</string> 90 <key>soundRepetitionsLabel</key> 91 <string>NSTextField</string> 92 <key>soundVolumeButton</key> 93 <string>NSButton</string> 94 <key>timeCalendarButton</key> 95 <string>NSButton</string> 96 <key>timeDate</key> 97 <string>NSTextField</string> 98 <key>timeDateCompletions</key> 99 <string>NSPopUpButton</string> 100 <key>timeInterval</key> 101 <string>NJRIntervalField</string> 102 <key>timeIntervalRepeats</key> 103 <string>NSButton</string> 104 <key>timeIntervalUnits</key> 105 <string>NSPopUpButton</string> 106 <key>timeOfDay</key> 107 <string>NSTextField</string> 108 <key>timeSummary</key> 109 <string>NSTextField</string> 110 <key>voice</key> 111 <string>NJRVoicePopUpButton</string> 112 <key>wakeUp</key> 113 <string>NSButtonCell</string> 114 </dict> 115 <key>SUPERCLASS</key> 116 <string>NSWindowController</string> 117 </dict> 118 <dict> 119 <key>CLASS</key> 120 <string>NSDisclosureButtonCell</string> 121 <key>LANGUAGE</key> 122 <string>ObjC</string> 123 <key>SUPERCLASS</key> 124 <string>NSButtonCell</string> 125 </dict> 126 <dict> 127 <key>ACTIONS</key> 128 <dict> 129 <key>clearAllEntries</key> 130 <string>id</string> 131 <key>removeEntry</key> 132 <string>id</string> 133 </dict> 134 <key>CLASS</key> 135 <string>NJRHistoryTrackingComboBox</string> 136 <key>LANGUAGE</key> 137 <string>ObjC</string> 138 <key>SUPERCLASS</key> 139 <string>NSComboBox</string> 140 </dict> 141 <dict> 142 <key>CLASS</key> 143 <string>NSMenuItem</string> 144 <key>LANGUAGE</key> 145 <string>ObjC</string> 146 <key>SUPERCLASS</key> 147 <string>NSObject</string> 148 </dict> 149 <dict> 150 <key>ACTIONS</key> 151 <dict> 152 <key>stopSoundPreview</key> 153 <string>id</string> 154 </dict> 155 <key>CLASS</key> 156 <string>NJRQTMediaPopUpButton</string> 157 <key>LANGUAGE</key> 158 <string>ObjC</string> 159 <key>OUTLETS</key> 160 <dict> 161 <key>preview</key> 162 <string>NSMovieView</string> 163 </dict> 164 <key>SUPERCLASS</key> 165 <string>NSPopUpButton</string> 166 </dict> 167 <dict> 168 <key>CLASS</key> 169 <string>FirstResponder</string> 170 <key>LANGUAGE</key> 171 <string>ObjC</string> 172 <key>SUPERCLASS</key> 173 <string>NSObject</string> 174 </dict> 175 <dict> 176 <key>CLASS</key> 177 <string>NJRUnfocusableMovieView</string> 178 <key>LANGUAGE</key> 179 <string>ObjC</string> 180 <key>SUPERCLASS</key> 181 <string>NSMovieView</string> 182 </dict> 183 <dict> 184 <key>CLASS</key> 185 <string>NSObject</string> 186 <key>LANGUAGE</key> 187 <string>ObjC</string> 188 </dict> 189 <dict> 190 <key>CLASS</key> 191 <string>NJRIntervalField</string> 192 <key>LANGUAGE</key> 193 <string>ObjC</string> 194 <key>OUTLETS</key> 195 <dict> 196 <key>intervalUnits</key> 197 <string>NSPopUpButton</string> 198 </dict> 199 <key>SUPERCLASS</key> 200 <string>NSTextField</string> 201 </dict> 202 <dict> 203 <key>ACTIONS</key> 204 <dict> 205 <key>orderFrontAlarmsPanel</key> 206 <string>id</string> 207 <key>orderFrontPreferencesPanel</key> 208 <string>id</string> 209 <key>orderFrontSetAlarmPanel</key> 210 <string>id</string> 211 <key>stopAlerts</key> 212 <string>id</string> 213 </dict> 214 <key>CLASS</key> 215 <string>PSApplication</string> 216 <key>LANGUAGE</key> 217 <string>ObjC</string> 218 <key>OUTLETS</key> 219 <dict> 220 <key>alarmSetController</key> 221 <string>PSAlarmSetController</string> 222 </dict> 223 <key>SUPERCLASS</key> 224 <string>NSApplication</string> 225 </dict> 226 <dict> 227 <key>CLASS</key> 228 <string>NJRIntegerFilter</string> 229 <key>LANGUAGE</key> 230 <string>ObjC</string> 231 <key>SUPERCLASS</key> 232 <string>NSNumberFormatter</string> 233 </dict> 234 <dict> 235 <key>ACTIONS</key> 236 <dict> 237 <key>select</key> 238 <string>id</string> 239 </dict> 240 <key>CLASS</key> 241 <string>NJRFSObjectSelector</string> 242 <key>LANGUAGE</key> 243 <string>ObjC</string> 244 <key>SUPERCLASS</key> 245 <string>NSButton</string> 246 </dict> 247 </array> 248 <key>IBVersion</key> 249 <string>1</string> 250 </dict> 251 </plist> -
trunk/Cocoa/Pester/Source/English.lproj/MainMenu.nib/info.nib
r133 r355 1 1 <?xml version="1.0" encoding="UTF-8"?> 2 <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">2 <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> 3 3 <plist version="1.0"> 4 4 <dict> 5 <key>IBDocumentLocation</key>6 <string>63 2 356 240 0 0 1280 832 </string>7 <key>IBEditorPositions</key>8 <dict>9 <key>29</key>10 <string>130 241 273 44 0 0 1280 832 </string>11 <key>640</key>12 <string>63 247 111 180 0 0 1280 832 </string>13 </dict>14 5 <key>IBFramework Version</key> 15 <string>291.0</string> 6 <string>629</string> 7 <key>IBLastKnownRelativeProjectPath</key> 8 <string>../../Pester.xcodeproj</string> 9 <key>IBOldestOS</key> 10 <integer>5</integer> 16 11 <key>IBOpenObjects</key> 17 12 <array> 18 <integer>640</integer> 19 <integer>21</integer> 13 <integer>2</integer> 20 14 </array> 21 15 <key>IBSystem Version</key> 22 <string>6I32</string> 23 <key>IBUserGuides</key> 24 <dict> 25 <key>21</key> 26 <dict> 27 <key>guideLocations</key> 28 <array> 29 <string>Horizontal:122.000000</string> 30 <string>Horizontal:178.000000</string> 31 <string>Horizontal:192.000000</string> 32 <string>Vertical:36.000000</string> 33 <string>Vertical:16.000000</string> 34 <string>Vertical:85.000000</string> 35 <string>Vertical:422.000000</string> 36 <string>Horizontal:150.000000</string> 37 <string>Horizontal:150.000000</string> 38 </array> 39 <key>guidesLocked</key> 40 <false/> 41 </dict> 42 </dict> 16 <string>9B18</string> 17 <key>targetFramework</key> 18 <string>IBCocoaFramework</string> 43 19 </dict> 44 20 </plist> -
trunk/Cocoa/Pester/Source/NJRFSObjectSelector.m
r53 r355 1 1 #import "NJRFSObjectSelector.h" 2 #import "NSMenuItem-NJRExtensions.h" 2 3 #import "NSImage-NJRExtensions.h" 3 4 #import "NSString-NJRExtensions.h" … … 84 85 - (void)setImage:(NSImage *)image; 85 86 { 87 // XXX change to use IconRef; see ICeCoffEELabeledIconCell and Google 86 88 [super setImage: [image bestFitImageForSize: [[self cell] cellSize]]]; 87 89 } … … 111 113 NSAssert1([files count] == 1, @"%d items returned, only one expected", [files count]); 112 114 [self setPath: [files objectAtIndex: 0]]; 113 [[self target] tryToPerform: [self action] with: self]; 115 if ([self target] != nil && [[self target] respondsToSelector:[self action]]) 116 [[self target] performSelector: [self action] withObject: self]; 114 117 } 115 118 } … … 145 148 } 146 149 do { 150 NSAssert1(![path isEqualToString: revealPath], @"Stuck on path |%@|", [alias fullPath]); 147 151 item = [menu addItemWithTitle: [fmgr displayNameAtPath: path] 148 152 action: @selector(revealInFinder:) … … 150 154 [item setTarget: self]; 151 155 [item setRepresentedObject: revealPath]; 152 [item setImage: 153 [[[NSWorkspace sharedWorkspace] iconForFile: path] bestFitImageForSize: NSMakeSize(16, 16)]]; 156 [item setImageFromPath: path]; 154 157 revealPath = path; 155 158 path = [path stringByDeletingLastPathComponent]; 156 NSAssert1(![path isEqualToString: revealPath], @"Stuck on path |%@|", [alias fullPath]);157 159 } while (![revealPath isEqualToString: @"/"] && ![path isEqualToString: @"/Volumes"]); 158 160 [[self cell] setMenu: menu]; … … 195 197 - (void)mouseDown:(NSEvent *)theEvent; 196 198 { 199 if (![self isEnabled]) return; 200 197 201 NSMenu *menu = [[self cell] menu]; 198 202 MenuRef mRef = _NSGetCarbonMenu(menu); … … 219 223 pressure: [theEvent pressure]]; 220 224 221 // this undocumented API does not work any better; contextual menu items are still added: 222 // [menu _popUpMenuWithEvent: theEvent forView: self]; 223 [NSMenu popUpContextMenu: menu withEvent: theEvent forView: self]; 225 // XXX otherwise Cocoa thoughtfully doesn't give me the font I want 226 NSFont *font = [[self cell] font]; 227 [NSMenu popUpContextMenu: menu withEvent: theEvent forView: self withFont: 228 [NSFont fontWithName: [font fontName] size: [font pointSize] - 0.001]]; 224 229 } 225 230 … … 310 315 if (url == nil) return NO; 311 316 [self setPath: [url path]]; 312 [[self target] tryToPerform: [self action] with: self]; 317 if ([self target] != nil && [[self target] respondsToSelector:[self action]]) 318 [[self target] performSelector: [self action] withObject: self]; 313 319 } 314 320 return YES; -
trunk/Cocoa/Pester/Source/NJRHistoryTrackingComboBox.m
r103 r355 27 27 [self removeAllItems]; 28 28 [self addItemsWithObjectValues: [[NSUserDefaults standardUserDefaults] stringArrayForKey: [self _defaultKey]]]; 29 [self setItemHeight: [self itemHeight] + 2];30 29 } 31 30 -
trunk/Cocoa/Pester/Source/NJRHotKey.m
r133 r355 39 39 { 40 40 [hotKeyCharacters release]; 41 [super dealloc]; 41 42 } 42 43 -
trunk/Cocoa/Pester/Source/NJRHotKeyField.m
r132 r355 65 65 { 66 66 [hotKey release]; 67 [super dealloc]; 67 68 } 68 69 -
trunk/Cocoa/Pester/Source/NJRHotKeyManager.m
r131 r355 32 32 [hotKey release]; 33 33 [target release]; 34 [super dealloc]; 34 35 } 35 36 -
trunk/Cocoa/Pester/Source/NJRIntervalField.m
r103 r355 84 84 NSString *alertMessage = nil; 85 85 NSString *alternateButtonString = nil; 86 NS DecimalNumber *proposedValue = nil;86 NSNumber *proposedValue = nil; 87 87 NSDictionary *contextInfo; 88 88 -
trunk/Cocoa/Pester/Source/NJRQTMediaPopUpButton.m
r133 r355 8 8 9 9 #import "NJRQTMediaPopUpButton.h" 10 #import "SoundFileManager.h"11 10 #import "NJRSoundManager.h" 12 11 #import "NSMovie-NJRExtensions.h" 13 #import "NSImage-NJRExtensions.h" 14 #import <QuickTime/Movies.h> 15 16 // XXX workaround for SoundFileManager log message in 10.2.3 and earlier 17 #include <stdio.h> 18 #include <unistd.h> 19 #include <fcntl.h> 20 // XXX end workaround 12 #import "NSMenuItem-NJRExtensions.h" 13 14 #import <QTKit/QTKit.h> 15 16 #include <QuickTime/Movies.h> 17 #include <limits.h> 21 18 22 19 static const int NJRQTMediaPopUpButtonMaxRecentItems = 10; … … 66 63 [item setTarget: self]; 67 64 [item setRepresentedObject: alias]; 68 [item setImage : [[[NSWorkspace sharedWorkspace] iconForFile: path] bestFitImageForSize: NSMakeSize(16, 16)]];65 [item setImageFromPath: path]; 69 66 [recentMediaAliasData addObject: [alias aliasData]]; 70 67 if ([recentMediaAliasData count] > NJRQTMediaPopUpButtonMaxRecentItems) { … … 115 112 - (void)_setUp; 116 113 { 117 NSMenu *menu; 118 NSMenuItem *item; 119 SoundFileManager *sfm = [SoundFileManager sharedSoundFileManager]; 120 int soundCount = [sfm count]; 121 114 NSMenu *menu = [self menu]; 122 115 [self removeAllItems]; 123 menu = [self menu]; 124 item = [menu addItemWithTitle: @"Alert sound" action: @selector(_beepSelected:) keyEquivalent: @""]; 116 [menu setAutoenablesItems: NO]; 117 118 NSMenuItem *item = [menu addItemWithTitle: @"Alert sound" action: @selector(_beepSelected:) keyEquivalent: @""]; 125 119 [item setTarget: self]; 126 120 [menu addItem: [NSMenuItem separatorItem]]; 127 if (soundCount == 0) { 121 122 NSMutableArray *soundFolderPaths = [[NSMutableArray alloc] initWithCapacity: kLastDomainConstant - kSystemDomain + 1]; 123 for (FSVolumeRefNum domain = kSystemDomain ; domain <= kLastDomainConstant ; domain++) { 124 OSStatus err; 125 FSRef fsr; 126 err = FSFindFolder(domain, kSystemSoundsFolderType, false, &fsr); 127 if (err != noErr) continue; 128 129 UInt8 path[PATH_MAX]; 130 err = FSRefMakePath(&fsr, path, PATH_MAX); 131 if (err != noErr) continue; 132 133 CFStringRef pathString = CFStringCreateWithFileSystemRepresentation(NULL, (const char *)path); 134 if (pathString == NULL) continue; 135 136 [soundFolderPaths addObject: (NSString *)pathString]; 137 CFRelease(pathString); 138 } 139 NSFileManager *fm = [NSFileManager defaultManager]; 140 NSEnumerator *e = [soundFolderPaths objectEnumerator]; 141 NSString *folderPath; 142 while ( (folderPath = [e nextObject]) != nil) { 143 if (![fm changeCurrentDirectoryPath: folderPath]) continue; 144 145 NSDirectoryEnumerator *de = [fm enumeratorAtPath: folderPath]; 146 NSString *path; 147 while ( (path = [de nextObject]) != nil) { 148 BOOL isDir; 149 if (![fm fileExistsAtPath: path isDirectory: &isDir] || isDir) { 150 [de skipDescendents]; 151 continue; 152 } 153 154 if (![QTMovie canInitWithFile: path]) continue; 155 156 item = [menu addItemWithTitle: [fm displayNameAtPath: path] 157 action: @selector(_systemSoundSelected:) 158 keyEquivalent: @""]; 159 [item setTarget: self]; 160 [item setImageFromPath: path]; 161 path = [folderPath stringByAppendingPathComponent: path]; 162 [item setRepresentedObject: path]; 163 [item setToolTip: path]; 164 } 165 } 166 [soundFolderPaths release]; 167 168 if ([menu numberOfItems] == 2) { 128 169 item = [menu addItemWithTitle: NSLocalizedString(@"Can't locate alert sounds", "QuickTime media popup menu item surrogate for alert sound list if no sounds are found") action: nil keyEquivalent: @""]; 129 170 [item setEnabled: NO]; 130 } else { 131 SoundFile *sf; 132 int i; 133 [sfm sortByName]; 134 for (i = 0 ; i < soundCount ; i++) { 135 sf = [sfm soundFileAtIndex: i]; 136 item = [menu addItemWithTitle: [sf name] action: @selector(_soundFileSelected:) keyEquivalent: @""]; 137 [item setTarget: self]; 138 [item setRepresentedObject: sf]; 139 [item setImage: [[[NSWorkspace sharedWorkspace] iconForFile: [sf path]] bestFitImageForSize: NSMakeSize(16, 16)]]; 140 } 141 } 171 } 172 142 173 [menu addItem: [NSMenuItem separatorItem]]; 143 174 item = [menu addItemWithTitle: NSLocalizedString(@"Other...", "Media popup item to select another sound/movie/image") action: @selector(select:) keyEquivalent: @""]; … … 212 243 - (NSMenuItem *)_itemForAlias:(BDAlias *)alias; 213 244 { 214 NSString *path; 215 SoundFile *sf; 216 if (alias == nil) { 217 return [self itemAtIndex: 0]; 218 } 245 if (alias == nil) return [self itemAtIndex: 0]; 219 246 220 247 // [self _validateRecentMedia]; 221 path = [alias fullPath]; 222 { // XXX suppress log message from Apple's code: 223 // 2002-12-14 14:09:58.740 Pester[26529] Could not find sound type for directory /Users/nicholas/Desktop 224 int errfd = dup(STDERR_FILENO), nullfd = open("/dev/null", O_WRONLY, 0); 225 // need to have something open in STDERR_FILENO because if it isn't, 226 // NSLog will log to /dev/console 227 dup2(nullfd, STDERR_FILENO); 228 close(nullfd); 229 sf = [[SoundFileManager sharedSoundFileManager] soundFileFromPath: path]; 230 dup2(errfd, STDERR_FILENO); 231 close(errfd); 232 } 233 // NSLog(@"_itemForAlias: %@", path); 248 NSString *path = [alias fullPath]; 234 249 235 250 // selected a system sound? 236 if (sf != nil) { 251 int itemIndex = [[self menu] indexOfItemWithRepresentedObject: path]; 252 if (itemIndex != -1) { 237 253 // NSLog(@"_itemForAlias: selected system sound"); 238 return [self itemAtIndex: [self indexOfItemWithRepresentedObject: sf]];254 return [self itemAtIndex: itemIndex]; 239 255 } else { 240 256 NSEnumerator *e = [recentMediaAliasData reverseObjectEnumerator]; … … 406 422 } 407 423 408 - (void)_s oundFileSelected:(NSMenuItem *)sender;409 { 410 [self _setPath: [ (SoundFile *)[sender representedObject] path]];424 - (void)_systemSoundSelected:(NSMenuItem *)sender; 425 { 426 [self _setPath: [sender representedObject]]; 411 427 if (![self _validateWithPreview: YES]) { 412 428 [[self menu] removeItem: sender]; -
trunk/Cocoa/Pester/Source/NJRReadMeController.m
r103 r355 64 64 unsigned i; 65 65 for (i = 0 ; i < level ; i++) { 66 [s appendString: @" ÊÊ"];66 [s appendString: @" "]; 67 67 } 68 68 [s appendString: description]; … … 101 101 NSString *frameAutosaveName; 102 102 if ( (frameAutosaveName = [window frameAutosaveName]) == nil) { 103 // XXX workaround for bug in 10.1.5 Ð10.2.4 (at least): autosave name set in IB doesn't show up103 // XXX workaround for bug in 10.1.5–10.2.4 (at least): autosave name set in IB doesn't show up 104 104 [self setWindowFrameAutosaveName: @"Read Me"]; 105 105 frameAutosaveName = [window frameAutosaveName]; -
trunk/Cocoa/Pester/Source/NJRSoundManager.m
r133 r355 34 34 35 35 propertySize = sizeof(stereoChannels); 36 err = AudioDeviceGetProperty(deviceID, NULL, false, kAudioDevicePropertyPreferredChannelsForStereo, &propertySize, &stereoChannels);36 err = AudioDeviceGetProperty(deviceID, 0, false, kAudioDevicePropertyPreferredChannelsForStereo, &propertySize, &stereoChannels); 37 37 if (err != noErr) return NO; 38 38 return YES; -
trunk/Cocoa/Pester/Source/NJRVoicePopUpButton.m
r103 r355 21 21 [menu setAutoenablesItems: NO]; 22 22 // XXX would be more elegant with surrogate support like my font popup menu 23 item = [menu addItemWithTitle: @" ÇunknownÈ" action: nil keyEquivalent: @""];23 item = [menu addItemWithTitle: @"«unknown»" action: nil keyEquivalent: @""]; 24 24 [item setEnabled: NO]; 25 25 [menu addItem: [NSMenuItem separatorItem]]; -
trunk/Cocoa/Pester/Source/PSAlarm.m
r113 r355 343 343 NSString *timeRemainingString = [self _stringForInterval: llround([self timeRemaining])]; 344 344 345 if (timeRemainingString == nil) return @" ÇexpiredÈ";345 if (timeRemainingString == nil) return @"«expired»"; 346 346 return timeRemainingString; 347 347 } -
trunk/Cocoa/Pester/Source/PSAlarmSetController.m
r133 r355 373 373 [[self window] makeFirstResponder: scriptSelectButton]; 374 374 if ([script alias] == nil) [scriptSelectButton performClick: sender]; 375 } else { 376 [[self window] makeFirstResponder: sender]; 375 377 } 376 378 } … … 382 384 if (doSpeakSelected && sender != nil) 383 385 [[self window] makeFirstResponder: voice]; 386 else 387 [[self window] makeFirstResponder: sender]; 384 388 } 385 389 -
trunk/Cocoa/Pester/Source/PSAlarms.m
r113 r355 176 176 NSEnumerator *e = [indices objectEnumerator]; 177 177 NSNumber *n; 178 intindexCount = [indices count], i = 0, alarmIndex;179 int *indexArray = (int *)malloc(indexCount * sizeof(int));178 unsigned indexCount = [indices count], i = 0, alarmIndex; 179 unsigned *indexArray = (unsigned *)malloc(indexCount * sizeof(unsigned)); 180 180 NS_DURING 181 181 while ( (n = [e nextObject]) != nil) { -
trunk/Cocoa/Pester/Source/PSAlarmsController.m
r113 r355 106 106 if ([[tableColumn identifier] isEqualToString: @"date"]) return [alarm shortDateString]; 107 107 if ([[tableColumn identifier] isEqualToString: @"time"]) { 108 if (date == nil) return @" ÇexpiredÈ";108 if (date == nil) return @"«expired»"; 109 109 return [alarm timeString]; 110 110 } -
trunk/Cocoa/Pester/Source/PSAlerts.m
r103 r355 41 41 { 42 42 [alerts release]; alerts = nil; 43 [super dealloc]; 43 44 } 44 45 … … 121 122 [plAlerts addObject: [alert propertyListRepresentation]]; 122 123 } 123 return [NSDictionary dictionaryWithObject: plAlerts forKey: PLAlerts]; 124 NSDictionary *dict = [NSDictionary dictionaryWithObject: plAlerts forKey: PLAlerts]; 125 [plAlerts release]; 126 return dict; 124 127 } 125 128 -
trunk/Cocoa/Pester/Source/PSPowerManager.h
r119 r355 21 21 22 22 + (BOOL)autoWakeSupported; 23 + (NSDate *)wakeTime; 24 + (void)setWakeInterval:(unsigned long)wakeInterval; 25 + (void)setWakeTime:(NSDate *)time overrideIfEarlier:(BOOL)override; 23 + (void)setWakeTime:(NSDate *)time; 26 24 + (void)clearWakeTime; 27 25 -
trunk/Cocoa/Pester/Source/PSPowerManager.m
r119 r355 11 11 #import <IOKit/pwr_mgt/IOPMLib.h> 12 12 #import <IOKit/IOMessage.h> 13 #import <CoreFoundation/CoreFoundation.h>14 15 /*16 * Copyright (c) 2002 Apple Computer, Inc. All rights reserved.17 *18 * @APPLE_LICENSE_HEADER_START@19 *20 * The contents of this file constitute Original Code as defined in and21 * are subject to the Apple Public Source License Version 1.1 (the22 * "License"). You may not use this file except in compliance with the23 * License. Please obtain a copy of the License at24 * http://www.apple.com/publicsource and read it before using this file.25 *26 * This Original Code and all software distributed under the License are27 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER28 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,29 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,30 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the31 * License for the specific language governing rights and limitations32 * under the License.33 *34 * @APPLE_LICENSE_HEADER_END@35 */36 37 /* Sample code to set an automatic wakeup timer to wake machines from sleep.38 39 When a machine is asleep, most hardware (including the processor) is40 powered off. The PMU chip is one of the few things left powered on, and it's41 able to generate a wakeup event on a timer.42 This code shows how to set the wakeup timer within the PMU.43 */44 45 // From autowake.cpp:46 47 // #define kAppleVIAUserClientMagicCookie 0x101face // or 0x101beef -- for PMU48 // #define kAppleVIAUserClientMagicCookie 0x101beef // or 0x101face -- for PMU49 50 // The difference is 101beef is only for superusers and 101face works for51 // non-privileged users. I have not determined which calls are only available52 // for superusers53 54 #define PMU_MAGIC_PASSWORD 0x0101FACE55 56 /* ==========================================57 * Close a device user client58 * =========================================== */59 static kern_return_t60 closeDevice(io_connect_t con)61 {62 kern_return_t ret = IOServiceClose(con);63 64 NSCAssert1(ret == kIOReturnSuccess, @"closeDevice: IOServiceClose returned an error of type %08lx", (unsigned long)ret);65 66 return ret;67 }68 69 /* ==========================================70 * Open an IORegistry device user client71 * =========================================== */72 static void73 openDevice(io_object_t obj, unsigned int type, io_connect_t * con)74 {75 kern_return_t ret = IOServiceOpen(obj, mach_task_self(), type, con);76 77 NSCAssert1(ret == kIOReturnSuccess, @"openDevice: IOServiceOpen returned an error of type %08lx", (unsigned long)ret);78 }79 80 /* ===========================================81 * Changes the string for a registry82 * property.83 * =========================================== */84 void85 writeDataProperty(io_object_t handle, CFStringRef name,86 unsigned char * bytes, unsigned int size)87 {88 kern_return_t kr = kIOReturnNoMemory;89 CFDataRef data;90 91 data = CFDataCreate(kCFAllocatorDefault, bytes, size);92 NSCAssert(data != NULL, @"writeDataProperty: CFDataCreate failed");93 [(NSData *)data autorelease];94 95 kr = IOConnectSetCFProperty(handle, name, data);96 NSCAssert1(kr == KERN_SUCCESS, @"writeDataProperty: IOConnectSetCFProperty returned an error of type %08lx", (unsigned long)kr);97 }98 99 /* ==========================================100 * Write a data property to the PMU driver101 * Arguments102 * pmuReference - the IORegistry device to write to103 * propertyName - Name of the property to write to104 * data - Data to write105 * dataSize - Data size106 * =========================================== */107 void108 writePMUProperty(io_object_t pmuReference, CFStringRef propertyName, void *data, size_t dataSize)109 {110 io_connect_t conObj;111 openDevice(pmuReference, PMU_MAGIC_PASSWORD, &conObj);112 writeDataProperty(conObj, propertyName, (unsigned char *)data, dataSize);113 closeDevice(conObj);114 }115 116 117 /* ==========================================118 * Look through the registry and search for an119 * IONetworkInterface objects with the given120 * name.121 * If a match is found, the object is returned.122 * =========================================== */123 124 io_service_t125 getInterfaceWithName(mach_port_t masterPort, char *className)126 {127 io_service_t obj;128 129 obj = IOServiceGetMatchingService(masterPort, IOServiceMatching(className));130 131 NSCAssert(obj != NULL, @"getInterfaceWithName: IOServiceGetMatchingService returned NULL");132 133 return obj;134 }135 136 /* ==========================================137 * Find the PMU in the IORegistry138 * =========================================== */139 io_service_t140 openPMUComPort(void)141 {142 static mach_port_t masterPort;143 kern_return_t kr;144 145 // Get a master port to talk with the mach_kernel146 kr = IOMasterPort(bootstrap_port, &masterPort);147 NSCAssert1(kr == KERN_SUCCESS, @"openPMUComPort: IOMasterPort returned an error of type %08lx", (unsigned long)kr);148 149 return getInterfaceWithName(masterPort, "ApplePMU");150 }151 152 153 /* ==========================================154 * Release our reference to the PMU in the IORegistry155 * =========================================== */156 void157 closePMUComPort(io_object_t pmuRef)158 {159 IOObjectRelease(pmuRef);160 }161 13 162 14 @implementation PSPowerManager … … 164 16 + (BOOL)autoWakeSupported; 165 17 { 166 io_service_t pmuReference = openPMUComPort(); 167 if (pmuReference == NULL) return NO; 168 closePMUComPort(pmuReference); 18 // XXX imagine it's supported on all machines that support 10.4 169 19 return YES; 170 20 } 171 21 172 + ( io_service_t)_pmuReference;22 + (void)setWakeTime:(NSDate *)time; 173 23 { 174 io_service_t pmuReference = openPMUComPort(); 175 NSAssert(pmuReference != NULL, NSLocalizedString(@"Couldn't find PMU in IORegistry. This computer may not support automatic wake from sleep.", "Assertion message: couldn't open ApplePMU")); 176 return pmuReference; 177 } 178 179 + (NSDate *)wakeTime; 180 { 181 io_service_t pmuReference = [self _pmuReference]; 182 NSNumber *autoWakeTime; 183 unsigned long long rawWakeTime; 184 185 autoWakeTime = (NSNumber *)IORegistryEntryCreateCFProperty(pmuReference, CFSTR("AutoWake"), NULL, 0); 186 closePMUComPort(pmuReference); 187 188 if (autoWakeTime == nil) return nil; 189 rawWakeTime = [autoWakeTime unsignedLongLongValue]; 190 if (rawWakeTime == 0) return nil; 191 // XXX no idea what the epoch is supposed to be, but this works... 192 return [NSDate dateWithTimeIntervalSinceReferenceDate: rawWakeTime - [[NSTimeZone systemTimeZone] secondsFromGMT] - 18446744072475736320LLU]; 193 } 194 195 + (void)setWakeInterval:(unsigned long)wakeInterval; 196 { 197 io_service_t pmuReference = [self _pmuReference]; 198 writePMUProperty(pmuReference, CFSTR("AutoWake"), (unsigned long *)&wakeInterval, sizeof(wakeInterval)); 199 closePMUComPort(pmuReference); 200 } 201 202 + (void)setWakeTime:(NSDate *)time overrideIfEarlier:(BOOL)override; 203 { 204 unsigned long wakeInterval; 205 206 if (time == nil) { 207 wakeInterval = 0; 208 override = YES; 209 } else { 210 wakeInterval = [time timeIntervalSinceNow]; 211 if (wakeInterval == 0) wakeInterval++; // 0 will disable 212 if (!override) { 213 NSDate *wakeTime = [self wakeTime]; 214 override = (wakeTime == nil || [wakeTime compare: time] == NSOrderedAscending); 215 } 216 } 217 218 if (override) { 219 [self setWakeInterval: wakeInterval]; 220 } 24 IOPMSchedulePowerEvent((CFDateRef)time, (CFStringRef)[[NSBundle mainBundle] bundleIdentifier], CFSTR(kIOPMAutoWake)); 221 25 } 222 26 223 27 + (void)clearWakeTime; 224 28 { 225 [self setWakeTime: nil overrideIfEarlier: YES];29 // XXX implement (IOPMCancelScheduledPowerEvent) 226 30 } 227 31 … … 266 70 delegate = [aDelegate retain]; 267 71 root_port = IORegisterForSystemPower(self, ¬ificationPort, powerCallback, ¬ifier); 268 NSAssert(root_port != NULL, @"IORegisterForSystemPower failed");72 NSAssert(root_port != 0, @"IORegisterForSystemPower failed"); 269 73 270 74 CFRunLoopAddSource(CFRunLoopGetCurrent(), IONotificationPortGetRunLoopSource(notificationPort), kCFRunLoopDefaultMode); -
trunk/Cocoa/Pester/Source/PSPreferencesController.m
r133 r355 102 102 [commandShiftRejectSet release]; 103 103 [commandOptionRejectSet release]; 104 [super dealloc]; 104 105 } 105 106 -
trunk/Cocoa/Pester/Source/PSScriptAlert.m
r103 r355 50 50 if (errorMessage == nil) errorMessage = [errorInfo objectForKey: NSAppleScriptErrorBriefMessage]; 51 51 NSRunAlertPanel(@"Script loading error", 52 @"Pester encountered an error while attempting to load Ò%@Ó%@ %@",52 @"Pester encountered an error while attempting to load “%@”%@ %@", 53 53 nil, nil, nil, 54 54 [[NSFileManager defaultManager] displayNameAtPath: scriptPath], 55 errorMessage == nil ? @"" : [NSString stringWithFormat: @":\n\n%@%@", appName == nil ? @"" : @" Ò%@Óreported an error: ", errorMessage],55 errorMessage == nil ? @"" : [NSString stringWithFormat: @":\n\n%@%@", appName == nil ? @"" : @"“%@” reported an error: ", errorMessage], 56 56 errorNumber == nil ? @"" : [NSString stringWithFormat: @"(%@)", errorNumber]); 57 57 } else { … … 63 63 if (errorMessage == nil) errorMessage = [errorInfo objectForKey: NSAppleScriptErrorBriefMessage]; 64 64 NSRunAlertPanel(@"Script execution error", 65 @"Pester encountered an error while attempting to execute the script Ò%@Ó%@ %@",65 @"Pester encountered an error while attempting to execute the script “%@”%@ %@", 66 66 nil, nil, nil, 67 67 [[NSFileManager defaultManager] displayNameAtPath: scriptPath], 68 errorMessage == nil ? @"" : [NSString stringWithFormat: @":\n\n%@%@", appName == nil ? @"" : @" Ò%@Óreported an error: ", errorMessage],68 errorMessage == nil ? @"" : [NSString stringWithFormat: @":\n\n%@%@", appName == nil ? @"" : @"“%@” reported an error: ", errorMessage], 69 69 errorNumber == nil ? @"" : [NSString stringWithFormat: @"(%@)", errorNumber]); 70 70 } -
trunk/Cocoa/Pester/Source/PSTimeDateEditor.m
r102 r355 32 32 NSRange matchingRange; 33 33 while ( (title = [e nextObject]) != nil) { 34 matchingRange = [title rangeOfString: @" ÇdayÈ"];34 matchingRange = [title rangeOfString: @"«day»"]; 35 35 if (matchingRange.location != NSNotFound) { 36 36 NSMutableString *format = [title mutableCopy]; … … 44 44 itemIndex++; 45 45 } 46 [format release]; 46 47 } else itemIndex++; 47 48 } -
trunk/Cocoa/Pester/Source/PSTimer.m
r119 r355 231 231 // NSLog(@"going to sleep, setting timer %@", PSTimerOnWake); 232 232 NS_DURING 233 [PSPowerManager setWakeTime: [[PSTimerOnWake fireDate] addTimeInterval: -15] overrideIfEarlier: NO];233 [PSPowerManager setWakeTime: [[PSTimerOnWake fireDate] addTimeInterval: -15]]; 234 234 NS_HANDLER 235 235 [self performSelectorOnMainThread: @selector(_runScheduledWakeErrorPanel:) withObject: [localException description] waitUntilDone: YES];
Note:
See TracChangeset
for help on using the changeset viewer.