Changeset 355 for trunk/Cocoa


Ignore:
Timestamp:
11/23/07 04:58:05 (17 years ago)
Author:
Nicholas Riley
Message:

English.lproj/MainMenu.nib: Modernize menu and alarm set dialog
layout. Use keyed archiving (10.2+) nib format.

Info-Pester.plist: Moved from old PBX project.

NJRFSObjectSelector.m: Bug fixes from code sent to Joey: remove
incorrect usage of tryToPerform:with:; fix logic error in menu
construction. Work around Cocoa's deciding that the menu font size
needs adjustment when it doesn't - so the menu font size now matches
the button font size, though the position is still off. Don't pop up
a menu if we're disabled. Use IconRefs for menu icons, though not
(yet) for the button icon.

NJRHistoryTrackingComboBox.m: Remove item height adjustment
workaround; it now makes the items too tall.

NJRHotKey.m: Add a missing [super dealloc] caught by current GCC.

NJRHotKeyField.m: Add a missing [super dealloc] caught by current GCC.

NJRHotKeyManager.m: Add a missing [super dealloc] caught by current
GCC.

NJRIntervalField.m: Fix some type errors.

NJRQTMediaPopUpButton.m: Replace SoundFileManager SPI usage, which
doesn't work in Leopard anyway, with manual enumeration of system
sounds. Start migration to QTKit. Use IconRefs for menu icons.

NJRReadMeController.m: Change source encoding to UTF-8.

NJRSoundManager.m: Fix a type error.

NJRVoicePopUpButton.m: Change source encoding to UTF-8.

NSMenuItem-NJRExtensions.[hm]: Code from ICeCoffEE to use IconRefs for
menu item icons.

PSAlarm.m: Change source encoding to UTF-8.

PSAlarms.m: Fix a signedness mismatch.

PSAlarmsController.m: Change source encoding to UTF-8.

PSAlarmSetController.m: Set keyboard focus after unchecking "Do
script:" and "Play" checkboxes.

PSAlerts.m: Add a missing [super dealloc] caught by current GCC. Fix
a memory leak in property list serialization.

PSPowerManager.[hm]: There's now API for scheduling wakeups; use it
(the old code asserted on startup). To fix: removing scheduled
wakeup. Fix a small type-checking error.

PSPreferencesController.m: Add a missing [super dealloc] caught by
current GCC.

PSScriptAlert.m: Change source encoding to UTF-8.

PSTimeDateEditor.m: Fix a tiny, and one-time, memory leak.

PSTimer.m: Update for new PSPowerManager API.

Pester.pbproj: Deleted; now supporting OS X 10.4+ (up from 10.1,
aiee.)

Pester.xcodeproj: Xcode 2.4+ project, upgraded targets, etc.

