Chameleon Applications

Chameleon Applications Svn Source Tree

Root/trunk/ChameleonPrefPane/Sources/PreferencesControllerBase.mm

1//
2// PreferencesControllerBase.mm
3// ChameleonPrefPane
4//
5// Created by Rekursor on 1/22/10.
6//
7
8#import "PreferencesControllerBase.h"
9#include <string>
10
11
12@implementation PreferencesControllerBase
13
14-(ChameleonPrefPane*) chameleon { return [ChameleonPrefPane instance]; }
15
16//--------------------------------------------------------------------------
17- (id) init
18{
19self = [super init];
20return self;
21}
22
23//--------------------------------------------------------------------------
24// from the id to desc map in prop, set all default values for dict
25+ (void) setDefaultValues: (NSMutableDictionary*) dict
26{
27
28for(const BootOptionDesc* bod = prop->firstOption();bod; bod=prop->nextOption())
29{
30switch (bod->Type)
31{
32case OptionYesNo:
33[(NSButton*)bod->ID setIntValue: (toupper(bod->Default[0])=='Y' ? 1 : 0) ];
34break;
35case OptionKernel:
36case OptionString:
37[(NSButton*)bod->ID setIntValue: 0 ];
38case OptionKernel1:
39[(NSTextField*)bod->contentID setStringValue:
40[[NSString alloc] initWithUTF8String: bod->Default] ];
41break;
42case OptionUnix:
43[(NSButton*)bod->ID setIntValue: 0 ];
44break;
45
46default:
47break;
48}
49}
50}
51//--------------------------------------------------------------------------
52- (void) refreshLockState: (id) item
53{
54 [item setEnabled:[[ChameleonPrefPane instance] isUnlocked]];
55
56}
57
58//--------------------------------------------------------------------------
59- (void) loadPreferences
60{
61[ [ChameleonPrefPane instance] loadPreferences];
62}
63
64//--------------------------------------------------------------------------
65- (bool) savePreferences
66{
67return [ [ChameleonPrefPane instance] savePreferences: [self preferencesFile] ];
68
69}
70//--------------------------------------------------------------------------
71-(NSMutableDictionary*) preferencesFile
72{
73return [[ChameleonPrefPane instance] preferencesFile];
74}
75
76//--------------------------------------------------------------------------
77-(NSMutableDictionary*) preferencesParts
78{
79return [[ChameleonPrefPane instance] preferencesParts];
80}
81
82//--------------------------------------------------------------------------
83- (bool) handleSender: (id) sender withButton: (NSButton*) button forKey:(const char*) key
84{
85return [self handleSender: sender withButton: button andField: nil forKey: key];
86}
87
88//--------------------------------------------------------------------------
89- (bool) handleSender: (id) sender withButton: (NSButton*) button andField:(NSTextField*) field forKey:(const char*) key
90{
91if((NSButton*)sender!=button || (NSTextField*)sender !=field) return false;
92if ((NSButton*)sender==button)
93{
94if (prop && prop->isValid())
95{
96std::string keyValue = prop->getStringForKey(key);
97if ( !![button intValue])
98{
99
100}
101else
102{
103
104}
105}
106}
107else
108{ // field
109
110}
111
112return true;
113}
114
115@end
116

Archive Download this file

Revision: 47