選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

41 行
1.5KB

  1. #import <Preferences/PSSpecifier.h>
  2. #include "DCPRootListController.h"
  3. @implementation DCPRootListController
  4. - (id)readPreferenceValue:(PSSpecifier*)specifier {
  5. NSString *path = [NSString stringWithFormat:@"/User/Library/Preferences/%@.plist", specifier.properties[@"defaults"]];
  6. NSMutableDictionary *settings = [NSMutableDictionary dictionary];
  7. [settings addEntriesFromDictionary:[NSDictionary dictionaryWithContentsOfFile:path]];
  8. return (settings[specifier.properties[@"key"]]) ?: specifier.properties[@"default"];
  9. }
  10. - (void)setPreferenceValue:(id)value specifier:(PSSpecifier*)specifier {
  11. NSString *path = [NSString stringWithFormat:@"/User/Library/Preferences/%@.plist", specifier.properties[@"defaults"]];
  12. NSMutableDictionary *settings = [NSMutableDictionary dictionary];
  13. [settings addEntriesFromDictionary:[NSDictionary dictionaryWithContentsOfFile:path]];
  14. [settings setObject:value forKey:specifier.properties[@"key"]];
  15. [settings writeToFile:path atomically:YES];
  16. CFStringRef notificationName = (CFStringRef)specifier.properties[@"PostNotification"];
  17. if (notificationName) {
  18. CFNotificationCenterPostNotification(CFNotificationCenterGetDarwinNotifyCenter(), notificationName, NULL, NULL, YES);
  19. }
  20. }
  21. - (NSArray *)specifiers {
  22. if (!_specifiers) {
  23. _specifiers = [[self loadSpecifiersFromPlistName:@"Root" target:self] retain];
  24. }
  25. return _specifiers;
  26. }
  27. -(void)save
  28. {
  29. [self.view endEditing:YES];
  30. CFNotificationCenterPostNotification(CFNotificationCenterGetDarwinNotifyCenter(), CFSTR("duplexcalendar.savepressed"), NULL, NULL, YES);
  31. }
  32. @end