blob: 5dd08f36927c8f912024e6a2489d10169a02c769 [file] [log] [blame]
Jack Jansen3bbb6172002-07-29 21:36:35 +00001#import "PreferencesWindowController.h"
2
3@implementation PreferencesWindowController
4
5+ getPreferencesWindow
6{
7 static PreferencesWindowController *_singleton;
8
9 if (!_singleton)
10 _singleton = [[PreferencesWindowController alloc] init];
11 [_singleton showWindow: _singleton];
12 return _singleton;
13}
14
15- (id) init
16{
17 self = [self initWithWindowNibName: @"PreferenceWindow"];
18 return self;
19}
20
21- (void)load_defaults
22{
23 NSString *title = [filetype titleOfSelectedItem];
24
25 settings = [FileSettings getDefaultsForFileType: title];
26}
27
28- (void)update_display
29{
30// [[self window] setTitle: script];
31
32 [interpreter setStringValue: [settings interpreter]];
Jack Jansen3d3b7462003-02-17 15:40:00 +000033 [honourhashbang setState: [settings honourhashbang]];
Jack Jansen3bbb6172002-07-29 21:36:35 +000034 [debug setState: [settings debug]];
35 [verbose setState: [settings verbose]];
36 [inspect setState: [settings inspect]];
37 [optimize setState: [settings optimize]];
38 [nosite setState: [settings nosite]];
39 [tabs setState: [settings tabs]];
40 [others setStringValue: [settings others]];
41 [with_terminal setState: [settings with_terminal]];
Jack Jansend7cccdd2003-06-20 22:21:03 +000042 // Not scriptargs, it isn't for preferences
Jack Jansen3bbb6172002-07-29 21:36:35 +000043
44 [commandline setStringValue: [settings commandLineForScript: @"<your script here>"]];
45}
46
47- (void) windowDidLoad
48{
49 [super windowDidLoad];
50 [self load_defaults];
51 [self update_display];
52}
53
54- (void)update_settings
55{
56 [settings updateFromSource: self];
57}
58
59- (IBAction)do_filetype:(id)sender
60{
61 [self load_defaults];
62 [self update_display];
63}
64
65- (IBAction)do_reset:(id)sender
66{
Jack Jansen2095c062002-11-25 13:11:06 +000067 [settings reset];
Jack Jansen3bbb6172002-07-29 21:36:35 +000068 [self update_display];
69}
70
71- (IBAction)do_apply:(id)sender
72{
73 [self update_settings];
74 [self update_display];
75}
76
77// FileSettingsSource protocol
78- (NSString *) interpreter { return [interpreter stringValue];};
Jack Jansen3d3b7462003-02-17 15:40:00 +000079- (BOOL) honourhashbang { return [honourhashbang state]; };
Jack Jansen3bbb6172002-07-29 21:36:35 +000080- (BOOL) debug { return [debug state];};
81- (BOOL) verbose { return [verbose state];};
82- (BOOL) inspect { return [inspect state];};
83- (BOOL) optimize { return [optimize state];};
84- (BOOL) nosite { return [nosite state];};
85- (BOOL) tabs { return [tabs state];};
86- (NSString *) others { return [others stringValue];};
87- (BOOL) with_terminal { return [with_terminal state];};
Jack Jansend7cccdd2003-06-20 22:21:03 +000088- (NSString *) scriptargs { return @"";};
Jack Jansen3bbb6172002-07-29 21:36:35 +000089
90// Delegates
91- (void)controlTextDidChange:(NSNotification *)aNotification
92{
93 [self update_settings];
94 [self update_display];
95};
96
Jack Jansenf044e092002-12-26 22:10:53 +000097// NSComboBoxDataSource protocol
98- (unsigned int)comboBox:(NSComboBox *)aComboBox indexOfItemWithStringValue:(NSString *)aString
99{
100 return [[settings interpreters] indexOfObjectIdenticalTo: aString];
101}
102
103- (id)comboBox:(NSComboBox *)aComboBox objectValueForItemAtIndex:(int)index
104{
105 return [[settings interpreters] objectAtIndex: index];
106}
107
108- (int)numberOfItemsInComboBox:(NSComboBox *)aComboBox
109{
110 return [[settings interpreters] count];
111}
112
Jack Jansen3bbb6172002-07-29 21:36:35 +0000113
114@end