Debian Codegraph @

Mac/PythonLauncher/PreferencesWindowController.m

raw
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 [interpreter reloadData];
31 [interpreter setStringValue: [settings interpreter]];
32 [honourhashbang setState: [settings honourhashbang]];
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 // Not scriptargs, it isn't for preferences
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 {
65 [settings reset];
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) honourhashbang { return [honourhashbang state]; };
78 - (BOOL) debug { return [debug state];};
79 - (BOOL) verbose { return [verbose state];};
80 - (BOOL) inspect { return [inspect state];};
81 - (BOOL) optimize { return [optimize state];};
82 - (BOOL) nosite { return [nosite state];};
83 - (BOOL) tabs { return [tabs state];};
84 - (NSString *) others { return [others stringValue];};
85 - (BOOL) with_terminal { return [with_terminal state];};
86 - (NSString *) scriptargs { return @"";};
87
88 // Delegates
89 - (void)controlTextDidChange:(NSNotification *)aNotification
90 {
91 [self update_settings];
92 [self update_display];
93 };
94
95 // NSComboBoxDataSource protocol
96 - (unsigned int)comboBox:(NSComboBox *)aComboBox indexOfItemWithStringValue:(NSString *)aString
97 {
98 NSArray *interp_list = [settings interpreters];
99 unsigned int rv = [interp_list indexOfObjectIdenticalTo: aString];
100 return rv;
101 }
102
103 - (id)comboBox:(NSComboBox *)aComboBox objectValueForItemAtIndex:(int)index
104 {
105 NSArray *interp_list = [settings interpreters];
106 id rv = [interp_list objectAtIndex: index];
107 return rv;
108 }
109
110 - (int)numberOfItemsInComboBox:(NSComboBox *)aComboBox
111 {
112 NSArray *interp_list = [settings interpreters];
113 int rv = [interp_list count];
114 return rv;
115 }
116
117
118 @end