diff options
author | Jack Jansen <jack.jansen@cwi.nl> | 2002-07-29 21:36:35 (GMT) |
---|---|---|
committer | Jack Jansen <jack.jansen@cwi.nl> | 2002-07-29 21:36:35 (GMT) |
commit | 3bbb617ca4195af7fb9ce5751a78dd6ca3d27e16 (patch) | |
tree | f85ddc5832ff08baf4f9229acf772785027d7aca /Mac/OSX | |
parent | c0f1e7749cba16273dfa0b0cec6c39406df9d7b6 (diff) | |
download | cpython-3bbb617ca4195af7fb9ce5751a78dd6ca3d27e16.zip cpython-3bbb617ca4195af7fb9ce5751a78dd6ca3d27e16.tar.gz cpython-3bbb617ca4195af7fb9ce5751a78dd6ca3d27e16.tar.bz2 |
First stab at the launcher application. This will be run when the user
doubleclicks a .py, .pyw or .pyc file. It runs the file by invoking the
relevant interpreter (either the command line Python in a terminal window
or a Python.app for GUI-based scripts). Interpreter to use and the options
to pass are settable through preferences.
If PythonLauncher wasn't running it does its thing for one script and exits.
If it was manually started before a dialog is presented where the user
can set the options to use, etc.
To be done:
- option-drag/doubleclick should always open the interactive dialog
- Terminal-window isn't done yet
- Should be reimplemented in Python, but pyobjc isn't part of the core.
- Various menu entries should be disabled.
Diffstat (limited to 'Mac/OSX')
24 files changed, 1413 insertions, 0 deletions
diff --git a/Mac/OSX/PythonLauncher/English.lproj/Credits.rtf b/Mac/OSX/PythonLauncher/English.lproj/Credits.rtf new file mode 100644 index 0000000..930ca22 --- /dev/null +++ b/Mac/OSX/PythonLauncher/English.lproj/Credits.rtf @@ -0,0 +1,30 @@ +{\rtf1\mac\ansicpg10000\cocoartf100 +{\fonttbl\f0\fswiss\fcharset77 Helvetica-Bold;\f1\fswiss\fcharset77 Helvetica;} +{\colortbl;\red255\green255\blue255;} +\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural + +\f0\b\fs24 \cf0 Engineering: +\f1\b0 \ + Jack Jansen\ +\ + +\f0\b Human Interface Design: +\f1\b0 \ + Jack Jansen\ +\ + +\f0\b Testing: +\f1\b0 \ + Jack Jansen\ + Pythonmac-SIG@python.org\ +\ + +\f0\b Documentation: +\f1\b0 \ + Missing\ +\ + +\f0\b With special thanks to: +\f1\b0 \ + Guido, of course\ +}
\ No newline at end of file diff --git a/Mac/OSX/PythonLauncher/English.lproj/InfoPlist.strings b/Mac/OSX/PythonLauncher/English.lproj/InfoPlist.strings Binary files differnew file mode 100644 index 0000000..40b6185 --- /dev/null +++ b/Mac/OSX/PythonLauncher/English.lproj/InfoPlist.strings diff --git a/Mac/OSX/PythonLauncher/English.lproj/MainMenu.nib/classes.nib b/Mac/OSX/PythonLauncher/English.lproj/MainMenu.nib/classes.nib new file mode 100644 index 0000000..47b40ab --- /dev/null +++ b/Mac/OSX/PythonLauncher/English.lproj/MainMenu.nib/classes.nib @@ -0,0 +1,12 @@ +{ + IBClasses = ( + {CLASS = FirstResponder; LANGUAGE = ObjC; SUPERCLASS = NSObject; }, + { + ACTIONS = {showPreferences = id; }; + CLASS = MyAppDelegate; + LANGUAGE = ObjC; + SUPERCLASS = NSObject; + } + ); + IBVersion = 1; +}
\ No newline at end of file diff --git a/Mac/OSX/PythonLauncher/English.lproj/MainMenu.nib/info.nib b/Mac/OSX/PythonLauncher/English.lproj/MainMenu.nib/info.nib new file mode 100644 index 0000000..b96759a --- /dev/null +++ b/Mac/OSX/PythonLauncher/English.lproj/MainMenu.nib/info.nib @@ -0,0 +1,21 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE plist SYSTEM "file://localhost/System/Library/DTDs/PropertyList.dtd"> +<plist version="0.9"> +<dict> + <key>IBDocumentLocation</key> + <string>99 33 356 240 0 0 800 578 </string> + <key>IBEditorPositions</key> + <dict> + <key>29</key> + <string>82 396 318 44 0 0 800 578 </string> + </dict> + <key>IBFramework Version</key> + <string>263.2</string> + <key>IBOpenObjects</key> + <array> + <integer>29</integer> + </array> + <key>IBSystem Version</key> + <string>5S66</string> +</dict> +</plist> diff --git a/Mac/OSX/PythonLauncher/English.lproj/MainMenu.nib/objects.nib b/Mac/OSX/PythonLauncher/English.lproj/MainMenu.nib/objects.nib Binary files differnew file mode 100644 index 0000000..532a5c8 --- /dev/null +++ b/Mac/OSX/PythonLauncher/English.lproj/MainMenu.nib/objects.nib diff --git a/Mac/OSX/PythonLauncher/English.lproj/MyDocument.nib/classes.nib b/Mac/OSX/PythonLauncher/English.lproj/MyDocument.nib/classes.nib new file mode 100644 index 0000000..7c58149 --- /dev/null +++ b/Mac/OSX/PythonLauncher/English.lproj/MyDocument.nib/classes.nib @@ -0,0 +1,24 @@ +{ + IBClasses = ( + {CLASS = FirstResponder; LANGUAGE = ObjC; SUPERCLASS = NSObject; }, + { + ACTIONS = {do_apply = id; do_cancel = id; do_reset = id; do_run = id; }; + CLASS = MyDocument; + LANGUAGE = ObjC; + OUTLETS = { + commandline = NSTextField; + debug = NSButton; + inspect = NSButton; + interpreter = NSTextField; + nosite = NSButton; + optimize = NSButton; + others = NSTextField; + tabs = NSButton; + verbose = NSButton; + with_terminal = NSButton; + }; + SUPERCLASS = NSDocument; + } + ); + IBVersion = 1; +}
\ No newline at end of file diff --git a/Mac/OSX/PythonLauncher/English.lproj/MyDocument.nib/info.nib b/Mac/OSX/PythonLauncher/English.lproj/MyDocument.nib/info.nib new file mode 100644 index 0000000..c767646 --- /dev/null +++ b/Mac/OSX/PythonLauncher/English.lproj/MyDocument.nib/info.nib @@ -0,0 +1,16 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE plist SYSTEM "file://localhost/System/Library/DTDs/PropertyList.dtd"> +<plist version="0.9"> +<dict> + <key>IBDocumentLocation</key> + <string>265 40 356 240 0 0 800 578 </string> + <key>IBFramework Version</key> + <string>263.2</string> + <key>IBOpenObjects</key> + <array> + <integer>5</integer> + </array> + <key>IBSystem Version</key> + <string>5S66</string> +</dict> +</plist> diff --git a/Mac/OSX/PythonLauncher/English.lproj/MyDocument.nib/objects.nib b/Mac/OSX/PythonLauncher/English.lproj/MyDocument.nib/objects.nib Binary files differnew file mode 100644 index 0000000..33521ad --- /dev/null +++ b/Mac/OSX/PythonLauncher/English.lproj/MyDocument.nib/objects.nib diff --git a/Mac/OSX/PythonLauncher/FileSettings.h b/Mac/OSX/PythonLauncher/FileSettings.h new file mode 100755 index 0000000..f487469 --- /dev/null +++ b/Mac/OSX/PythonLauncher/FileSettings.h @@ -0,0 +1,53 @@ +// +// FileSettings.h +// PythonLauncher +// +// Created by Jack Jansen on Sun Jul 21 2002. +// Copyright (c) 2002 __MyCompanyName__. All rights reserved. +// + +#import <Foundation/Foundation.h> + +@protocol FileSettingsSource +- (NSString *) interpreter; +- (BOOL) debug; +- (BOOL) verbose; +- (BOOL) inspect; +- (BOOL) optimize; +- (BOOL) nosite; +- (BOOL) tabs; +- (NSString *) others; +- (BOOL) with_terminal; +@end + +@interface FileSettings : NSObject <FileSettingsSource> +{ + NSString *interpreter; // The pathname of the interpreter to use + BOOL debug; // -d option: debug parser + BOOL verbose; // -v option: verbose import + BOOL inspect; // -i option: interactive mode after script + BOOL optimize; // -O option: optimize bytecode + BOOL nosite; // -S option: don't import site.py + BOOL tabs; // -t option: warn about inconsistent tabs + NSString *others; // other options + BOOL with_terminal; // Run in terminal window + + FileSettings *origsource; + NSString *prefskey; +} + ++ (id)getDefaultsForFileType: (NSString *)filetype; ++ (id)newSettingsForFileType: (NSString *)filetype; + +- (id)init; +- (id)initWithFileSettings: (FileSettings *)source; + +- (void)updateFromSource: (id <FileSettingsSource>)source; +- (NSString *)commandLineForScript: (NSString *)script; + +- (id)factorySettingsForFileType: (NSString *)filetype; +- (void)saveDefaults; +- (void)updateFromUserDefaults: (NSString *)filetype; + + +@end diff --git a/Mac/OSX/PythonLauncher/FileSettings.m b/Mac/OSX/PythonLauncher/FileSettings.m new file mode 100755 index 0000000..99a1166 --- /dev/null +++ b/Mac/OSX/PythonLauncher/FileSettings.m @@ -0,0 +1,182 @@ +// +// FileSettings.m +// PythonLauncher +// +// Created by Jack Jansen on Sun Jul 21 2002. +// Copyright (c) 2002 __MyCompanyName__. All rights reserved. +// + +#import "FileSettings.h" + +@implementation FileSettings ++ (id)getDefaultsForFileType: (NSString *)filetype +{ + static FileSettings *default_py, *default_pyw, *default_pyc; + FileSettings **curdefault; + + if ([filetype isEqualToString: @"Python Script"]) { + curdefault = &default_py; + } else if ([filetype isEqualToString: @"Python GUI Script"]) { + curdefault = &default_pyw; + } else if ([filetype isEqualToString: @"Python Bytecode Document"]) { + curdefault = &default_pyc; + } else { + NSLog(@"Funny File Type: %@\n", filetype); + curdefault = &default_py; + filetype = @"Python Script"; + } + if (!*curdefault) { + *curdefault = [[FileSettings new] init]; + [*curdefault factorySettingsForFileType: filetype]; + [*curdefault updateFromUserDefaults: filetype]; + } + return *curdefault; +} + ++ (id)newSettingsForFileType: (NSString *)filetype +{ + FileSettings *cur; + + cur = [[FileSettings new] init]; + [cur initWithFileSettings: [FileSettings getDefaultsForFileType: filetype]]; + return cur; +} + +- (id)init +{ + self = [super init]; + return [self factorySettingsForFileType: @"Python Script"]; +} + +- (id)factorySettingsForFileType: (NSString *)filetype +{ + debug = NO; + verbose = NO; + inspect = NO; + optimize = NO; + nosite = NO; + tabs = NO; + others = @""; + if ([filetype isEqualToString: @"Python Script"] || + [filetype isEqualToString: @"Python Bytecode Document"]) { + interpreter = @"/usr/local/bin/python"; + with_terminal = YES; + } else if ([filetype isEqualToString: @"Python GUI Script"]) { + interpreter = @"/Applications/Python.app/Contents/MacOS/python"; + with_terminal = NO; + } else { + NSLog(@"Funny File Type: %@\n", filetype); + } + origsource = NULL; + return self; +} + +- (id)initWithFileSettings: (FileSettings *)source +{ + interpreter = [source->interpreter retain]; + debug = source->debug; + verbose = source->verbose; + inspect = source->inspect; + optimize = source->optimize; + nosite = source->nosite; + tabs = source->tabs; + others = [source->others retain]; + with_terminal = source->with_terminal; + + origsource = [source retain]; + return self; +} + +- (void)saveDefaults +{ + [origsource updateFromSource: self]; +} + +- (void)updateFromSource: (id <FileSettingsSource>)source +{ + interpreter = [[source interpreter] retain]; + debug = [source debug]; + verbose = [source verbose]; + inspect = [source inspect]; + optimize = [source optimize]; + nosite = [source nosite]; + tabs = [source tabs]; + others = [[source others] retain]; + with_terminal = [source with_terminal]; + if (!origsource) { + NSUserDefaults *defaults; + NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys: + interpreter, @"interpreter", + [NSNumber numberWithBool: debug], @"debug", + [NSNumber numberWithBool: verbose], @"verbose", + [NSNumber numberWithBool: inspect], @"inspect", + [NSNumber numberWithBool: optimize], @"optimize", + [NSNumber numberWithBool: nosite], @"nosite", + [NSNumber numberWithBool: nosite], @"nosite", + others, @"others", + [NSNumber numberWithBool: with_terminal], @"with_terminal", + nil]; + defaults = [NSUserDefaults standardUserDefaults]; + [defaults setObject: dict forKey: prefskey]; + } +} + +- (void)updateFromUserDefaults: (NSString *)filetype +{ + NSUserDefaults *defaults; + NSDictionary *dict; + id value; + + prefskey = [filetype retain]; + defaults = [NSUserDefaults standardUserDefaults]; + dict = [defaults dictionaryForKey: filetype]; + if (!dict) + return; + value = [dict objectForKey: @"interpreter"]; + if (value) interpreter = [value retain]; + value = [dict objectForKey: @"debug"]; + if (value) debug = [value boolValue]; + value = [dict objectForKey: @"verbose"]; + if (value) verbose = [value boolValue]; + value = [dict objectForKey: @"inspect"]; + if (value) inspect = [value boolValue]; + value = [dict objectForKey: @"optimize"]; + if (value) optimize = [value boolValue]; + value = [dict objectForKey: @"nosite"]; + if (value) nosite = [value boolValue]; + value = [dict objectForKey: @"nosite"]; + if (value) tabs = [value boolValue]; + value = [dict objectForKey: @"others"]; + if (value) others = [value retain]; + value = [dict objectForKey: @"with_terminal"]; + if (value) with_terminal = [value boolValue]; +} + +- (NSString *)commandLineForScript: (NSString *)script +{ + return [NSString stringWithFormat: + @"\"%@\"%s%s%s%s%s%s %@ \"%@\" %s", + interpreter, + debug?" -d":"", + verbose?" -v":"", + inspect?" -i":"", + optimize?" -O":"", + nosite?" -S":"", + tabs?" -t":"", + others, + script, + with_terminal? "" : " &"]; +} + +// FileSettingsSource protocol +- (NSString *) interpreter { return interpreter;}; +- (BOOL) debug { return debug;}; +- (BOOL) verbose { return verbose;}; +- (BOOL) inspect { return inspect;}; +- (BOOL) optimize { return optimize;}; +- (BOOL) nosite { return nosite;}; +- (BOOL) tabs { return tabs;}; +- (NSString *) others { return others;}; +- (BOOL) with_terminal { return with_terminal;}; + +@end diff --git a/Mac/OSX/PythonLauncher/MyAppDelegate.h b/Mac/OSX/PythonLauncher/MyAppDelegate.h new file mode 100644 index 0000000..c65175a --- /dev/null +++ b/Mac/OSX/PythonLauncher/MyAppDelegate.h @@ -0,0 +1,14 @@ +/* MyAppDelegate */ + +#import <Cocoa/Cocoa.h> + +@interface MyAppDelegate : NSObject +{ + BOOL initial_action_done; + BOOL should_terminate; +} +- (id)init; +- (IBAction)showPreferences:(id)sender; +- (BOOL)shouldShowUI; +- (BOOL)shouldTerminate; +@end diff --git a/Mac/OSX/PythonLauncher/MyAppDelegate.m b/Mac/OSX/PythonLauncher/MyAppDelegate.m new file mode 100644 index 0000000..107e7d0 --- /dev/null +++ b/Mac/OSX/PythonLauncher/MyAppDelegate.m @@ -0,0 +1,64 @@ +#import "MyAppDelegate.h" +#import "PreferencesWindowController.h" + +@implementation MyAppDelegate + +- (id)init +{ + self = [super init]; + initial_action_done = NO; + should_terminate = NO; + return self; +} + +- (IBAction)showPreferences:(id)sender +{ + [PreferencesWindowController getPreferencesWindow]; +} + +- (void)applicationDidFinishLaunching:(NSNotification *)notification +{ + // If we were opened because of a file drag or doubleclick + // we've set initial_action_done in shouldShowUI + // Otherwise we open a preferences dialog. + if (!initial_action_done) { + initial_action_done = YES; + [self showPreferences: self]; + } +} + +- (BOOL)shouldShowUI +{ + // if this call comes before applicationDidFinishLaunching: we do not show a UI + // for the file. Also, we should terminate immedeately after starting the script. + if (initial_action_done) + return YES; + initial_action_done = YES; + should_terminate = YES; + return NO; +} + +- (BOOL)shouldTerminate +{ + return should_terminate; +} + +- (BOOL)applicationShouldOpenUntitledFile:(NSApplication *)sender +{ + return NO; +} + + +- (BOOL)application:(NSApplication *)sender xx_openFile:(NSString *)filename +{ + initial_action_done = YES; + return YES; +} + +- (BOOL)application:(id)sender xx_openFileWithoutUI:(NSString *)filename +{ + initial_action_done = YES; + return YES; +} + +@end diff --git a/Mac/OSX/PythonLauncher/MyDocument.h b/Mac/OSX/PythonLauncher/MyDocument.h new file mode 100755 index 0000000..47c7be38 --- /dev/null +++ b/Mac/OSX/PythonLauncher/MyDocument.h @@ -0,0 +1,39 @@ +// +// MyDocument.h +// PythonLauncher +// +// Created by Jack Jansen on Fri Jul 19 2002. +// Copyright (c) 2002 __MyCompanyName__. All rights reserved. +// + + +#import <Cocoa/Cocoa.h> + +#import "FileSettings.h" + +@interface MyDocument : NSDocument <FileSettingsSource> +{ + IBOutlet NSTextField *interpreter; + IBOutlet NSButton *debug; + IBOutlet NSButton *verbose; + IBOutlet NSButton *inspect; + IBOutlet NSButton *optimize; + IBOutlet NSButton *nosite; + IBOutlet NSButton *tabs; + IBOutlet NSTextField *others; + IBOutlet NSButton *with_terminal; + IBOutlet NSTextField *commandline; + + NSString *script; + NSString *filetype; + FileSettings *settings; +} + +- (IBAction)do_run:(id)sender; +- (IBAction)do_cancel:(id)sender; +- (IBAction)do_reset:(id)sender; +- (IBAction)do_apply:(id)sender; + +- (void)controlTextDidChange:(NSNotification *)aNotification; + +@end diff --git a/Mac/OSX/PythonLauncher/MyDocument.m b/Mac/OSX/PythonLauncher/MyDocument.m new file mode 100755 index 0000000..a4c20d1 --- /dev/null +++ b/Mac/OSX/PythonLauncher/MyDocument.m @@ -0,0 +1,165 @@ +// +// MyDocument.m +// PythonLauncher +// +// Created by Jack Jansen on Fri Jul 19 2002. +// Copyright (c) 2002 __MyCompanyName__. All rights reserved. +// + +#import "MyDocument.h" +#import "MyAppDelegate.h" + +@implementation MyDocument + +- (id)init +{ + [super init]; + if (self) { + + // Add your subclass-specific initialization here. + // If an error occurs here, send a [self dealloc] message and return nil. + script = @"<no script>.py"; + filetype = @"Python Script"; + } + return self; +} + +- (NSString *)windowNibName +{ + // Override returning the nib file name of the document + // If you need to use a subclass of NSWindowController or if your document supports multiple NSWindowControllers, you should remove this method and override -makeWindowControllers instead. + return @"MyDocument"; +} + +- (void)close +{ + NSApplication *app = [NSApplication sharedApplication]; + [super close]; + if ([[app delegate] shouldTerminate]) + [app terminate: self]; +} + +- (void)load_defaults +{ + settings = [FileSettings newSettingsForFileType: filetype]; +} + +- (void)update_display +{ +// [[self window] setTitle: script]; + + [interpreter setStringValue: [settings interpreter]]; + [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]]; + + [commandline setStringValue: [settings commandLineForScript: script]]; +} + +- (void)update_settings +{ + [settings updateFromSource: self]; +} + +- (BOOL)run +{ + const char *cmdline; + int sts; + + if ([settings with_terminal]) { + NSLog(@"Terminal not implemented yet\n"); + return NO; + } + cmdline = [[settings commandLineForScript: script] cString]; + sts = system(cmdline); + if (sts) { + NSLog(@"Exit status: %d\n", sts); + return NO; + } + return YES; +} + +- (void)windowControllerDidLoadNib:(NSWindowController *) aController +{ + [super windowControllerDidLoadNib:aController]; + // Add any code here that need to be executed once the windowController has loaded the document's window. + [self load_defaults]; + [self update_display]; +} + +- (NSData *)dataRepresentationOfType:(NSString *)aType +{ + // Insert code here to write your document from the given data. You can also choose to override -fileWrapperRepresentationOfType: or -writeToFile:ofType: instead. + return nil; +} + +- (BOOL)readFromFile:(NSString *)fileName ofType:(NSString *)type; +{ + // Insert code here to read your document from the given data. You can also choose to override -loadFileWrapperRepresentation:ofType: or -readFromFile:ofType: instead. + BOOL show_ui; + + // ask the app delegate whether we should show the UI or not. + show_ui = [[[NSApplication sharedApplication] delegate] shouldShowUI]; + script = [fileName retain]; + filetype = [type retain]; + settings = [FileSettings newSettingsForFileType: filetype]; + if (show_ui) { + [self update_display]; + return YES; + } else { + [self run]; + [self close]; + return NO; + } +} + +- (IBAction)do_run:(id)sender +{ + [self update_settings]; + [self update_display]; + if ([self run]) + [self close]; +} + +- (IBAction)do_cancel:(id)sender +{ + [self close]; +} + + +- (IBAction)do_reset:(id)sender +{ + [self load_defaults]; + [self update_display]; +} + +- (IBAction)do_apply:(id)sender +{ + [self update_settings]; + [self update_display]; +} + +// FileSettingsSource protocol +- (NSString *) interpreter { return [interpreter stringValue];}; +- (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];}; + +// Delegates +- (void)controlTextDidChange:(NSNotification *)aNotification +{ + [self update_settings]; + [self update_display]; +}; + +@end diff --git a/Mac/OSX/PythonLauncher/PreferenceWindow.nib/classes.nib b/Mac/OSX/PythonLauncher/PreferenceWindow.nib/classes.nib new file mode 100644 index 0000000..2a07ee1 --- /dev/null +++ b/Mac/OSX/PythonLauncher/PreferenceWindow.nib/classes.nib @@ -0,0 +1,25 @@ +{ + IBClasses = ( + {CLASS = FirstResponder; LANGUAGE = ObjC; SUPERCLASS = NSObject; }, + { + ACTIONS = {do_apply = id; do_filetype = id; do_reset = id; }; + CLASS = PreferencesWindowController; + LANGUAGE = ObjC; + OUTLETS = { + commandline = NSTextField; + debug = NSButton; + filetype = NSPopUpButton; + inspect = NSButton; + interpreter = NSTextField; + nosite = NSButton; + optimize = NSButton; + others = NSTextField; + tabs = NSButton; + verbose = NSButton; + with_terminal = NSButton; + }; + SUPERCLASS = NSWindowController; + } + ); + IBVersion = 1; +}
\ No newline at end of file diff --git a/Mac/OSX/PythonLauncher/PreferenceWindow.nib/info.nib b/Mac/OSX/PythonLauncher/PreferenceWindow.nib/info.nib new file mode 100644 index 0000000..952d977 --- /dev/null +++ b/Mac/OSX/PythonLauncher/PreferenceWindow.nib/info.nib @@ -0,0 +1,16 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE plist SYSTEM "file://localhost/System/Library/DTDs/PropertyList.dtd"> +<plist version="0.9"> +<dict> + <key>IBDocumentLocation</key> + <string>237 -80 356 240 0 0 1280 938 </string> + <key>IBFramework Version</key> + <string>263.2</string> + <key>IBOpenObjects</key> + <array> + <integer>5</integer> + </array> + <key>IBSystem Version</key> + <string>5S66</string> +</dict> +</plist> diff --git a/Mac/OSX/PythonLauncher/PreferenceWindow.nib/objects.nib b/Mac/OSX/PythonLauncher/PreferenceWindow.nib/objects.nib Binary files differnew file mode 100644 index 0000000..8c3102d --- /dev/null +++ b/Mac/OSX/PythonLauncher/PreferenceWindow.nib/objects.nib diff --git a/Mac/OSX/PythonLauncher/PreferencesWindowController.h b/Mac/OSX/PythonLauncher/PreferencesWindowController.h new file mode 100644 index 0000000..a2a4c74 --- /dev/null +++ b/Mac/OSX/PythonLauncher/PreferencesWindowController.h @@ -0,0 +1,32 @@ +/* PreferencesWindowController */ + +#import <Cocoa/Cocoa.h> + +#import "FileSettings.h" + +@interface PreferencesWindowController : NSWindowController <FileSettingsSource> +{ + IBOutlet NSPopUpButton *filetype; + IBOutlet NSTextField *interpreter; + IBOutlet NSButton *debug; + IBOutlet NSButton *verbose; + IBOutlet NSButton *inspect; + IBOutlet NSButton *optimize; + IBOutlet NSButton *nosite; + IBOutlet NSButton *tabs; + IBOutlet NSTextField *others; + IBOutlet NSButton *with_terminal; + IBOutlet NSTextField *commandline; + + FileSettings *settings; +} + ++ getPreferencesWindow; + +- (IBAction)do_reset:(id)sender; +- (IBAction)do_apply:(id)sender; +- (IBAction)do_filetype:(id)sender; + +- (void)controlTextDidChange:(NSNotification *)aNotification; + +@end diff --git a/Mac/OSX/PythonLauncher/PreferencesWindowController.m b/Mac/OSX/PythonLauncher/PreferencesWindowController.m new file mode 100644 index 0000000..8842162 --- /dev/null +++ b/Mac/OSX/PythonLauncher/PreferencesWindowController.m @@ -0,0 +1,94 @@ +#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]; + + [interpreter setStringValue: [settings interpreter]]; + [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]]; + + [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 +{ + [self load_defaults]; + [self update_display]; +} + +- (IBAction)do_apply:(id)sender +{ + [self update_settings]; + [self update_display]; +} + +// FileSettingsSource protocol +- (NSString *) interpreter { return [interpreter stringValue];}; +- (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];}; + +// Delegates +- (void)controlTextDidChange:(NSNotification *)aNotification +{ + [self update_settings]; + [self update_display]; +}; + + +@end diff --git a/Mac/OSX/PythonLauncher/PythonCompiled.icns b/Mac/OSX/PythonLauncher/PythonCompiled.icns Binary files differnew file mode 100644 index 0000000..afead3e --- /dev/null +++ b/Mac/OSX/PythonLauncher/PythonCompiled.icns diff --git a/Mac/OSX/PythonLauncher/PythonInterpreter.icns b/Mac/OSX/PythonLauncher/PythonInterpreter.icns Binary files differnew file mode 100644 index 0000000..d5dd12f --- /dev/null +++ b/Mac/OSX/PythonLauncher/PythonInterpreter.icns diff --git a/Mac/OSX/PythonLauncher/PythonLauncher.pbproj/project.pbxproj b/Mac/OSX/PythonLauncher/PythonLauncher.pbproj/project.pbxproj new file mode 100755 index 0000000..849aeb3 --- /dev/null +++ b/Mac/OSX/PythonLauncher/PythonLauncher.pbproj/project.pbxproj @@ -0,0 +1,612 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 38; + objects = { + 080E96D9FE201CDB7F000001 = { + fileRef = 2A37F4B9FDCFA73011CA2CEA; + isa = PBXBuildFile; + settings = { + }; + }; + 080E96DAFE201CDB7F000001 = { + fileRef = 2A37F4B6FDCFA73011CA2CEA; + isa = PBXBuildFile; + settings = { + }; + }; + 080E96DBFE201CDB7F000001 = { + fileRef = 2A37F4B4FDCFA73011CA2CEA; + isa = PBXBuildFile; + settings = { + }; + }; + 089C165FFE840EACC02AAC07 = { + children = ( + 089C1660FE840EACC02AAC07, + ); + isa = PBXVariantGroup; + name = InfoPlist.strings; + refType = 4; + }; + 089C1660FE840EACC02AAC07 = { + fileEncoding = 10; + isa = PBXFileReference; + name = English; + path = English.lproj/InfoPlist.strings; + refType = 4; + }; + 089C1661FE840EACC02AAC07 = { + fileRef = 089C165FFE840EACC02AAC07; + isa = PBXBuildFile; + settings = { + }; + }; +//080 +//081 +//082 +//083 +//084 +//100 +//101 +//102 +//103 +//104 + 1058C7A6FEA54F5311CA2CBB = { + children = ( + 1058C7A7FEA54F5311CA2CBB, + ); + isa = PBXGroup; + name = "Linked Frameworks"; + refType = 4; + }; + 1058C7A7FEA54F5311CA2CBB = { + isa = PBXFrameworkReference; + name = Cocoa.framework; + path = /System/Library/Frameworks/Cocoa.framework; + refType = 0; + }; + 1058C7A8FEA54F5311CA2CBB = { + children = ( + 2A37F4C5FDCFA73011CA2CEA, + 2A37F4C4FDCFA73011CA2CEA, + ); + isa = PBXGroup; + name = "Other Frameworks"; + refType = 4; + }; + 1058C7A9FEA54F5311CA2CBB = { + fileRef = 1058C7A7FEA54F5311CA2CBB; + isa = PBXBuildFile; + settings = { + }; + }; +//100 +//101 +//102 +//103 +//104 +//170 +//171 +//172 +//173 +//174 + 1758732AFF379DA111CA2CBB = { + isa = PBXApplicationReference; + path = PythonLauncher.app; + refType = 3; + }; +//170 +//171 +//172 +//173 +//174 +//190 +//191 +//192 +//193 +//194 + 19C28FB0FE9D524F11CA2CBB = { + children = ( + 1758732AFF379DA111CA2CBB, + ); + isa = PBXGroup; + name = Products; + refType = 4; + }; +//190 +//191 +//192 +//193 +//194 +//2A0 +//2A1 +//2A2 +//2A3 +//2A4 + 2A37F4A9FDCFA73011CA2CEA = { + buildStyles = ( + 4A9504D0FFE6A4CB11CA0CBA, + 4A9504D1FFE6A4CB11CA0CBA, + ); + isa = PBXProject; + mainGroup = 2A37F4AAFDCFA73011CA2CEA; + projectDirPath = ""; + targets = ( + 2A37F4C6FDCFA73011CA2CEA, + ); + }; + 2A37F4AAFDCFA73011CA2CEA = { + children = ( + 2A37F4ABFDCFA73011CA2CEA, + 2A37F4AFFDCFA73011CA2CEA, + 2A37F4B8FDCFA73011CA2CEA, + 2A37F4C3FDCFA73011CA2CEA, + 19C28FB0FE9D524F11CA2CBB, + ); + isa = PBXGroup; + name = PythonLauncher; + path = ""; + refType = 4; + }; + 2A37F4ABFDCFA73011CA2CEA = { + children = ( + 2A37F4AEFDCFA73011CA2CEA, + 2A37F4ACFDCFA73011CA2CEA, + F52A90CD02EB5C6A01000102, + F52A90CE02EB5C6A01000102, + F5A4C14002F2055C01000102, + F5A4C14102F2055C01000102, + F5A4C14402F2070D01000102, + F5A4C14502F2070D01000102, + ); + isa = PBXGroup; + name = Classes; + path = ""; + refType = 4; + }; + 2A37F4ACFDCFA73011CA2CEA = { + isa = PBXFileReference; + path = MyDocument.m; + refType = 4; + }; + 2A37F4AEFDCFA73011CA2CEA = { + isa = PBXFileReference; + path = MyDocument.h; + refType = 4; + }; + 2A37F4AFFDCFA73011CA2CEA = { + children = ( + 2A37F4B0FDCFA73011CA2CEA, + ); + isa = PBXGroup; + name = "Other Sources"; + path = ""; + refType = 4; + }; + 2A37F4B0FDCFA73011CA2CEA = { + isa = PBXFileReference; + path = main.m; + refType = 4; + }; + 2A37F4B4FDCFA73011CA2CEA = { + children = ( + 2A37F4B5FDCFA73011CA2CEA, + ); + isa = PBXVariantGroup; + name = MyDocument.nib; + path = ""; + refType = 4; + }; + 2A37F4B5FDCFA73011CA2CEA = { + isa = PBXFileReference; + name = English; + path = English.lproj/MyDocument.nib; + refType = 4; + }; + 2A37F4B6FDCFA73011CA2CEA = { + children = ( + 2A37F4B7FDCFA73011CA2CEA, + ); + isa = PBXVariantGroup; + name = MainMenu.nib; + path = ""; + refType = 4; + }; + 2A37F4B7FDCFA73011CA2CEA = { + isa = PBXFileReference; + name = English; + path = English.lproj/MainMenu.nib; + refType = 4; + }; + 2A37F4B8FDCFA73011CA2CEA = { + children = ( + F58D4A3A02F1F94B01000102, + F58D4A3B02F1F94B01000102, + F58D4A3C02F1F94B01000102, + 2A37F4B9FDCFA73011CA2CEA, + 2A37F4B6FDCFA73011CA2CEA, + 2A37F4B4FDCFA73011CA2CEA, + F5A4C13E02F203F601000102, + 089C165FFE840EACC02AAC07, + ); + isa = PBXGroup; + name = Resources; + path = ""; + refType = 4; + }; + 2A37F4B9FDCFA73011CA2CEA = { + children = ( + 2A37F4BAFDCFA73011CA2CEA, + ); + isa = PBXVariantGroup; + name = Credits.rtf; + path = ""; + refType = 4; + }; + 2A37F4BAFDCFA73011CA2CEA = { + isa = PBXFileReference; + name = English; + path = English.lproj/Credits.rtf; + refType = 4; + }; + 2A37F4C3FDCFA73011CA2CEA = { + children = ( + 1058C7A6FEA54F5311CA2CBB, + 1058C7A8FEA54F5311CA2CBB, + ); + isa = PBXGroup; + name = Frameworks; + path = ""; + refType = 4; + }; + 2A37F4C4FDCFA73011CA2CEA = { + isa = PBXFrameworkReference; + name = AppKit.framework; + path = /System/Library/Frameworks/AppKit.framework; + refType = 0; + }; + 2A37F4C5FDCFA73011CA2CEA = { + isa = PBXFrameworkReference; + name = Foundation.framework; + path = /System/Library/Frameworks/Foundation.framework; + refType = 0; + }; + 2A37F4C6FDCFA73011CA2CEA = { + buildPhases = ( + 2A37F4C7FDCFA73011CA2CEA, + 2A37F4C9FDCFA73011CA2CEA, + 2A37F4CEFDCFA73011CA2CEA, + 2A37F4D1FDCFA73011CA2CEA, + ); + buildSettings = { + FRAMEWORK_SEARCH_PATHS = ""; + HEADER_SEARCH_PATHS = ""; + INSTALL_PATH = "$(HOME)/Applications"; + LIBRARY_SEARCH_PATHS = ""; + OTHER_CFLAGS = ""; + OTHER_LDFLAGS = ""; + PRODUCT_NAME = PythonLauncher; + SECTORDER_FLAGS = ""; + WARNING_CFLAGS = "-Wmost -Wno-four-char-constants -Wno-unknown-pragmas"; + WRAPPER_EXTENSION = app; + }; + dependencies = ( + ); + isa = PBXApplicationTarget; + name = PythonLauncher; + productInstallPath = "$(HOME)/Applications"; + productName = PythonLauncher; + productReference = 1758732AFF379DA111CA2CBB; + productSettingsXML = "<?xml version=\"1.0\" encoding=\"UTF-8\"?> +<!DOCTYPE plist SYSTEM \"file://localhost/System/Library/DTDs/PropertyList.dtd\"> +<plist version=\"0.9\"> +<dict> + <key>CFBundleDevelopmentRegion</key> + <string>English</string> + <key>CFBundleDocumentTypes</key> + <array> + <dict> + <key>CFBundleTypeExtensions</key> + <array> + <string>????</string> + </array> + <key>CFBundleTypeIconFile</key> + <string></string> + <key>CFBundleTypeName</key> + <string>DocumentType</string> + <key>CFBundleTypeOSTypes</key> + <array> + <string>????</string> + </array> + <key>CFBundleTypeRole</key> + <string>Editor</string> + <key>NSDocumentClass</key> + <string>MyDocument</string> + </dict> + <dict> + <key>CFBundleTypeExtensions</key> + <array> + <string>py</string> + </array> + <key>CFBundleTypeIconFile</key> + <string>PythonSource.icns</string> + <key>CFBundleTypeName</key> + <string>Python Script</string> + <key>CFBundleTypeRole</key> + <string>Viewer</string> + <key>NSDocumentClass</key> + <string>MyDocument</string> + </dict> + <dict> + <key>CFBundleTypeExtensions</key> + <array> + <string>pyw</string> + </array> + <key>CFBundleTypeName</key> + <string>Python GUI Script</string> + <key>CFBundleTypeRole</key> + <string>Viewer</string> + <key>NSDocumentClass</key> + <string>MyDocument</string> + </dict> + <dict> + <key>CFBundleTypeExtensions</key> + <array> + <string>pyc</string> + </array> + <key>CFBundleTypeIconFile</key> + <string>PythonCompiled.icns</string> + <key>CFBundleTypeName</key> + <string>Python Bytecode Document</string> + <key>CFBundleTypeRole</key> + <string>Viewer</string> + <key>NSDocumentClass</key> + <string>MyDocument</string> + </dict> + </array> + <key>CFBundleExecutable</key> + <string>PythonLauncher</string> + <key>CFBundleGetInfoString</key> + <string>Python Launcher</string> + <key>CFBundleIconFile</key> + <string>PythonInterpreter.icns</string> + <key>CFBundleIdentifier</key> + <string>org.python.PythonLauncher</string> + <key>CFBundleInfoDictionaryVersion</key> + <string>6.0</string> + <key>CFBundleName</key> + <string>Python Launcher</string> + <key>CFBundlePackageType</key> + <string>APPL</string> + <key>CFBundleSignature</key> + <string>PytL</string> + <key>CFBundleVersion</key> + <string>2.3a0</string> + <key>NSMainNibFile</key> + <string>MainMenu</string> + <key>NSPrincipalClass</key> + <string>NSApplication</string> +</dict> +</plist> +"; + shouldUseHeadermap = 1; + }; + 2A37F4C7FDCFA73011CA2CEA = { + buildActionMask = 2147483647; + files = ( + 2A37F4C8FDCFA73011CA2CEA, + F52A90D002EB5C6A01000102, + F5A4C14202F2055D01000102, + F5A4C14702F2070D01000102, + ); + isa = PBXHeadersBuildPhase; + }; + 2A37F4C8FDCFA73011CA2CEA = { + fileRef = 2A37F4AEFDCFA73011CA2CEA; + isa = PBXBuildFile; + settings = { + }; + }; + 2A37F4C9FDCFA73011CA2CEA = { + buildActionMask = 2147483647; + files = ( + 080E96D9FE201CDB7F000001, + 080E96DAFE201CDB7F000001, + 080E96DBFE201CDB7F000001, + 089C1661FE840EACC02AAC07, + F58D4A3D02F1F94B01000102, + F58D4A3E02F1F94B01000102, + F58D4A3F02F1F94B01000102, + F5A4C13F02F203F701000102, + ); + isa = PBXResourcesBuildPhase; + }; + 2A37F4CEFDCFA73011CA2CEA = { + buildActionMask = 2147483647; + files = ( + 2A37F4CFFDCFA73011CA2CEA, + 2A37F4D0FDCFA73011CA2CEA, + F52A90CF02EB5C6A01000102, + F5A4C14302F2055D01000102, + F5A4C14602F2070D01000102, + ); + isa = PBXSourcesBuildPhase; + }; + 2A37F4CFFDCFA73011CA2CEA = { + fileRef = 2A37F4ACFDCFA73011CA2CEA; + isa = PBXBuildFile; + settings = { + ATTRIBUTES = ( + ); + }; + }; + 2A37F4D0FDCFA73011CA2CEA = { + fileRef = 2A37F4B0FDCFA73011CA2CEA; + isa = PBXBuildFile; + settings = { + ATTRIBUTES = ( + ); + }; + }; + 2A37F4D1FDCFA73011CA2CEA = { + buildActionMask = 2147483647; + files = ( + 1058C7A9FEA54F5311CA2CBB, + ); + isa = PBXFrameworksBuildPhase; + }; +//2A0 +//2A1 +//2A2 +//2A3 +//2A4 +//4A0 +//4A1 +//4A2 +//4A3 +//4A4 + 4A9504D0FFE6A4CB11CA0CBA = { + buildRules = ( + ); + buildSettings = { + COPY_PHASE_STRIP = NO; + OPTIMIZATION_CFLAGS = "-O0"; + }; + isa = PBXBuildStyle; + name = Development; + }; + 4A9504D1FFE6A4CB11CA0CBA = { + buildRules = ( + ); + buildSettings = { + COPY_PHASE_STRIP = YES; + }; + isa = PBXBuildStyle; + name = Deployment; + }; +//4A0 +//4A1 +//4A2 +//4A3 +//4A4 +//F50 +//F51 +//F52 +//F53 +//F54 + F52A90CD02EB5C6A01000102 = { + isa = PBXFileReference; + path = FileSettings.m; + refType = 4; + }; + F52A90CE02EB5C6A01000102 = { + isa = PBXFileReference; + path = FileSettings.h; + refType = 4; + }; + F52A90CF02EB5C6A01000102 = { + fileRef = F52A90CD02EB5C6A01000102; + isa = PBXBuildFile; + settings = { + }; + }; + F52A90D002EB5C6A01000102 = { + fileRef = F52A90CE02EB5C6A01000102; + isa = PBXBuildFile; + settings = { + }; + }; + F58D4A3A02F1F94B01000102 = { + isa = PBXFileReference; + path = PythonCompiled.icns; + refType = 4; + }; + F58D4A3B02F1F94B01000102 = { + isa = PBXFileReference; + path = PythonInterpreter.icns; + refType = 4; + }; + F58D4A3C02F1F94B01000102 = { + isa = PBXFileReference; + path = PythonSource.icns; + refType = 4; + }; + F58D4A3D02F1F94B01000102 = { + fileRef = F58D4A3A02F1F94B01000102; + isa = PBXBuildFile; + settings = { + }; + }; + F58D4A3E02F1F94B01000102 = { + fileRef = F58D4A3B02F1F94B01000102; + isa = PBXBuildFile; + settings = { + }; + }; + F58D4A3F02F1F94B01000102 = { + fileRef = F58D4A3C02F1F94B01000102; + isa = PBXBuildFile; + settings = { + }; + }; + F5A4C13E02F203F601000102 = { + isa = PBXFileReference; + path = PreferenceWindow.nib; + refType = 4; + }; + F5A4C13F02F203F701000102 = { + fileRef = F5A4C13E02F203F601000102; + isa = PBXBuildFile; + settings = { + }; + }; + F5A4C14002F2055C01000102 = { + isa = PBXFileReference; + path = PreferencesWindowController.h; + refType = 4; + }; + F5A4C14102F2055C01000102 = { + isa = PBXFileReference; + path = PreferencesWindowController.m; + refType = 4; + }; + F5A4C14202F2055D01000102 = { + fileRef = F5A4C14002F2055C01000102; + isa = PBXBuildFile; + settings = { + }; + }; + F5A4C14302F2055D01000102 = { + fileRef = F5A4C14102F2055C01000102; + isa = PBXBuildFile; + settings = { + }; + }; + F5A4C14402F2070D01000102 = { + isa = PBXFileReference; + path = MyAppDelegate.m; + refType = 4; + }; + F5A4C14502F2070D01000102 = { + isa = PBXFileReference; + path = MyAppDelegate.h; + refType = 4; + }; + F5A4C14602F2070D01000102 = { + fileRef = F5A4C14402F2070D01000102; + isa = PBXBuildFile; + settings = { + }; + }; + F5A4C14702F2070D01000102 = { + fileRef = F5A4C14502F2070D01000102; + isa = PBXBuildFile; + settings = { + }; + }; + }; + rootObject = 2A37F4A9FDCFA73011CA2CEA; +} diff --git a/Mac/OSX/PythonLauncher/PythonSource.icns b/Mac/OSX/PythonLauncher/PythonSource.icns Binary files differnew file mode 100644 index 0000000..4ac7a96 --- /dev/null +++ b/Mac/OSX/PythonLauncher/PythonSource.icns diff --git a/Mac/OSX/PythonLauncher/main.m b/Mac/OSX/PythonLauncher/main.m new file mode 100755 index 0000000..70323f2 --- /dev/null +++ b/Mac/OSX/PythonLauncher/main.m @@ -0,0 +1,14 @@ +// +// main.m +// PythonLauncher +// +// Created by Jack Jansen on Fri Jul 19 2002. +// Copyright (c) 2002 __MyCompanyName__. All rights reserved. +// + +#import <Cocoa/Cocoa.h> + +int main(int argc, const char *argv[]) +{ + return NSApplicationMain(argc, argv); +} |