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 setStringValue: [settings interpreter]];
33 [honourhashbang setState: [settings honourhashbang]];
34 [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]];
43 [commandline setStringValue: [settings commandLineForScript: @"<your script here>"]];
46 - (void) windowDidLoad
48 [super windowDidLoad];
50 [self update_display];
53 - (void)update_settings
55 [settings updateFromSource: self];
58 - (IBAction)do_filetype:(id)sender
61 [self update_display];
64 - (IBAction)do_reset:(id)sender
67 [self update_display];
70 - (IBAction)do_apply:(id)sender
72 [self update_settings];
73 [self update_display];
76 // FileSettingsSource protocol
77 - (NSString *) interpreter { return [interpreter stringValue];};
78 - (BOOL) honourhashbang { return [honourhashbang state]; };
79 - (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];};
89 - (void)controlTextDidChange:(NSNotification *)aNotification
91 [self update_settings];
92 [self update_display];
95 // NSComboBoxDataSource protocol
96 - (unsigned int)comboBox:(NSComboBox *)aComboBox indexOfItemWithStringValue:(NSString *)aString
98 return [[settings interpreters] indexOfObjectIdenticalTo: aString];
101 - (id)comboBox:(NSComboBox *)aComboBox objectValueForItemAtIndex:(int)index
103 return [[settings interpreters] objectAtIndex: index];
106 - (int)numberOfItemsInComboBox:(NSComboBox *)aComboBox
108 return [[settings interpreters] count];