source: trunk/ICeCoffEE/ICeCoffEE/ICeCoffEEController.m@ 450

Last change on this file since 450 was 447, checked in by Nicholas Riley, 16 years ago

Actually display the value of the TerminalRequireOptionForSelfDrag setting; broken since introduction in 1.4!

File size: 5.4 KB
Line 
1//
2// File: ICeCoffEEController.m
3//
4// Contains: ICeCoffEE APE preference pane controller
5//
6// Copyright: Copyright (c) 2003, Nicholas Riley
7// All Rights Reserved.
8//
9// Author(s): Nicholas Riley (Sun Jan 19 2003)
10//
11// ===========================================================================
12
13#import <ApplicationEnhancer/ApplicationEnhancer.h>
14#import "ICeCoffEEController.h"
15#import "ICeCoffEEShared.h"
16#import "ICeCoffEEServicePrefController.h"
17
18// Just a handy macro for localized strings from our bundle; unused in this project.
19#define NSLocalizedString_(key, comment) [[self bundle] localizedStringForKey:(key) value:@"" table:nil]
20
21@implementation ICeCoffEEController
22
23// This method should return an id of a class that implements the protocol
24// required by APE Manager.
25
26+ (id)prefPaneHandlerForAPE:(NSBundle*)apeBundle andBundle:(NSBundle*)prefPaneBundle
27{
28 return [[self alloc] initWithAPE: apeBundle andBundle: prefPaneBundle];
29}
30
31// Init the instance of our class
32- (id)initWithAPE:(NSBundle*)apeBundle andBundle:(NSBundle*)prefPaneBundle
33{
34 [self setAPEBundle: apeBundle prefPaneBundle: prefPaneBundle];
35
36 [NSBundle loadNibNamed:@"APE Manager plugin" owner:self]; // load our nib file; it will call our awakeFromNib method
37
38 return self;
39}
40
41// This method is called when the preference pane is about to be shown.
42- (void)willLoad
43{
44 // we do nothing here
45}
46
47// This method is called when the preference pane will be dismissed.
48- (void)willUnload
49{
50 [prefs release];
51 prefs = nil;
52}
53
54// This method should return an NSView to be loaded into APE Manager preference
55// area.
56- (NSView *)mainView
57{
58 return [window contentView];
59}
60
61#define ICP(pref) (NSString *)kIC ## pref
62
63// This method is called once our nib file is loaded (we load it in the init method)
64- (void)awakeFromNib
65{
66 // load the preferences for our APE module
67 prefs = [[CFPreferencesWrapper_ICeCoffEE preferencesWithApplication: (NSString *)kICBundleIdentifier] retain];
68
69 CFBundleRef apeBundle = CFBundleCreate(NULL, (CFURLRef)[NSURL fileURLWithPath: [_apeBundle bundlePath]]);
70 if ([prefs integerForKey: ICP(LastLoadedVersion)] != CFBundleGetVersionNumber(apeBundle)) {
71 [tabView selectTabViewItemWithIdentifier: @"noPrefs"];
72 CFRelease(apeBundle);
73 return;
74 }
75 CFRelease(apeBundle);
76 [tabView selectTabViewItemWithIdentifier: @"prefs"];
77
78 [commandClickEnabled setState: [prefs boolForKey: ICP(CommandClickEnabled)]];
79 [self commandClickEnabled: nil];
80 [textBlinkEnabled setState: [prefs boolForKey: ICP(TextBlinkEnabled)]];
81 [self textBlinkEnabled: nil];
82 int blink = [prefs integerForKey: ICP(TextBlinkCount)];
83 if (blink != -1 && (blink = [textBlinkCount indexOfItemWithTag: blink]) != -1)
84 [textBlinkCount selectItemAtIndex: blink];
85 [servicesInContextualMenu setState: [prefs boolForKey: ICP(ServicesInContextualMenu)]];
86 [servicesInMenuBar setState: [prefs boolForKey: ICP(ServicesInMenuBar)]];
87 [terminalRequireOptionForSelfDrag setState: [prefs boolForKey: ICP(TerminalRequireOptionForSelfDrag)]];
88 [errorSoundEnabled setState: [prefs boolForKey: ICP(ErrorSoundEnabled)]];
89 [errorDialogEnabled setState: [prefs boolForKey: ICP(ErrorDialogEnabled)]];
90}
91
92- (void)setAPEBundle:(NSBundle*)apeBundle prefPaneBundle:(NSBundle *)aBundle;
93{
94 [apeBundle retain];
95 [_apeBundle release];
96 _apeBundle = apeBundle;
97 [aBundle retain];
98 [_bundle release];
99 _bundle = aBundle;
100}
101
102- (NSBundle *)bundle;
103{
104 [_bundle autorelease];
105 return [_bundle retain];
106}
107
108- (void)prefsChanged;
109{
110 [prefs synchronize];
111 APEMessageBroadcast(kICBundleIdentifier, kICPreferencesChanged, NULL);
112}
113
114- (IBAction)commandClickEnabled:(NSButton *)sender;
115{
116 BOOL enabled = [commandClickEnabled state];
117 if (sender != nil) {
118 [prefs setBool: enabled forKey: ICP(CommandClickEnabled)];
119 [self prefsChanged];
120 }
121 [textBlinkEnabled setEnabled: enabled];
122 [textBlinkCount setEnabled: enabled ? [textBlinkEnabled state] : NO];
123}
124- (IBAction)textBlinkEnabled:(NSButton *)sender;
125{
126 BOOL enabled = [textBlinkEnabled state];
127 if (sender != nil) {
128 [prefs setBool: enabled forKey: ICP(TextBlinkEnabled)];
129 [self prefsChanged];
130 }
131 [textBlinkCount setEnabled: enabled];
132}
133- (IBAction)textBlinkCount:(NSPopUpButton *)sender;
134{
135 [prefs setInteger: [[textBlinkCount selectedItem] tag] forKey: ICP(TextBlinkCount)];
136 [self prefsChanged];
137}
138- (IBAction)servicesInContextualMenu:(NSButton *)sender;
139{
140 [prefs setBool: [servicesInContextualMenu state] forKey: ICP(ServicesInContextualMenu)];
141 [self prefsChanged];
142}
143- (IBAction)servicesInMenuBar:(NSButton *)sender;
144{
145 [prefs setBool: [servicesInMenuBar state] forKey: ICP(ServicesInMenuBar)];
146 [self prefsChanged];
147}
148- (IBAction)editContextualServices:(NSButton *)sender;
149{
150 [[ICeCoffEEServicePrefController alloc] performSelector: @selector(initWithParentWindow:) withObject: [NSApp mainWindow] afterDelay: 0.01];
151}
152- (IBAction)terminalRequireOptionForSelfDrag:(NSButton *)sender;
153{
154 [prefs setBool: [terminalRequireOptionForSelfDrag state] forKey: ICP(TerminalRequireOptionForSelfDrag)];
155 [self prefsChanged];
156}
157- (IBAction)errorSoundEnabled:(NSButton *)sender;
158{
159 [prefs setBool: [errorSoundEnabled state] forKey: ICP(ErrorSoundEnabled)];
160 [self prefsChanged];
161}
162- (IBAction)errorDialogEnabled:(NSButton *)sender;
163{
164 [prefs setBool: [errorDialogEnabled state] forKey: ICP(ErrorDialogEnabled)];
165 [self prefsChanged];
166}
167
168@end
Note: See TracBrowser for help on using the repository browser.