blob: fd65194afce08d1ae20b406eda28ac0e4b5193a2 [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]];
42
43 [commandline setStringValue: [settings commandLineForScript: @"<your script here>"]];
44}
45
46- (void) windowDidLoad
47{
48 [super windowDidLoad];
49 [self load_defaults];
50 [self update_display];
51}
52
53- (void)update_settings
54{
55 [settings updateFromSource: self];
56}
57
58- (IBAction)do_filetype:(id)sender
59{
60 [self load_defaults];
61 [self update_display];
62}
63
64- (IBAction)do_reset:(id)sender
65{
Jack Jansen2095c062002-11-25 13:11:06 +000066 [settings reset];
Jack Jansen3bbb6172002-07-29 21:36:35 +000067 [self update_display];
68}
69
70- (IBAction)do_apply:(id)sender
71{
72 [self update_settings];
73 [self update_display];
74}
75
76// FileSettingsSource protocol
77- (NSString *) interpreter { return [interpreter stringValue];};
Jack Jansen3d3b7462003-02-17 15:40:00 +000078- (BOOL) honourhashbang { return [honourhashbang state]; };
Jack Jansen3bbb6172002-07-29 21:36:35 +000079- (BOOL) debug { return [debug state];};
80- (BOOL) verbose { return [verbose state];};
81- (BOOL) inspect { return [inspect state];};
82- (BOOL) optimize { return [optimize state];};
83- (BOOL) nosite { return [nosite state];};
84- (BOOL) tabs { return [tabs state];};
85- (NSString *) others { return [others stringValue];};
86- (BOOL) with_terminal { return [with_terminal state];};
87
88// Delegates
89- (void)controlTextDidChange:(NSNotification *)aNotification
90{
91 [self update_settings];
92 [self update_display];
93};
94
Jack Jansenf044e092002-12-26 22:10:53 +000095// NSComboBoxDataSource protocol
96- (unsigned int)comboBox:(NSComboBox *)aComboBox indexOfItemWithStringValue:(NSString *)aString
97{
98 return [[settings interpreters] indexOfObjectIdenticalTo: aString];
99}
100
101- (id)comboBox:(NSComboBox *)aComboBox objectValueForItemAtIndex:(int)index
102{
103 return [[settings interpreters] objectAtIndex: index];
104}
105
106- (int)numberOfItemsInComboBox:(NSComboBox *)aComboBox
107{
108 return [[settings interpreters] count];
109}
110
Jack Jansen3bbb6172002-07-29 21:36:35 +0000111
112@end