SoundFileManager.h: Deleted; this SPI no longer exists in Leopard and
possibly earlier.

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  
    11<?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">
    33<plist version="1.0">
    44<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>
    145        <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>
    1611        <key>IBOpenObjects</key>
    1712        <array>
    18                 <integer>640</integer>
    19                 <integer>21</integer>
     13                <integer>2</integer>
    2014        </array>
    2115        <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>
    4319</dict>
    4420</plist>
  • trunk/Cocoa/Pester/Source/NJRFSObjectSelector.m

    r53 r355  
    11#import "NJRFSObjectSelector.h"
     2#import "NSMenuItem-NJRExtensions.h"
    23#import "NSImage-NJRExtensions.h"
    34#import "NSString-NJRExtensions.h"
     
    8485- (void)setImage:(NSImage *)image;
    8586{
     87    // XXX change to use IconRef; see ICeCoffEELabeledIconCell and Google
    8688    [super setImage: [image bestFitImageForSize: [[self cell] cellSize]]];
    8789}
     
    111113        NSAssert1([files count] == 1, @"%d items returned, only one expected", [files count]);
    112114        [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];
    114117    }
    115118}
     
    145148            }
    146149            do {
     150                NSAssert1(![path isEqualToString: revealPath], @"Stuck on path |%@|", [alias fullPath]);
    147151                item = [menu addItemWithTitle: [fmgr displayNameAtPath: path]
    148152                                       action: @selector(revealInFinder:)
     
    150154                [item setTarget: self];
    151155                [item setRepresentedObject: revealPath];
    152                 [item setImage:
    153                     [[[NSWorkspace sharedWorkspace] iconForFile: path] bestFitImageForSize: NSMakeSize(16, 16)]];
     156                [item setImageFromPath: path];
    154157                revealPath = path;
    155158                path = [path stringByDeletingLastPathComponent];
    156                 NSAssert1(![path isEqualToString: revealPath], @"Stuck on path |%@|", [alias fullPath]);
    157159            } while (![revealPath isEqualToString: @"/"] && ![path isEqualToString: @"/Volumes"]);
    158160            [[self cell] setMenu: menu];
     
    195197- (void)mouseDown:(NSEvent *)theEvent;
    196198{
     199    if (![self isEnabled]) return;
     200   
    197201    NSMenu *menu = [[self cell] menu];
    198202    MenuRef mRef = _NSGetCarbonMenu(menu);
     
    219223                                  pressure: [theEvent pressure]];
    220224
    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]];
    224229}
    225230
     
    310315        if (url == nil) return NO;
    311316        [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];
    313319    }
    314320    return YES;
  • trunk/Cocoa/Pester/Source/NJRHistoryTrackingComboBox.m

    r103 r355  
    2727    [self removeAllItems];
    2828    [self addItemsWithObjectValues: [[NSUserDefaults standardUserDefaults] stringArrayForKey: [self _defaultKey]]];
    29     [self setItemHeight: [self itemHeight] + 2];
    3029}
    3130
  • trunk/Cocoa/Pester/Source/NJRHotKey.m

    r133 r355  
    3939{
    4040    [hotKeyCharacters release];
     41    [super dealloc];
    4142}
    4243
  • trunk/Cocoa/Pester/Source/NJRHotKeyField.m

    r132 r355  
    6565{
    6666    [hotKey release];
     67    [super dealloc];
    6768}
    6869
  • trunk/Cocoa/Pester/Source/NJRHotKeyManager.m

    r131 r355  
    3232    [hotKey release];
    3333    [target release];
     34    [super dealloc];
    3435}
    3536
  • trunk/Cocoa/Pester/Source/NJRIntervalField.m

    r103 r355  
    8484    NSString *alertMessage = nil;
    8585    NSString *alternateButtonString = nil;
    86     NSDecimalNumber *proposedValue = nil;
     86    NSNumber *proposedValue = nil;
    8787    NSDictionary *contextInfo;
    8888
  • trunk/Cocoa/Pester/Source/NJRQTMediaPopUpButton.m

    r133 r355  
    88
    99#import "NJRQTMediaPopUpButton.h"
    10 #import "SoundFileManager.h"
    1110#import "NJRSoundManager.h"
    1211#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>
    2118
    2219static const int NJRQTMediaPopUpButtonMaxRecentItems = 10;
     
    6663    [item setTarget: self];
    6764    [item setRepresentedObject: alias];
    68     [item setImage: [[[NSWorkspace sharedWorkspace] iconForFile: path] bestFitImageForSize: NSMakeSize(16, 16)]];
     65    [item setImageFromPath: path];
    6966    [recentMediaAliasData addObject: [alias aliasData]];
    7067    if ([recentMediaAliasData count] > NJRQTMediaPopUpButtonMaxRecentItems) {
     
    115112- (void)_setUp;
    116113{
    117     NSMenu *menu;
    118     NSMenuItem *item;
    119     SoundFileManager *sfm = [SoundFileManager sharedSoundFileManager];
    120     int soundCount = [sfm count];
    121 
     114    NSMenu *menu = [self menu];
    122115    [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: @""];
    125119    [item setTarget: self];
    126120    [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) {
    128169        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: @""];
    129170        [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         
    142173    [menu addItem: [NSMenuItem separatorItem]];
    143174    item = [menu addItemWithTitle: NSLocalizedString(@"Other...", "Media popup item to select another sound/movie/image") action: @selector(select:) keyEquivalent: @""];
     
    212243- (NSMenuItem *)_itemForAlias:(BDAlias *)alias;
    213244{
    214     NSString *path;
    215     SoundFile *sf;
    216     if (alias == nil) {
    217         return [self itemAtIndex: 0];
    218     }
     245    if (alias == nil) return [self itemAtIndex: 0];
    219246
    220247    // [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];
    234249
    235250    // selected a system sound?
    236     if (sf != nil) {
     251    int itemIndex = [[self menu] indexOfItemWithRepresentedObject: path];
     252    if (itemIndex != -1) {
    237253        // NSLog(@"_itemForAlias: selected system sound");
    238         return [self itemAtIndex: [self indexOfItemWithRepresentedObject: sf]];
     254        return [self itemAtIndex: itemIndex];
    239255    } else {
    240256        NSEnumerator *e = [recentMediaAliasData reverseObjectEnumerator];
     
    406422}
    407423
    408 - (void)_soundFileSelected:(NSMenuItem *)sender;
    409 {
    410     [self _setPath: [(SoundFile *)[sender representedObject] path]];
     424- (void)_systemSoundSelected:(NSMenuItem *)sender;
     425{
     426    [self _setPath: [sender representedObject]];
    411427    if (![self _validateWithPreview: YES]) {
    412428        [[self menu] removeItem: sender];
  • trunk/Cocoa/Pester/Source/NJRReadMeController.m

    r103 r355  
    6464    unsigned i;
    6565    for (i = 0 ; i < level ; i++) {
    66         [s appendString: @"ÊÊ"];
     66        [s appendString: @"  "];
    6767    }
    6868    [s appendString: description];
     
    101101        NSString *frameAutosaveName;
    102102        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 up
     103            // XXX workaround for bug in 10.1.510.2.4 (at least): autosave name set in IB doesn't show up
    104104            [self setWindowFrameAutosaveName: @"Read Me"];
    105105            frameAutosaveName = [window frameAutosaveName];
  • trunk/Cocoa/Pester/Source/NJRSoundManager.m

    r133 r355  
    3434
    3535    propertySize = sizeof(stereoChannels);
    36     err = AudioDeviceGetProperty(deviceID, NULL, false, kAudioDevicePropertyPreferredChannelsForStereo, &propertySize, &stereoChannels);
     36    err = AudioDeviceGetProperty(deviceID, 0, false, kAudioDevicePropertyPreferredChannelsForStereo, &propertySize, &stereoChannels);
    3737    if (err != noErr) return NO;
    3838    return YES;
  • trunk/Cocoa/Pester/Source/NJRVoicePopUpButton.m

    r103 r355  
    2121    [menu setAutoenablesItems: NO];
    2222    // 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: @""];
    2424    [item setEnabled: NO];
    2525    [menu addItem: [NSMenuItem separatorItem]];
  • trunk/Cocoa/Pester/Source/PSAlarm.m

    r113 r355  
    343343    NSString *timeRemainingString = [self _stringForInterval: llround([self timeRemaining])];
    344344   
    345     if (timeRemainingString == nil) return @"ÇexpiredÈ";
     345    if (timeRemainingString == nil) return @"«expired»";
    346346    return timeRemainingString;
    347347}
  • trunk/Cocoa/Pester/Source/PSAlarmSetController.m

    r133 r355  
    373373        [[self window] makeFirstResponder: scriptSelectButton];
    374374        if ([script alias] == nil) [scriptSelectButton performClick: sender];
     375    } else {
     376        [[self window] makeFirstResponder: sender];
    375377    }
    376378}
     
    382384    if (doSpeakSelected && sender != nil)
    383385        [[self window] makeFirstResponder: voice];
     386    else
     387        [[self window] makeFirstResponder: sender];     
    384388}
    385389
  • trunk/Cocoa/Pester/Source/PSAlarms.m

    r113 r355  
    176176    NSEnumerator *e = [indices objectEnumerator];
    177177    NSNumber *n;
    178     int indexCount = [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));
    180180    NS_DURING
    181181        while ( (n = [e nextObject]) != nil) {
  • trunk/Cocoa/Pester/Source/PSAlarmsController.m

    r113 r355  
    106106        if ([[tableColumn identifier] isEqualToString: @"date"]) return [alarm shortDateString];
    107107        if ([[tableColumn identifier] isEqualToString: @"time"]) {
    108             if (date == nil) return @"ÇexpiredÈ";
     108            if (date == nil) return @"«expired»";
    109109            return [alarm timeString];
    110110        }
  • trunk/Cocoa/Pester/Source/PSAlerts.m

    r103 r355  
    4141{
    4242    [alerts release]; alerts = nil;
     43    [super dealloc];
    4344}
    4445
     
    121122        [plAlerts addObject: [alert propertyListRepresentation]];
    122123    }
    123     return [NSDictionary dictionaryWithObject: plAlerts forKey: PLAlerts];
     124    NSDictionary *dict = [NSDictionary dictionaryWithObject: plAlerts forKey: PLAlerts];
     125    [plAlerts release];
     126    return dict;
    124127}
    125128
  • trunk/Cocoa/Pester/Source/PSPowerManager.h

    r119 r355  
    2121
    2222+ (BOOL)autoWakeSupported;
    23 + (NSDate *)wakeTime;
    24 + (void)setWakeInterval:(unsigned long)wakeInterval;
    25 + (void)setWakeTime:(NSDate *)time overrideIfEarlier:(BOOL)override;
     23+ (void)setWakeTime:(NSDate *)time;
    2624+ (void)clearWakeTime;
    2725
  • trunk/Cocoa/Pester/Source/PSPowerManager.m

    r119 r355  
    1111#import <IOKit/pwr_mgt/IOPMLib.h>
    1212#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 and
    21  * are subject to the Apple Public Source License Version 1.1 (the
    22  * "License").  You may not use this file except in compliance with the
    23  * License.  Please obtain a copy of the License at
    24  * http://www.apple.com/publicsource and read it before using this file.
    25  *
    26  * This Original Code and all software distributed under the License are
    27  * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
    28  * 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 the
    31  * License for the specific language governing rights and limitations
    32  * 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) is
    40 powered off. The PMU chip is one of the few things left powered on, and it's
    41 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 PMU
    48 // #define kAppleVIAUserClientMagicCookie 0x101beef // or 0x101face  -- for PMU
    49 
    50 // The difference is 101beef is only for superusers and 101face works for
    51 // non-privileged users.  I have not determined which calls are only available
    52 // for superusers
    53 
    54 #define PMU_MAGIC_PASSWORD      0x0101FACE
    55 
    56 /* ==========================================
    57 * Close a device user client
    58 * =========================================== */
    59 static kern_return_t
    60 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 client
    71 * =========================================== */
    72 static void
    73 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 registry
    82 * property.
    83 * ===========================================  */
    84 void
    85 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 driver
    101 * Arguments
    102 *     pmuReference - the IORegistry device to write to
    103 *     propertyName - Name of the property to write to
    104 *     data - Data to write
    105 *     dataSize - Data size
    106 * =========================================== */
    107 void
    108 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 an
    119 * IONetworkInterface objects with the given
    120 * name.
    121 * If a match is found, the object is returned.
    122 * =========================================== */
    123 
    124 io_service_t
    125 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 IORegistry
    138 * =========================================== */
    139 io_service_t
    140 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_kernel
    146     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 IORegistry
    155 * =========================================== */
    156 void
    157 closePMUComPort(io_object_t pmuRef)
    158 {
    159     IOObjectRelease(pmuRef);
    160 }
    16113
    16214@implementation PSPowerManager
     
    16416+ (BOOL)autoWakeSupported;
    16517{
    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
    16919    return YES;
    17020}
    17121
    172 + (io_service_t)_pmuReference;
     22+ (void)setWakeTime:(NSDate *)time;
    17323{
    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));
    22125}
    22226
    22327+ (void)clearWakeTime;
    22428{
    225     [self setWakeTime: nil overrideIfEarlier: YES];
     29    // XXX implement (IOPMCancelScheduledPowerEvent)
    22630}
    22731
     
    26670        delegate = [aDelegate retain];
    26771        root_port = IORegisterForSystemPower(self, &notificationPort, powerCallback, &notifier);
    268         NSAssert(root_port != NULL, @"IORegisterForSystemPower failed");
     72        NSAssert(root_port != 0, @"IORegisterForSystemPower failed");
    26973
    27074        CFRunLoopAddSource(CFRunLoopGetCurrent(), IONotificationPortGetRunLoopSource(notificationPort), kCFRunLoopDefaultMode);
  • trunk/Cocoa/Pester/Source/PSPreferencesController.m

    r133 r355  
    102102    [commandShiftRejectSet release];
    103103    [commandOptionRejectSet release];
     104    [super dealloc];
    104105}
    105106
  • trunk/Cocoa/Pester/Source/PSScriptAlert.m

    r103 r355  
    5050            if (errorMessage == nil) errorMessage = [errorInfo objectForKey: NSAppleScriptErrorBriefMessage];
    5151            NSRunAlertPanel(@"Script loading error",
    52                             @"Pester encountered an error while attempting to load Ò%@Ó%@ %@",
     52                            @"Pester encountered an error while attempting to load “%@”%@ %@",
    5353                            nil, nil, nil,
    5454                            [[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],
    5656                            errorNumber == nil ? @"" : [NSString stringWithFormat: @"(%@)", errorNumber]);
    5757        } else {
     
    6363                if (errorMessage == nil) errorMessage = [errorInfo objectForKey: NSAppleScriptErrorBriefMessage];
    6464                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 “%@”%@ %@",
    6666                                nil, nil, nil,
    6767                                [[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],
    6969                                errorNumber == nil ? @"" : [NSString stringWithFormat: @"(%@)", errorNumber]);
    7070            }
  • trunk/Cocoa/Pester/Source/PSTimeDateEditor.m

    r102 r355  
    3232    NSRange matchingRange;
    3333    while ( (title = [e nextObject]) != nil) {
    34         matchingRange = [title rangeOfString: @"ÇdayÈ"];
     34        matchingRange = [title rangeOfString: @"«day»"];
    3535        if (matchingRange.location != NSNotFound) {
    3636            NSMutableString *format = [title mutableCopy];
     
    4444                itemIndex++;
    4545            }
     46            [format release];
    4647        } else itemIndex++;
    4748    }
  • trunk/Cocoa/Pester/Source/PSTimer.m

    r119 r355  
    231231            // NSLog(@"going to sleep, setting timer %@", PSTimerOnWake);
    232232            NS_DURING
    233                 [PSPowerManager setWakeTime: [[PSTimerOnWake fireDate] addTimeInterval: -15] overrideIfEarlier: NO];
     233                [PSPowerManager setWakeTime: [[PSTimerOnWake fireDate] addTimeInterval: -15]];
    234234            NS_HANDLER
    235235                [self performSelectorOnMainThread: @selector(_runScheduledWakeErrorPanel:) withObject: [localException description] waitUntilDone: YES];
Note: See TracChangeset for help on using the changeset viewer.