Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

34 lines
1.4KB

  1. #import <Preferences/PSSpecifier.h>
  2. #include "prpRootListController.h"
  3. @implementation prpRootListController
  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. @end