Changeset 131 for trunk/Cocoa/Pester/Source/PSPreferencesController.m
- Timestamp:
- 04/01/03 21:25:02 (21 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Cocoa/Pester/Source/PSPreferencesController.m
r130 r131 8 8 9 9 #import "PSPreferencesController.h" 10 #import "PSApplication.h" 10 11 #import "NJRHotKeyField.h" 12 #import "NJRHotKey.h" 13 #import "NJRHotKeyManager.h" 14 15 // NSUserDefaults key 16 static NSString * const PSSetAlarmHotKey = @"Pester set alarm system-wide keyboard shortcut"; 17 18 // NJRHotKeyManager shortcut identifier 19 static NSString * const PSSetAlarmHotKeyShortcut = @"PSSetAlarmHotKeyShortcut"; 11 20 12 21 @implementation PSPreferencesController 22 23 + (void)readPreferences; 24 { 25 NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; 26 NJRHotKeyManager *hotKeyManager = [NJRHotKeyManager sharedManager]; 27 NJRHotKey *hotKey = [[[NJRHotKey alloc] initWithPropertyList: [defaults dictionaryForKey: PSSetAlarmHotKey]] autorelease]; 28 29 if (hotKey == nil) { 30 [hotKeyManager removeShortcutWithIdentifier: PSSetAlarmHotKeyShortcut]; 31 } else { 32 if (![hotKeyManager addShortcutWithIdentifier: PSSetAlarmHotKeyShortcut 33 hotKey: hotKey 34 target: NSApp 35 action: @selector(orderFrontSetAlarmPanel:)]) { 36 NSRunAlertPanel(NSLocalizedString(@"Can't reserve alarm key equivalent", "Hot key set failure"), 37 NSLocalizedString(@"Pester was unable to reserve the key equivalent %@. Please select another in Pester's Preferences, or click Clear to remove it.", "Hot key set failure"), nil, nil, nil, [hotKey keyGlyphs]); 38 [defaults removeObjectForKey: PSSetAlarmHotKey]; 39 [(PSApplication *)NSApp performSelector: @selector(orderFrontPreferencesPanel:) withObject: self afterDelay: 0.1]; 40 } 41 } 42 } 13 43 14 44 #pragma mark interface updating … … 24 54 { 25 55 NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; 26 [setAlarmHotKey setFromPropertyList: [defaults dictionaryForKey: @"Pester set alarm system-wide keyboard shortcut"]]; 56 NJRHotKey *hotKey = [[NJRHotKey alloc] initWithPropertyList: [defaults dictionaryForKey: PSSetAlarmHotKey]]; 57 [setAlarmHotKey setHotKey: hotKey]; 58 [hotKey release]; 27 59 } 28 60 … … 30 62 { 31 63 NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; 32 [defaults setObject: [ setAlarmHotKeypropertyListRepresentation] forKey: @"Pester set alarm system-wide keyboard shortcut"];64 [defaults setObject: [[setAlarmHotKey hotKey] propertyListRepresentation] forKey: @"Pester set alarm system-wide keyboard shortcut"]; 33 65 [defaults synchronize]; 66 [[self class] readPreferences]; 34 67 } 35 68 … … 38 71 - (id)init { 39 72 if ( (self = [super initWithWindowNibName: @"Preferences"]) != nil) { 40 [ self window]; // connect outlets73 [[self window] center]; // connect outlets 41 74 [self readFromPrefs]; 42 75 [self update];
Note:
See TracChangeset
for help on using the changeset viewer.