Move Mac/OSX/PythonLauncher one level up
diff --git a/Mac/PythonLauncher/English.lproj/Credits.rtf b/Mac/PythonLauncher/English.lproj/Credits.rtf
new file mode 100644
index 0000000..930ca22
--- /dev/null
+++ b/Mac/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/PythonLauncher/English.lproj/MainMenu.nib/classes.nib b/Mac/PythonLauncher/English.lproj/MainMenu.nib/classes.nib
new file mode 100644
index 0000000..47b40ab
--- /dev/null
+++ b/Mac/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/PythonLauncher/English.lproj/MainMenu.nib/info.nib b/Mac/PythonLauncher/English.lproj/MainMenu.nib/info.nib
new file mode 100644
index 0000000..b96759a
--- /dev/null
+++ b/Mac/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/PythonLauncher/English.lproj/MainMenu.nib/objects.nib b/Mac/PythonLauncher/English.lproj/MainMenu.nib/objects.nib
new file mode 100644
index 0000000..532a5c8
--- /dev/null
+++ b/Mac/PythonLauncher/English.lproj/MainMenu.nib/objects.nib
Binary files differ
diff --git a/Mac/PythonLauncher/English.lproj/MyDocument.nib/classes.nib b/Mac/PythonLauncher/English.lproj/MyDocument.nib/classes.nib
new file mode 100644
index 0000000..bcdc0cd
--- /dev/null
+++ b/Mac/PythonLauncher/English.lproj/MyDocument.nib/classes.nib
@@ -0,0 +1,26 @@
+{
+ 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;
+ honourhashbang = NSButton;
+ inspect = NSButton;
+ interpreter = NSTextField;
+ nosite = NSButton;
+ optimize = NSButton;
+ others = NSTextField;
+ scriptargs = NSTextField;
+ tabs = NSButton;
+ verbose = NSButton;
+ "with_terminal" = NSButton;
+ };
+ SUPERCLASS = NSDocument;
+ }
+ );
+ IBVersion = 1;
+}
\ No newline at end of file
diff --git a/Mac/PythonLauncher/English.lproj/MyDocument.nib/info.nib b/Mac/PythonLauncher/English.lproj/MyDocument.nib/info.nib
new file mode 100644
index 0000000..e258c72
--- /dev/null
+++ b/Mac/PythonLauncher/English.lproj/MyDocument.nib/info.nib
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>IBDocumentLocation</key>
+ <string>398 60 356 240 0 0 1024 746 </string>
+ <key>IBFramework Version</key>
+ <string>291.0</string>
+ <key>IBOpenObjects</key>
+ <array>
+ <integer>5</integer>
+ </array>
+ <key>IBSystem Version</key>
+ <string>6L60</string>
+</dict>
+</plist>
diff --git a/Mac/PythonLauncher/English.lproj/MyDocument.nib/objects.nib b/Mac/PythonLauncher/English.lproj/MyDocument.nib/objects.nib
new file mode 100644
index 0000000..0473a31
--- /dev/null
+++ b/Mac/PythonLauncher/English.lproj/MyDocument.nib/objects.nib
Binary files differ
diff --git a/Mac/PythonLauncher/English.lproj/PreferenceWindow.nib/classes.nib b/Mac/PythonLauncher/English.lproj/PreferenceWindow.nib/classes.nib
new file mode 100644
index 0000000..467aa8b
--- /dev/null
+++ b/Mac/PythonLauncher/English.lproj/PreferenceWindow.nib/classes.nib
@@ -0,0 +1,26 @@
+{
+ 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;
+ honourhashbang = NSButton;
+ 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/PythonLauncher/English.lproj/PreferenceWindow.nib/info.nib b/Mac/PythonLauncher/English.lproj/PreferenceWindow.nib/info.nib
new file mode 100644
index 0000000..bc558f7
--- /dev/null
+++ b/Mac/PythonLauncher/English.lproj/PreferenceWindow.nib/info.nib
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>IBDocumentLocation</key>
+ <string>565 235 519 534 0 0 1280 1002 </string>
+ <key>IBFramework Version</key>
+ <string>364.0</string>
+ <key>IBOpenObjects</key>
+ <array>
+ <integer>5</integer>
+ </array>
+ <key>IBSystem Version</key>
+ <string>7H63</string>
+</dict>
+</plist>
diff --git a/Mac/PythonLauncher/English.lproj/PreferenceWindow.nib/objects.nib b/Mac/PythonLauncher/English.lproj/PreferenceWindow.nib/objects.nib
new file mode 100644
index 0000000..3dfed33
--- /dev/null
+++ b/Mac/PythonLauncher/English.lproj/PreferenceWindow.nib/objects.nib
Binary files differ
diff --git a/Mac/PythonLauncher/FileSettings.h b/Mac/PythonLauncher/FileSettings.h
new file mode 100755
index 0000000..d807bae
--- /dev/null
+++ b/Mac/PythonLauncher/FileSettings.h
@@ -0,0 +1,64 @@
+//
+// 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) honourhashbang;
+- (BOOL) debug;
+- (BOOL) verbose;
+- (BOOL) inspect;
+- (BOOL) optimize;
+- (BOOL) nosite;
+- (BOOL) tabs;
+- (NSString *) others;
+- (BOOL) with_terminal;
+- (NSString *) scriptargs;
+@end
+
+@interface FileSettings : NSObject <FileSettingsSource>
+{
+ NSString *interpreter; // The pathname of the interpreter to use
+ NSArray *interpreters; // List of known interpreters
+ BOOL honourhashbang; // #! line overrides interpreter
+ 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
+ NSString *scriptargs; // script arguments (not for preferences)
+ BOOL with_terminal; // Run in terminal window
+
+ FileSettings *origsource;
+ NSString *prefskey;
+}
+
++ (id)getDefaultsForFileType: (NSString *)filetype;
++ (id)getFactorySettingsForFileType: (NSString *)filetype;
++ (id)newSettingsForFileType: (NSString *)filetype;
+
+//- (id)init;
+- (id)initForFileType: (NSString *)filetype;
+- (id)initForFSDefaultFileType: (NSString *)filetype;
+- (id)initForDefaultFileType: (NSString *)filetype;
+//- (id)initWithFileSettings: (FileSettings *)source;
+
+- (void)updateFromSource: (id <FileSettingsSource>)source;
+- (NSString *)commandLineForScript: (NSString *)script;
+
+//- (void)applyFactorySettingsForFileType: (NSString *)filetype;
+//- (void)saveDefaults;
+//- (void)applyUserDefaults: (NSString *)filetype;
+- (void)applyValuesFromDict: (NSDictionary *)dict;
+- (void)reset;
+- (NSArray *) interpreters;
+
+@end
diff --git a/Mac/PythonLauncher/FileSettings.m b/Mac/PythonLauncher/FileSettings.m
new file mode 100755
index 0000000..fc3937b
--- /dev/null
+++ b/Mac/PythonLauncher/FileSettings.m
@@ -0,0 +1,298 @@
+//
+// 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)getFactorySettingsForFileType: (NSString *)filetype
+{
+ static FileSettings *fsdefault_py, *fsdefault_pyw, *fsdefault_pyc;
+ FileSettings **curdefault;
+
+ if ([filetype isEqualToString: @"Python Script"]) {
+ curdefault = &fsdefault_py;
+ } else if ([filetype isEqualToString: @"Python GUI Script"]) {
+ curdefault = &fsdefault_pyw;
+ } else if ([filetype isEqualToString: @"Python Bytecode Document"]) {
+ curdefault = &fsdefault_pyc;
+ } else {
+ NSLog(@"Funny File Type: %@\n", filetype);
+ curdefault = &fsdefault_py;
+ filetype = @"Python Script";
+ }
+ if (!*curdefault) {
+ *curdefault = [[FileSettings new] initForFSDefaultFileType: filetype];
+ }
+ return *curdefault;
+}
+
++ (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] initForDefaultFileType: filetype];
+ }
+ return *curdefault;
+}
+
++ (id)newSettingsForFileType: (NSString *)filetype
+{
+ FileSettings *cur;
+
+ cur = [FileSettings new];
+ [cur initForFileType: filetype];
+ return [cur retain];
+}
+
+- (id)initWithFileSettings: (FileSettings *)source
+{
+ self = [super init];
+ if (!self) return self;
+
+ interpreter = [source->interpreter retain];
+ honourhashbang = source->honourhashbang;
+ debug = source->debug;
+ verbose = source->verbose;
+ inspect = source->inspect;
+ optimize = source->optimize;
+ nosite = source->nosite;
+ tabs = source->tabs;
+ others = [source->others retain];
+ scriptargs = [source->scriptargs retain];
+ with_terminal = source->with_terminal;
+ prefskey = source->prefskey;
+ if (prefskey) [prefskey retain];
+
+ return self;
+}
+
+- (id)initForFileType: (NSString *)filetype
+{
+ FileSettings *defaults;
+
+ defaults = [FileSettings getDefaultsForFileType: filetype];
+ self = [self initWithFileSettings: defaults];
+ origsource = [defaults retain];
+ return self;
+}
+
+//- (id)init
+//{
+// self = [self initForFileType: @"Python Script"];
+// return self;
+//}
+
+- (id)initForFSDefaultFileType: (NSString *)filetype
+{
+ int i;
+ NSString *filename;
+ NSDictionary *dict;
+ static NSDictionary *factorySettings;
+
+ self = [super init];
+ if (!self) return self;
+
+ if (factorySettings == NULL) {
+ NSBundle *bdl = [NSBundle mainBundle];
+ NSString *path = [ bdl pathForResource: @"factorySettings"
+ ofType: @"plist"];
+ factorySettings = [[NSDictionary dictionaryWithContentsOfFile:
+ path] retain];
+ if (factorySettings == NULL) {
+ NSLog(@"Missing %@", path);
+ return NULL;
+ }
+ }
+ dict = [factorySettings objectForKey: filetype];
+ if (dict == NULL) {
+ NSLog(@"factorySettings.plist misses file type \"%@\"", filetype);
+ interpreter = [@"no default found" retain];
+ return NULL;
+ }
+ [self applyValuesFromDict: dict];
+ interpreters = [dict objectForKey: @"interpreter_list"];
+ interpreter = NULL;
+ for (i=0; i < [interpreters count]; i++) {
+ filename = [interpreters objectAtIndex: i];
+ filename = [filename stringByExpandingTildeInPath];
+ if ([[NSFileManager defaultManager] fileExistsAtPath: filename]) {
+ interpreter = [filename retain];
+ break;
+ }
+ }
+ if (interpreter == NULL)
+ interpreter = [@"no default found" retain];
+ origsource = NULL;
+ return self;
+}
+
+- (void)applyUserDefaults: (NSString *)filetype
+{
+ NSUserDefaults *defaults;
+ NSDictionary *dict;
+
+ defaults = [NSUserDefaults standardUserDefaults];
+ dict = [defaults dictionaryForKey: filetype];
+ if (!dict)
+ return;
+ [self applyValuesFromDict: dict];
+}
+
+- (id)initForDefaultFileType: (NSString *)filetype
+{
+ FileSettings *fsdefaults;
+
+ fsdefaults = [FileSettings getFactorySettingsForFileType: filetype];
+ self = [self initWithFileSettings: fsdefaults];
+ if (!self) return self;
+ interpreters = [fsdefaults->interpreters retain];
+ scriptargs = [@"" retain];
+ [self applyUserDefaults: filetype];
+ prefskey = [filetype retain];
+ return self;
+}
+
+- (void)reset
+{
+ if (origsource) {
+ [self updateFromSource: origsource];
+ } else {
+ FileSettings *fsdefaults;
+ fsdefaults = [FileSettings getFactorySettingsForFileType: prefskey];
+ [self updateFromSource: fsdefaults];
+ }
+}
+
+- (void)updateFromSource: (id <FileSettingsSource>)source
+{
+ interpreter = [[source interpreter] retain];
+ honourhashbang = [source honourhashbang];
+ debug = [source debug];
+ verbose = [source verbose];
+ inspect = [source inspect];
+ optimize = [source optimize];
+ nosite = [source nosite];
+ tabs = [source tabs];
+ others = [[source others] retain];
+ scriptargs = [[source scriptargs] retain];
+ with_terminal = [source with_terminal];
+ // And if this is a user defaults object we also save the
+ // values
+ if (!origsource) {
+ NSUserDefaults *defaults;
+ NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys:
+ interpreter, @"interpreter",
+ [NSNumber numberWithBool: honourhashbang], @"honourhashbang",
+ [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",
+ scriptargs, @"scriptargs",
+ [NSNumber numberWithBool: with_terminal], @"with_terminal",
+ nil];
+ defaults = [NSUserDefaults standardUserDefaults];
+ [defaults setObject: dict forKey: prefskey];
+ }
+}
+
+- (void)applyValuesFromDict: (NSDictionary *)dict
+{
+ id value;
+
+ value = [dict objectForKey: @"interpreter"];
+ if (value) interpreter = [value retain];
+ value = [dict objectForKey: @"honourhashbang"];
+ if (value) honourhashbang = [value boolValue];
+ 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: @"scriptargs"];
+ if (value) scriptargs = [value retain];
+ value = [dict objectForKey: @"with_terminal"];
+ if (value) with_terminal = [value boolValue];
+}
+
+- (NSString *)commandLineForScript: (NSString *)script
+{
+ NSString *cur_interp = NULL;
+ char hashbangbuf[1024];
+ FILE *fp;
+ char *p;
+
+ if (honourhashbang &&
+ (fp=fopen([script cString], "r")) &&
+ fgets(hashbangbuf, sizeof(hashbangbuf), fp) &&
+ strncmp(hashbangbuf, "#!", 2) == 0 &&
+ (p=strchr(hashbangbuf, '\n'))) {
+ *p = '\0';
+ p = hashbangbuf + 2;
+ while (*p == ' ') p++;
+ cur_interp = [NSString stringWithCString: p];
+ }
+ if (!cur_interp)
+ cur_interp = interpreter;
+
+ return [NSString stringWithFormat:
+ @"\"%@\"%s%s%s%s%s%s %@ \"%@\" %@ %s",
+ cur_interp,
+ debug?" -d":"",
+ verbose?" -v":"",
+ inspect?" -i":"",
+ optimize?" -O":"",
+ nosite?" -S":"",
+ tabs?" -t":"",
+ others,
+ script,
+ scriptargs,
+ with_terminal? "&& echo Exit status: $? && exit 1" : " &"];
+}
+
+- (NSArray *) interpreters { return interpreters;};
+
+// FileSettingsSource protocol
+- (NSString *) interpreter { return interpreter;};
+- (BOOL) honourhashbang { return honourhashbang; };
+- (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;};
+- (NSString *) scriptargs { return scriptargs;};
+- (BOOL) with_terminal { return with_terminal;};
+
+@end
diff --git a/Mac/PythonLauncher/Info.plist b/Mac/PythonLauncher/Info.plist
new file mode 100644
index 0000000..1dd795f
--- /dev/null
+++ b/Mac/PythonLauncher/Info.plist
@@ -0,0 +1,65 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>CFBundleDevelopmentRegion</key>
+ <string>English</string>
+ <key>CFBundleDocumentTypes</key>
+ <array>
+ <dict>
+ <key>CFBundleTypeExtensions</key>
+ <array>
+ <string>py</string>
+ <string>pyw</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>pyc</string>
+ <string>pyo</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>2.5, © 001-2006 Python Software Foundation</string>
+ <key>CFBundleIconFile</key>
+ <string>PythonLauncher.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>CFBundleShortVersionString</key>
+ <string>2.5</string>
+ <key>CFBundleSignature</key>
+ <string>PytL</string>
+ <key>CFBundleVersion</key>
+ <string>2.5</string>
+ <key>NSMainNibFile</key>
+ <string>MainMenu</string>
+ <key>NSPrincipalClass</key>
+ <string>NSApplication</string>
+</dict>
+</plist>
diff --git a/Mac/PythonLauncher/Makefile.in b/Mac/PythonLauncher/Makefile.in
new file mode 100644
index 0000000..19763a6
--- /dev/null
+++ b/Mac/PythonLauncher/Makefile.in
@@ -0,0 +1,78 @@
+CC=@CC@
+LD=@CC@
+BASECFLAGS=@BASECFLAGS@
+OPT=@OPT@
+CFLAGS=$(BASECFLAGS) $(OPT)
+LDFLAGS=@LDFLAGS@
+srcdir= @srcdir@
+VERSION= @VERSION@
+UNIVERSALSDK=@UNIVERSALSDK@
+builddir= ../..
+
+RUNSHARED= @RUNSHARED@
+BUILDEXE= @BUILDEXEEXT@
+BUILDPYTHON= $(builddir)/python$(BUILDEXE)
+
+# Deployment target selected during configure, to be checked
+# by distutils
+MACOSX_DEPLOYMENT_TARGET=@CONFIGURE_MACOSX_DEPLOYMENT_TARGET@
+@EXPORT_MACOSX_DEPLOYMENT_TARGET@export MACOSX_DEPLOYMENT_TARGET
+
+BUNDLEBULDER=$(srcdir)/../../Lib/plat-mac/bundlebuilder.py
+
+PYTHONAPPSDIR=/Applications/MacPython $(VERSION)
+OBJECTS=FileSettings.o MyAppDelegate.o MyDocument.o PreferencesWindowController.o doscript.o main.o
+
+all: Python\ Launcher.app
+
+install: Python\ Launcher.app
+ test -d "$(DESTDIR)$(PYTHONAPPSDIR)" || mkdir -p "$(DESTDIR)$(PYTHONAPPSDIR)"
+ -test -d "$(DESTDIR)$(PYTHONAPPSDIR)/Python Launcher.app" && rm -r "$(DESTDIR)$(PYTHONAPPSDIR)/Python Launcher.app"
+ cp -r "Python Launcher.app" "$(DESTDIR)$(PYTHONAPPSDIR)"
+ touch "$(DESTDIR)$(PYTHONAPPSDIR)/Python Launcher.app"
+
+clean:
+ rm -f *.o "Python Launcher"
+ rm -rf "Python Launcher.app"
+
+Python\ Launcher.app: \
+ Python\ Launcher $(srcdir)/../Icons/PythonLauncher.icns \
+ $(srcdir)/../Icons/PythonSource.icns \
+ $(srcdir)/../Icons/PythonCompiled.icns \
+ $(srcdir)/factorySettings.plist
+ rm -fr "Python Launcher.app"
+ $(RUNSHARED) $(BUILDPYTHON) $(BUNDLEBULDER) \
+ --builddir=. \
+ --name="Python Launcher" \
+ --executable="Python Launcher" \
+ --iconfile=$(srcdir)/../Icons/PythonLauncher.icns \
+ --bundle-id=org.python.PythonLauncher \
+ --resource=$(srcdir)/../Icons/PythonSource.icns \
+ --resource=$(srcdir)/../Icons/PythonCompiled.icns \
+ --resource=$(srcdir)/English.lproj \
+ --resource=$(srcdir)/factorySettings.plist \
+ --plist=$(srcdir)/Info.plist \
+ build
+ find "Python Launcher.app" -name '.svn' -print0 | xargs -0 rm -r
+
+
+FileSettings.o: $(srcdir)/FileSettings.m
+ $(CC) $(CFLAGS) -o $@ -c $(srcdir)/FileSettings.m
+
+MyAppDelegate.o: $(srcdir)/MyAppDelegate.m
+ $(CC) $(CFLAGS) -o $@ -c $(srcdir)/MyAppDelegate.m
+
+MyDocument.o: $(srcdir)/MyDocument.m
+ $(CC) $(CFLAGS) -o $@ -c $(srcdir)/MyDocument.m
+
+PreferencesWindowController.o: $(srcdir)/PreferencesWindowController.m
+ $(CC) $(CFLAGS) -o $@ -c $(srcdir)/PreferencesWindowController.m
+
+doscript.o: $(srcdir)/doscript.m
+ $(CC) $(CFLAGS) -o $@ -c $(srcdir)/doscript.m
+
+main.o: $(srcdir)/main.m
+ $(CC) $(CFLAGS) -o $@ -c $(srcdir)/main.m
+
+Python\ Launcher: $(OBJECTS)
+ $(CC) $(LDFLAGS) -o "Python Launcher" $(OBJECTS) -framework AppKit -framework Carbon
diff --git a/Mac/PythonLauncher/MyAppDelegate.h b/Mac/PythonLauncher/MyAppDelegate.h
new file mode 100644
index 0000000..097b541
--- /dev/null
+++ b/Mac/PythonLauncher/MyAppDelegate.h
@@ -0,0 +1,15 @@
+/* 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;
+- (void)testFileTypeBinding;
+@end
diff --git a/Mac/PythonLauncher/MyAppDelegate.m b/Mac/PythonLauncher/MyAppDelegate.m
new file mode 100644
index 0000000..a5ba751
--- /dev/null
+++ b/Mac/PythonLauncher/MyAppDelegate.m
@@ -0,0 +1,96 @@
+#import "MyAppDelegate.h"
+#import "PreferencesWindowController.h"
+#import <Carbon/Carbon.h>
+#import <ApplicationServices/ApplicationServices.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
+{
+ // Test that the file mappings are correct
+ [self testFileTypeBinding];
+ // 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
+ // should terminate immedeately after starting the script.
+ if (!initial_action_done)
+ should_terminate = YES;
+ initial_action_done = YES;
+ if( GetCurrentKeyModifiers() & optionKey )
+ return YES;
+ return NO;
+}
+
+- (BOOL)shouldTerminate
+{
+ return should_terminate;
+}
+
+- (BOOL)applicationShouldOpenUntitledFile:(NSApplication *)sender
+{
+ return NO;
+}
+
+- (void)testFileTypeBinding
+{
+ NSURL *ourUrl;
+ OSStatus err;
+ FSRef appRef;
+ NSURL *appUrl;
+ static NSString *extensions[] = { @"py", @"pyw", @"pyc", NULL};
+ NSString **ext_p;
+ int i;
+
+ if ([[NSUserDefaults standardUserDefaults] boolForKey: @"SkipFileBindingTest"])
+ return;
+ ourUrl = [NSURL fileURLWithPath: [[NSBundle mainBundle] bundlePath]];
+ for( ext_p = extensions; *ext_p; ext_p++ ) {
+ err = LSGetApplicationForInfo(
+ kLSUnknownType,
+ kLSUnknownCreator,
+ (CFStringRef)*ext_p,
+ kLSRolesViewer,
+ &appRef,
+ (CFURLRef *)&appUrl);
+ if (err || ![appUrl isEqual: ourUrl] ) {
+ i = NSRunAlertPanel(@"File type binding",
+ @"PythonLauncher is not the default application for all " \
+ @"Python script types. You should fix this with the " \
+ @"Finder's \"Get Info\" command.\n\n" \
+ @"See \"Changing the application that opens a file\" in " \
+ @"Mac Help for details.",
+ @"OK",
+ @"Don't show this warning again",
+ NULL);
+ if ( i == 0 ) { // Don't show again
+ [[NSUserDefaults standardUserDefaults]
+ setObject:@"YES" forKey:@"SkipFileBindingTest"];
+ }
+ return;
+ }
+ }
+}
+
+@end
diff --git a/Mac/PythonLauncher/MyDocument.h b/Mac/PythonLauncher/MyDocument.h
new file mode 100755
index 0000000..00c1bae
--- /dev/null
+++ b/Mac/PythonLauncher/MyDocument.h
@@ -0,0 +1,41 @@
+//
+// 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 *honourhashbang;
+ 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 *scriptargs;
+ 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/PythonLauncher/MyDocument.m b/Mac/PythonLauncher/MyDocument.m
new file mode 100755
index 0000000..5acc2dc
--- /dev/null
+++ b/Mac/PythonLauncher/MyDocument.m
@@ -0,0 +1,175 @@
+//
+// 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"
+#import "doscript.h"
+
+@implementation MyDocument
+
+- (id)init
+{
+ self = [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" retain];
+ filetype = [@"Python Script" retain];
+ settings = NULL;
+ }
+ 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
+{
+// if (settings) [settings release];
+ settings = [FileSettings newSettingsForFileType: filetype];
+}
+
+- (void)update_display
+{
+// [[self window] setTitle: script];
+
+ [interpreter setStringValue: [settings interpreter]];
+ [honourhashbang setState: [settings honourhashbang]];
+ [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]];
+ [scriptargs setStringValue: [settings scriptargs]];
+ [with_terminal setState: [settings with_terminal]];
+
+ [commandline setStringValue: [settings commandLineForScript: script]];
+}
+
+- (void)update_settings
+{
+ [settings updateFromSource: self];
+}
+
+- (BOOL)run
+{
+ const char *cmdline;
+ int sts;
+
+ cmdline = [[settings commandLineForScript: script] cString];
+ if ([settings with_terminal]) {
+ sts = doscript(cmdline);
+ } else {
+ 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 release];
+ script = [fileName retain];
+ [filetype release];
+ filetype = [type retain];
+// if (settings) [settings release];
+ 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
+{
+ [settings reset];
+ [self update_display];
+}
+
+- (IBAction)do_apply:(id)sender
+{
+ [self update_settings];
+ [self update_display];
+}
+
+// FileSettingsSource protocol
+- (NSString *) interpreter { return [interpreter stringValue];};
+- (BOOL) honourhashbang { return [honourhashbang state];};
+- (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];};
+- (NSString *) scriptargs { return [scriptargs stringValue];};
+- (BOOL) with_terminal { return [with_terminal state];};
+
+// Delegates
+- (void)controlTextDidChange:(NSNotification *)aNotification
+{
+ [self update_settings];
+ [self update_display];
+};
+
+@end
diff --git a/Mac/PythonLauncher/PreferencesWindowController.h b/Mac/PythonLauncher/PreferencesWindowController.h
new file mode 100644
index 0000000..6346996
--- /dev/null
+++ b/Mac/PythonLauncher/PreferencesWindowController.h
@@ -0,0 +1,38 @@
+/* PreferencesWindowController */
+
+#import <Cocoa/Cocoa.h>
+
+#import "FileSettings.h"
+
+@interface PreferencesWindowController : NSWindowController <FileSettingsSource>
+{
+ IBOutlet NSPopUpButton *filetype;
+ IBOutlet NSComboBox *interpreter;
+ IBOutlet NSButton *honourhashbang;
+ 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;
+
+- (unsigned int)comboBox:(NSComboBox *)aComboBox indexOfItemWithStringValue:(NSString *)aString;
+- (id)comboBox:(NSComboBox *)aComboBox objectValueForItemAtIndex:(int)index;
+- (int)numberOfItemsInComboBox:(NSComboBox *)aComboBox;
+
+
+@end
diff --git a/Mac/PythonLauncher/PreferencesWindowController.m b/Mac/PythonLauncher/PreferencesWindowController.m
new file mode 100644
index 0000000..311c375
--- /dev/null
+++ b/Mac/PythonLauncher/PreferencesWindowController.m
@@ -0,0 +1,121 @@
+#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 reloadData];
+ [interpreter setStringValue: [settings interpreter]];
+ [honourhashbang setState: [settings honourhashbang]];
+ [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]];
+ // Not scriptargs, it isn't for preferences
+
+ [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
+{
+ [settings reset];
+ [self update_display];
+}
+
+- (IBAction)do_apply:(id)sender
+{
+ [self update_settings];
+ [self update_display];
+}
+
+// FileSettingsSource protocol
+- (NSString *) interpreter { return [interpreter stringValue];};
+- (BOOL) honourhashbang { return [honourhashbang state]; };
+- (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];};
+- (NSString *) scriptargs { return @"";};
+
+// Delegates
+- (void)controlTextDidChange:(NSNotification *)aNotification
+{
+ [self update_settings];
+ [self update_display];
+};
+
+// NSComboBoxDataSource protocol
+- (unsigned int)comboBox:(NSComboBox *)aComboBox indexOfItemWithStringValue:(NSString *)aString
+{
+ NSArray *interp_list = [settings interpreters];
+ unsigned int rv = [interp_list indexOfObjectIdenticalTo: aString];
+ return rv;
+}
+
+- (id)comboBox:(NSComboBox *)aComboBox objectValueForItemAtIndex:(int)index
+{
+ NSArray *interp_list = [settings interpreters];
+ id rv = [interp_list objectAtIndex: index];
+ return rv;
+}
+
+- (int)numberOfItemsInComboBox:(NSComboBox *)aComboBox
+{
+ NSArray *interp_list = [settings interpreters];
+ int rv = [interp_list count];
+ return rv;
+}
+
+
+@end
diff --git a/Mac/PythonLauncher/doscript.h b/Mac/PythonLauncher/doscript.h
new file mode 100644
index 0000000..eef0b56
--- /dev/null
+++ b/Mac/PythonLauncher/doscript.h
@@ -0,0 +1,12 @@
+/*
+ * doscript.h
+ * PythonLauncher
+ *
+ * Created by Jack Jansen on Wed Jul 31 2002.
+ * Copyright (c) 2002 __MyCompanyName__. All rights reserved.
+ *
+ */
+
+#include <Carbon/Carbon.h>
+
+extern int doscript(const char *command);
\ No newline at end of file
diff --git a/Mac/PythonLauncher/doscript.m b/Mac/PythonLauncher/doscript.m
new file mode 100644
index 0000000..3e4e223
--- /dev/null
+++ b/Mac/PythonLauncher/doscript.m
@@ -0,0 +1,118 @@
+/*
+ * doscript.c
+ * PythonLauncher
+ *
+ * Created by Jack Jansen on Wed Jul 31 2002.
+ * Copyright (c) 2002 __MyCompanyName__. All rights reserved.
+ *
+ */
+
+#import <Cocoa/Cocoa.h>
+#import <ApplicationServices/ApplicationServices.h>
+#import "doscript.h"
+
+/* I assume I could pick these up from somewhere, but where... */
+#define CREATOR 'trmx'
+
+#define ACTIVATE_CMD 'misc'
+#define ACTIVATE_SUITE 'actv'
+
+#define DOSCRIPT_CMD 'dosc'
+#define DOSCRIPT_SUITE 'core'
+#define WITHCOMMAND 'cmnd'
+
+/* ... and there's probably also a better way to do this... */
+#define START_TERMINAL "/Applications/Utilities/Terminal.app/Contents/MacOS/Terminal &"
+
+extern int
+doscript(const char *command)
+{
+ OSErr err;
+ AppleEvent theAEvent, theReply;
+ AEAddressDesc terminalAddress;
+ AEDesc commandDesc;
+ OSType terminalCreator = CREATOR;
+
+ /* set up locals */
+ AECreateDesc(typeNull, NULL, 0, &theAEvent);
+ AECreateDesc(typeNull, NULL, 0, &terminalAddress);
+ AECreateDesc(typeNull, NULL, 0, &theReply);
+ AECreateDesc(typeNull, NULL, 0, &commandDesc);
+
+ /* create the "activate" event for Terminal */
+ err = AECreateDesc(typeApplSignature, (Ptr) &terminalCreator,
+ sizeof(terminalCreator), &terminalAddress);
+ if (err != noErr) {
+ NSLog(@"doscript: AECreateDesc: error %d\n", err);
+ goto bail;
+ }
+ err = AECreateAppleEvent(ACTIVATE_SUITE, ACTIVATE_CMD,
+ &terminalAddress, kAutoGenerateReturnID,
+ kAnyTransactionID, &theAEvent);
+
+ if (err != noErr) {
+ NSLog(@"doscript: AECreateAppleEvent(activate): error %d\n", err);
+ goto bail;
+ }
+ /* send the event */
+ err = AESend(&theAEvent, &theReply, kAEWaitReply,
+ kAENormalPriority, kAEDefaultTimeout, NULL, NULL);
+ if ( err == -600 ) {
+ int count=10;
+ /* If it failed with "no such process" try to start Terminal */
+ err = system(START_TERMINAL);
+ if ( err ) {
+ NSLog(@"doscript: system(): %s\n", strerror(errno));
+ goto bail;
+ }
+ do {
+ sleep(1);
+ /* send the event again */
+ err = AESend(&theAEvent, &theReply, kAEWaitReply,
+ kAENormalPriority, kAEDefaultTimeout, NULL, NULL);
+ } while (err == -600 && --count > 0);
+ if ( err == -600 )
+ NSLog(@"doscript: Could not activate Terminal\n");
+ }
+ if (err != noErr) {
+ NSLog(@"doscript: AESend(activate): error %d\n", err);
+ goto bail;
+ }
+
+ /* create the "doscript with command" event for Terminal */
+ err = AECreateAppleEvent(DOSCRIPT_SUITE, DOSCRIPT_CMD,
+ &terminalAddress, kAutoGenerateReturnID,
+ kAnyTransactionID, &theAEvent);
+ if (err != noErr) {
+ NSLog(@"doscript: AECreateAppleEvent(doscript): error %d\n", err);
+ goto bail;
+ }
+
+ /* add the command to the apple event */
+ err = AECreateDesc(typeChar, command, strlen(command), &commandDesc);
+ if (err != noErr) {
+ NSLog(@"doscript: AECreateDesc(command): error %d\n", err);
+ goto bail;
+ }
+ err = AEPutParamDesc(&theAEvent, WITHCOMMAND, &commandDesc);
+ if (err != noErr) {
+ NSLog(@"doscript: AEPutParamDesc: error %d\n", err);
+ goto bail;
+ }
+
+ /* send the command event to Terminal.app */
+ err = AESend(&theAEvent, &theReply, kAEWaitReply,
+ kAENormalPriority, kAEDefaultTimeout, NULL, NULL);
+
+ if (err != noErr) {
+ NSLog(@"doscript: AESend(docommand): error %d\n", err);
+ goto bail;
+ }
+ /* clean up and leave */
+bail:
+ AEDisposeDesc(&commandDesc);
+ AEDisposeDesc(&theAEvent);
+ AEDisposeDesc(&terminalAddress);
+ AEDisposeDesc(&theReply);
+ return err;
+}
diff --git a/Mac/PythonLauncher/factorySettings.plist b/Mac/PythonLauncher/factorySettings.plist
new file mode 100644
index 0000000..1202421
--- /dev/null
+++ b/Mac/PythonLauncher/factorySettings.plist
@@ -0,0 +1,87 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>Python GUI Script</key>
+ <dict>
+ <key>debug</key>
+ <false/>
+ <key>inspect</key>
+ <false/>
+ <key>interpreter_list</key>
+ <array>
+ <string>/usr/local/bin/pythonw</string>
+ <string>/usr/bin/pythonw</string>
+ <string>/sw/bin/pythonw</string>
+ </array>
+ <key>honourhashbang</key>
+ <false/>
+ <key>nosite</key>
+ <false/>
+ <key>optimize</key>
+ <false/>
+ <key>others</key>
+ <string></string>
+ <key>verbose</key>
+ <false/>
+ <key>with_terminal</key>
+ <false/>
+ </dict>
+ <key>Python Script</key>
+ <dict>
+ <key>debug</key>
+ <false/>
+ <key>inspect</key>
+ <false/>
+ <key>interpreter_list</key>
+ <array>
+ <string>/usr/local/bin/pythonw</string>
+ <string>/usr/local/bin/python</string>
+ <string>/usr/bin/pythonw</string>
+ <string>/usr/bin/python</string>
+ <string>/sw/bin/pythonw</string>
+ <string>/sw/bin/python</string>
+ </array>
+ <key>honourhashbang</key>
+ <false/>
+ <key>nosite</key>
+ <false/>
+ <key>optimize</key>
+ <false/>
+ <key>others</key>
+ <string></string>
+ <key>verbose</key>
+ <false/>
+ <key>with_terminal</key>
+ <true/>
+ </dict>
+ <key>Python Bytecode Document</key>
+ <dict>
+ <key>debug</key>
+ <false/>
+ <key>inspect</key>
+ <false/>
+ <key>interpreter_list</key>
+ <array>
+ <string>/usr/local/bin/pythonw</string>
+ <string>/usr/local/bin/python</string>
+ <string>/usr/bin/pythonw</string>
+ <string>/usr/bin/python</string>
+ <string>/sw/bin/pythonw</string>
+ <string>/sw/bin/python</string>
+ </array>
+ <key>honourhashbang</key>
+ <false/>
+ <key>nosite</key>
+ <false/>
+ <key>optimize</key>
+ <false/>
+ <key>others</key>
+ <string></string>
+ <key>verbose</key>
+ <false/>
+ <key>with_terminal</key>
+ <true/>
+ </dict>
+</dict>
+</plist>
diff --git a/Mac/PythonLauncher/main.m b/Mac/PythonLauncher/main.m
new file mode 100755
index 0000000..6841433
--- /dev/null
+++ b/Mac/PythonLauncher/main.m
@@ -0,0 +1,17 @@
+//
+// main.m
+// PythonLauncher
+//
+// Created by Jack Jansen on Fri Jul 19 2002.
+// Copyright (c) 2002 __MyCompanyName__. All rights reserved.
+//
+
+#import <Cocoa/Cocoa.h>
+#include <unistd.h>
+
+int main(int argc, const char *argv[])
+{
+ char *home = getenv("HOME");
+ if (home) chdir(home);
+ return NSApplicationMain(argc, argv);
+}