|
- #import <Preferences/PSSpecifier.h>
- #include "prpRootListController.h"
-
- @implementation prpRootListController
-
- - (id)readPreferenceValue:(PSSpecifier*)specifier {
- NSString *path = [NSString stringWithFormat:@"/User/Library/Preferences/%@.plist", specifier.properties[@"defaults"]];
- NSMutableDictionary *settings = [NSMutableDictionary dictionary];
- [settings addEntriesFromDictionary:[NSDictionary dictionaryWithContentsOfFile:path]];
- return (settings[specifier.properties[@"key"]]) ?: specifier.properties[@"default"];
- }
-
- - (void)setPreferenceValue:(id)value specifier:(PSSpecifier*)specifier {
- NSString *path = [NSString stringWithFormat:@"/User/Library/Preferences/%@.plist", specifier.properties[@"defaults"]];
- NSMutableDictionary *settings = [NSMutableDictionary dictionary];
- [settings addEntriesFromDictionary:[NSDictionary dictionaryWithContentsOfFile:path]];
- [settings setObject:value forKey:specifier.properties[@"key"]];
- [settings writeToFile:path atomically:YES];
- CFStringRef notificationName = (CFStringRef)specifier.properties[@"PostNotification"];
- if (notificationName) {
- CFNotificationCenterPostNotification(CFNotificationCenterGetDarwinNotifyCenter(), notificationName, NULL, NULL, YES);
- }
- }
-
- - (NSArray *)specifiers {
- if (!_specifiers) {
- _specifiers = [[self loadSpecifiersFromPlistName:@"Root" target:self] retain];
- }
-
- return _specifiers;
- }
-
- @end
|