Path: blob/main/Mac/PythonLauncher/PreferencesWindowController.m
12 views
#import "PreferencesWindowController.h"12@implementation PreferencesWindowController34+ getPreferencesWindow5{6static PreferencesWindowController *_singleton;78if (!_singleton)9_singleton = [[PreferencesWindowController alloc] init];10[_singleton showWindow: _singleton];11return _singleton;12}1314- (id) init15{16self = [self initWithWindowNibName: @"PreferenceWindow"];17return self;18}1920- (void)load_defaults21{22NSString *title = [filetype titleOfSelectedItem];2324settings = [FileSettings getDefaultsForFileType: title];25}2627- (void)update_display28{29[interpreter reloadData];30[interpreter setStringValue: [settings interpreter]];31[honourhashbang setState: [settings honourhashbang]];32[debug setState: [settings debug]];33[verbose setState: [settings verbose]];34[inspect setState: [settings inspect]];35[optimize setState: [settings optimize]];36[nosite setState: [settings nosite]];37[tabs setState: [settings tabs]];38[others setStringValue: [settings others]];39[with_terminal setState: [settings with_terminal]];40// Not scriptargs, it isn't for preferences41[commandline setStringValue: [settings commandLineForScript: @"<your script here>"]];42}4344- (void) windowDidLoad45{46[super windowDidLoad];47[self load_defaults];48[self update_display];49}5051- (void)update_settings52{53[settings updateFromSource: self];54}5556- (IBAction)do_filetype:(id)sender57{58[self load_defaults];59[self update_display];60}6162- (IBAction)do_reset:(id)sender63{64[settings reset];65[self update_display];66}6768- (IBAction)do_apply:(id)sender69{70[self update_settings];71[self update_display];72}7374// FileSettingsSource protocol75- (NSString *) interpreter { return [interpreter stringValue];};76- (BOOL) honourhashbang { return [honourhashbang state]; };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- (NSString *) scriptargs { return @"";};8687// Delegates88- (void)controlTextDidChange:(NSNotification *)aNotification89{90[self update_settings];91[self update_display];92};9394// NSComboBoxDataSource protocol95- (unsigned int)comboBox:(NSComboBox *)aComboBox indexOfItemWithStringValue:(NSString *)aString96{97NSArray *interp_list = [settings interpreters];98unsigned int rv = [interp_list indexOfObjectIdenticalTo: aString];99return rv;100}101102- (id)comboBox:(NSComboBox *)aComboBox objectValueForItemAtIndex:(int)index103{104NSArray *interp_list = [settings interpreters];105id rv = [interp_list objectAtIndex: index];106return rv;107}108109- (int)numberOfItemsInComboBox:(NSComboBox *)aComboBox110{111NSArray *interp_list = [settings interpreters];112int rv = [interp_list count];113return rv;114}115116117@end118119120