Jack Jansen | 3bbb617 | 2002-07-29 21:36:35 +0000 | [diff] [blame] | 1 | #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]]; |
| 33 | [debug setState: [settings debug]]; |
| 34 | [verbose setState: [settings verbose]]; |
| 35 | [inspect setState: [settings inspect]]; |
| 36 | [optimize setState: [settings optimize]]; |
| 37 | [nosite setState: [settings nosite]]; |
| 38 | [tabs setState: [settings tabs]]; |
| 39 | [others setStringValue: [settings others]]; |
| 40 | [with_terminal setState: [settings with_terminal]]; |
| 41 | |
| 42 | [commandline setStringValue: [settings commandLineForScript: @"<your script here>"]]; |
| 43 | } |
| 44 | |
| 45 | - (void) windowDidLoad |
| 46 | { |
| 47 | [super windowDidLoad]; |
| 48 | [self load_defaults]; |
| 49 | [self update_display]; |
| 50 | } |
| 51 | |
| 52 | - (void)update_settings |
| 53 | { |
| 54 | [settings updateFromSource: self]; |
| 55 | } |
| 56 | |
| 57 | - (IBAction)do_filetype:(id)sender |
| 58 | { |
| 59 | [self load_defaults]; |
| 60 | [self update_display]; |
| 61 | } |
| 62 | |
| 63 | - (IBAction)do_reset:(id)sender |
| 64 | { |
Jack Jansen | 2095c06 | 2002-11-25 13:11:06 +0000 | [diff] [blame] | 65 | [settings reset]; |
Jack Jansen | 3bbb617 | 2002-07-29 21:36:35 +0000 | [diff] [blame] | 66 | [self update_display]; |
| 67 | } |
| 68 | |
| 69 | - (IBAction)do_apply:(id)sender |
| 70 | { |
| 71 | [self update_settings]; |
| 72 | [self update_display]; |
| 73 | } |
| 74 | |
| 75 | // FileSettingsSource protocol |
| 76 | - (NSString *) interpreter { return [interpreter stringValue];}; |
| 77 | - (BOOL) debug { return [debug state];}; |
| 78 | - (BOOL) verbose { return [verbose state];}; |
| 79 | - (BOOL) inspect { return [inspect state];}; |
| 80 | - (BOOL) optimize { return [optimize state];}; |
| 81 | - (BOOL) nosite { return [nosite state];}; |
| 82 | - (BOOL) tabs { return [tabs state];}; |
| 83 | - (NSString *) others { return [others stringValue];}; |
| 84 | - (BOOL) with_terminal { return [with_terminal state];}; |
| 85 | |
| 86 | // Delegates |
| 87 | - (void)controlTextDidChange:(NSNotification *)aNotification |
| 88 | { |
| 89 | [self update_settings]; |
| 90 | [self update_display]; |
| 91 | }; |
| 92 | |
Jack Jansen | f044e09 | 2002-12-26 22:10:53 +0000 | [diff] [blame^] | 93 | // NSComboBoxDataSource protocol |
| 94 | - (unsigned int)comboBox:(NSComboBox *)aComboBox indexOfItemWithStringValue:(NSString *)aString |
| 95 | { |
| 96 | return [[settings interpreters] indexOfObjectIdenticalTo: aString]; |
| 97 | } |
| 98 | |
| 99 | - (id)comboBox:(NSComboBox *)aComboBox objectValueForItemAtIndex:(int)index |
| 100 | { |
| 101 | return [[settings interpreters] objectAtIndex: index]; |
| 102 | } |
| 103 | |
| 104 | - (int)numberOfItemsInComboBox:(NSComboBox *)aComboBox |
| 105 | { |
| 106 | return [[settings interpreters] count]; |
| 107 | } |
| 108 | |
Jack Jansen | 3bbb617 | 2002-07-29 21:36:35 +0000 | [diff] [blame] | 109 | |
| 110 | @end |