You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

41 lines
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