_make_boundary(): Fix for SF bug #745478, broken boundary calculation
[python/dscho.git] / Mac / OSX / PythonLauncher / PreferencesWindowController.m
blobfd65194afce08d1ae20b406eda28ac0e4b5193a2
1 #import "PreferencesWindowController.h"
3 @implementation PreferencesWindowController
5 + getPreferencesWindow
7     static PreferencesWindowController *_singleton;
8     
9     if (!_singleton)
10         _singleton = [[PreferencesWindowController alloc] init];
11     [_singleton showWindow: _singleton];
12     return _singleton;
15 - (id) init
17     self = [self initWithWindowNibName: @"PreferenceWindow"];
18     return self;
21 - (void)load_defaults
23     NSString *title = [filetype titleOfSelectedItem];
24     
25     settings = [FileSettings getDefaultsForFileType: title];
28 - (void)update_display
30 //    [[self window] setTitle: script];
31     
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]];
42     
43     [commandline setStringValue: [settings commandLineForScript: @"<your script here>"]];
46 - (void) windowDidLoad
48     [super windowDidLoad];
49     [self load_defaults];
50     [self update_display];
53 - (void)update_settings
55     [settings updateFromSource: self];
58 - (IBAction)do_filetype:(id)sender
60     [self load_defaults];
61     [self update_display];
64 - (IBAction)do_reset:(id)sender
66     [settings reset];
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];};
88 // Delegates
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];
112 @end