1 #import "PreferencesWindowController.h"
3 @implementation PreferencesWindowController
7 static PreferencesWindowController *_singleton;
10 _singleton = [[PreferencesWindowController alloc] init];
11 [_singleton showWindow: _singleton];
17 self = [self initWithWindowNibName: @"PreferenceWindow"];
23 NSString *title = [filetype titleOfSelectedItem];
25 settings = [FileSettings getDefaultsForFileType: title];
28 - (void)update_display
30 // [[self window] setTitle: script];
32 [interpreter reloadData];
33 [interpreter setStringValue: [settings interpreter]];
34 [honourhashbang setState: [settings honourhashbang]];
35 [debug setState: [settings debug]];
36 [verbose setState: [settings verbose]];
37 [inspect setState: [settings inspect]];
38 [optimize setState: [settings optimize]];
39 [nosite setState: [settings nosite]];
40 [tabs setState: [settings tabs]];
41 [others setStringValue: [settings others]];
42 [with_terminal setState: [settings with_terminal]];
43 // Not scriptargs, it isn't for preferences
45 [commandline setStringValue: [settings commandLineForScript: @"<your script here>"]];
48 - (void) windowDidLoad
50 [super windowDidLoad];
52 [self update_display];
55 - (void)update_settings
57 [settings updateFromSource: self];
60 - (IBAction)do_filetype:(id)sender
63 [self update_display];
66 - (IBAction)do_reset:(id)sender
69 [self update_display];
72 - (IBAction)do_apply:(id)sender
74 [self update_settings];
75 [self update_display];
78 // FileSettingsSource protocol
79 - (NSString *) interpreter { return [interpreter stringValue];};
80 - (BOOL) honourhashbang { return [honourhashbang state]; };
81 - (BOOL) debug { return [debug state];};
82 - (BOOL) verbose { return [verbose state];};
83 - (BOOL) inspect { return [inspect state];};
84 - (BOOL) optimize { return [optimize state];};
85 - (BOOL) nosite { return [nosite state];};
86 - (BOOL) tabs { return [tabs state];};
87 - (NSString *) others { return [others stringValue];};
88 - (BOOL) with_terminal { return [with_terminal state];};
89 - (NSString *) scriptargs { return @"";};
92 - (void)controlTextDidChange:(NSNotification *)aNotification
94 [self update_settings];
95 [self update_display];
98 // NSComboBoxDataSource protocol
99 - (unsigned int)comboBox:(NSComboBox *)aComboBox indexOfItemWithStringValue:(NSString *)aString
101 NSArray *interp_list = [settings interpreters];
102 unsigned int rv = [interp_list indexOfObjectIdenticalTo: aString];
106 - (id)comboBox:(NSComboBox *)aComboBox objectValueForItemAtIndex:(int)index
108 NSArray *interp_list = [settings interpreters];
109 id rv = [interp_list objectAtIndex: index];
113 - (int)numberOfItemsInComboBox:(NSComboBox *)aComboBox
115 NSArray *interp_list = [settings interpreters];
116 int rv = [interp_list count];