2002-07-29 23:36:35 +02:00
|
|
|
#import "PreferencesWindowController.h"
|
|
|
|
|
|
|
|
@implementation PreferencesWindowController
|
|
|
|
|
|
|
|
+ getPreferencesWindow
|
|
|
|
{
|
|
|
|
static PreferencesWindowController *_singleton;
|
|
|
|
|
|
|
|
if (!_singleton)
|
|
|
|
_singleton = [[PreferencesWindowController alloc] init];
|
|
|
|
[_singleton showWindow: _singleton];
|
|
|
|
return _singleton;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (id) init
|
|
|
|
{
|
|
|
|
self = [self initWithWindowNibName: @"PreferenceWindow"];
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)load_defaults
|
|
|
|
{
|
|
|
|
NSString *title = [filetype titleOfSelectedItem];
|
|
|
|
|
|
|
|
settings = [FileSettings getDefaultsForFileType: title];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)update_display
|
|
|
|
{
|
|
|
|
// [[self window] setTitle: script];
|
|
|
|
|
2004-07-16 14:36:02 +02:00
|
|
|
[interpreter reloadData];
|
2002-07-29 23:36:35 +02:00
|
|
|
[interpreter setStringValue: [settings interpreter]];
|
2003-02-17 16:40:00 +01:00
|
|
|
[honourhashbang setState: [settings honourhashbang]];
|
2002-07-29 23:36:35 +02:00
|
|
|
[debug setState: [settings debug]];
|
|
|
|
[verbose setState: [settings verbose]];
|
|
|
|
[inspect setState: [settings inspect]];
|
|
|
|
[optimize setState: [settings optimize]];
|
|
|
|
[nosite setState: [settings nosite]];
|
|
|
|
[tabs setState: [settings tabs]];
|
|
|
|
[others setStringValue: [settings others]];
|
|
|
|
[with_terminal setState: [settings with_terminal]];
|
2003-06-21 00:21:03 +02:00
|
|
|
// Not scriptargs, it isn't for preferences
|
2002-07-29 23:36:35 +02:00
|
|
|
|
|
|
|
[commandline setStringValue: [settings commandLineForScript: @"<your script here>"]];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) windowDidLoad
|
|
|
|
{
|
|
|
|
[super windowDidLoad];
|
|
|
|
[self load_defaults];
|
|
|
|
[self update_display];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)update_settings
|
|
|
|
{
|
|
|
|
[settings updateFromSource: self];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (IBAction)do_filetype:(id)sender
|
|
|
|
{
|
|
|
|
[self load_defaults];
|
|
|
|
[self update_display];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (IBAction)do_reset:(id)sender
|
|
|
|
{
|
2002-11-25 14:11:06 +01:00
|
|
|
[settings reset];
|
2002-07-29 23:36:35 +02:00
|
|
|
[self update_display];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (IBAction)do_apply:(id)sender
|
|
|
|
{
|
|
|
|
[self update_settings];
|
|
|
|
[self update_display];
|
|
|
|
}
|
|
|
|
|
|
|
|
// FileSettingsSource protocol
|
|
|
|
- (NSString *) interpreter { return [interpreter stringValue];};
|
2003-02-17 16:40:00 +01:00
|
|
|
- (BOOL) honourhashbang { return [honourhashbang state]; };
|
2002-07-29 23:36:35 +02:00
|
|
|
- (BOOL) debug { return [debug state];};
|
|
|
|
- (BOOL) verbose { return [verbose state];};
|
|
|
|
- (BOOL) inspect { return [inspect state];};
|
|
|
|
- (BOOL) optimize { return [optimize state];};
|
|
|
|
- (BOOL) nosite { return [nosite state];};
|
|
|
|
- (BOOL) tabs { return [tabs state];};
|
|
|
|
- (NSString *) others { return [others stringValue];};
|
|
|
|
- (BOOL) with_terminal { return [with_terminal state];};
|
2003-06-21 00:21:03 +02:00
|
|
|
- (NSString *) scriptargs { return @"";};
|
2002-07-29 23:36:35 +02:00
|
|
|
|
|
|
|
// Delegates
|
|
|
|
- (void)controlTextDidChange:(NSNotification *)aNotification
|
|
|
|
{
|
|
|
|
[self update_settings];
|
|
|
|
[self update_display];
|
|
|
|
};
|
|
|
|
|
2002-12-26 23:10:53 +01:00
|
|
|
// NSComboBoxDataSource protocol
|
|
|
|
- (unsigned int)comboBox:(NSComboBox *)aComboBox indexOfItemWithStringValue:(NSString *)aString
|
|
|
|
{
|
2004-07-16 14:36:02 +02:00
|
|
|
NSArray *interp_list = [settings interpreters];
|
|
|
|
unsigned int rv = [interp_list indexOfObjectIdenticalTo: aString];
|
|
|
|
return rv;
|
2002-12-26 23:10:53 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
- (id)comboBox:(NSComboBox *)aComboBox objectValueForItemAtIndex:(int)index
|
|
|
|
{
|
2004-07-16 14:36:02 +02:00
|
|
|
NSArray *interp_list = [settings interpreters];
|
|
|
|
id rv = [interp_list objectAtIndex: index];
|
|
|
|
return rv;
|
2002-12-26 23:10:53 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
- (int)numberOfItemsInComboBox:(NSComboBox *)aComboBox
|
|
|
|
{
|
2004-07-16 14:36:02 +02:00
|
|
|
NSArray *interp_list = [settings interpreters];
|
|
|
|
int rv = [interp_list count];
|
|
|
|
return rv;
|
2002-12-26 23:10:53 +01:00
|
|
|
}
|
|
|
|
|
2002-07-29 23:36:35 +02:00
|
|
|
|
|
|
|
@end
|