From c629be8a1e77786e3a839ed4784c7b2b36c6344f Mon Sep 17 00:00:00 2001 From: Ronald Oussoren Date: Wed, 7 Jun 2006 18:58:01 +0000 Subject: [PATCH] Move Mac/OSX/PythonLauncher one level up --- Mac/PythonLauncher/English.lproj/Credits.rtf | 30 ++ .../English.lproj/MainMenu.nib/classes.nib | 12 + .../English.lproj/MainMenu.nib/info.nib | 21 ++ .../English.lproj/MainMenu.nib/objects.nib | Bin 0 -> 5016 bytes .../English.lproj/MyDocument.nib/classes.nib | 26 ++ .../English.lproj/MyDocument.nib/info.nib | 16 + .../English.lproj/MyDocument.nib/objects.nib | Bin 0 -> 4845 bytes .../PreferenceWindow.nib/classes.nib | 26 ++ .../PreferenceWindow.nib/info.nib | 16 + .../PreferenceWindow.nib/objects.nib | Bin 0 -> 5882 bytes Mac/PythonLauncher/FileSettings.h | 64 ++++ Mac/PythonLauncher/FileSettings.m | 298 ++++++++++++++++++ Mac/PythonLauncher/Info.plist | 65 ++++ Mac/PythonLauncher/Makefile.in | 78 +++++ Mac/PythonLauncher/MyAppDelegate.h | 15 + Mac/PythonLauncher/MyAppDelegate.m | 96 ++++++ Mac/PythonLauncher/MyDocument.h | 41 +++ Mac/PythonLauncher/MyDocument.m | 175 ++++++++++ .../PreferencesWindowController.h | 38 +++ .../PreferencesWindowController.m | 121 +++++++ Mac/PythonLauncher/doscript.h | 12 + Mac/PythonLauncher/doscript.m | 118 +++++++ Mac/PythonLauncher/factorySettings.plist | 87 +++++ Mac/PythonLauncher/main.m | 17 + 24 files changed, 1372 insertions(+) create mode 100644 Mac/PythonLauncher/English.lproj/Credits.rtf create mode 100644 Mac/PythonLauncher/English.lproj/MainMenu.nib/classes.nib create mode 100644 Mac/PythonLauncher/English.lproj/MainMenu.nib/info.nib create mode 100644 Mac/PythonLauncher/English.lproj/MainMenu.nib/objects.nib create mode 100644 Mac/PythonLauncher/English.lproj/MyDocument.nib/classes.nib create mode 100644 Mac/PythonLauncher/English.lproj/MyDocument.nib/info.nib create mode 100644 Mac/PythonLauncher/English.lproj/MyDocument.nib/objects.nib create mode 100644 Mac/PythonLauncher/English.lproj/PreferenceWindow.nib/classes.nib create mode 100644 Mac/PythonLauncher/English.lproj/PreferenceWindow.nib/info.nib create mode 100644 Mac/PythonLauncher/English.lproj/PreferenceWindow.nib/objects.nib create mode 100755 Mac/PythonLauncher/FileSettings.h create mode 100755 Mac/PythonLauncher/FileSettings.m create mode 100644 Mac/PythonLauncher/Info.plist create mode 100644 Mac/PythonLauncher/Makefile.in create mode 100644 Mac/PythonLauncher/MyAppDelegate.h create mode 100644 Mac/PythonLauncher/MyAppDelegate.m create mode 100755 Mac/PythonLauncher/MyDocument.h create mode 100755 Mac/PythonLauncher/MyDocument.m create mode 100644 Mac/PythonLauncher/PreferencesWindowController.h create mode 100644 Mac/PythonLauncher/PreferencesWindowController.m create mode 100644 Mac/PythonLauncher/doscript.h create mode 100644 Mac/PythonLauncher/doscript.m create mode 100644 Mac/PythonLauncher/factorySettings.plist create mode 100755 Mac/PythonLauncher/main.m diff --git a/Mac/PythonLauncher/English.lproj/Credits.rtf b/Mac/PythonLauncher/English.lproj/Credits.rtf new file mode 100644 index 000000000000..930ca221a128 --- /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 000000000000..47b40aba31c1 --- /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 000000000000..b96759af1c23 --- /dev/null +++ b/Mac/PythonLauncher/English.lproj/MainMenu.nib/info.nib @@ -0,0 +1,21 @@ + + + + + IBDocumentLocation + 99 33 356 240 0 0 800 578 + IBEditorPositions + + 29 + 82 396 318 44 0 0 800 578 + + IBFramework Version + 263.2 + IBOpenObjects + + 29 + + IBSystem Version + 5S66 + + 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 0000000000000000000000000000000000000000..532a5c828967455b622d4670969ba546ec4adf21 GIT binary patch literal 5016 zc-pO44Qv$06`nKLx!CxCnm|PjIwVRQSw$waKpa)IF?Dep|HPLl>W>sHcZ0ofw|m*! z#h5llL-w|W za$x_%hYv{-EicJ0u%9M$%LvnFMgehXzAL5-P{CR3y4NvC!@FaOvDAe8zeEodOsx zgvhwOiaYKJ+oRD>DQFEZTB`Xd z*I#>_>q5KeRrglVf^em!y@j1>l$PHB7lOgB6SS`a$2oi#9ZtXy>Y6EVdMC<6W;sU2HLy(&TX=uW!XuTP$G*5u zS9e79guJ!Bp~_2K7*h7Q;6!C`tpEqx6ZsH^DpP9u=^kpBkG|z;Db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M%OF!CV^-(%z)KhDS-++yS>{QP#5 zy~)UFuJ7ZS=lF&1@s*66Vo1b9h0AI$)`@DvcBfN@{U-M1hLBdZNIm?eR!tncj zM*hXqt9a8cewL9jlq4BB!9PY6e*c(}GdPSf@>d*w&dA?zc$<+)9NuN*@B9oSz+Y$N z7zz$C@((`5$OtElOz_)``~syvV&o5ed<(zvb-t95aej}H!@Q1>6wfj85x?2ZkGAsr z$mW}?`K9mkVMgBJrxeTinlWIPu{HawT%3kuRve; sRES^e<1L>>1Y_hl-?$>h$R{Z>g6Doo*VYa_tSg;{5~D-9_(#(J07Jd4@&Et; literal 0 Hc-jL100001 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 000000000000..bcdc0cdf0888 --- /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 000000000000..e258c7220a47 --- /dev/null +++ b/Mac/PythonLauncher/English.lproj/MyDocument.nib/info.nib @@ -0,0 +1,16 @@ + + + + + IBDocumentLocation + 398 60 356 240 0 0 1024 746 + IBFramework Version + 291.0 + IBOpenObjects + + 5 + + IBSystem Version + 6L60 + + 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 0000000000000000000000000000000000000000..0473a31a21f113e527bc0c4f1aa9dd0a26653a4a GIT binary patch literal 4845 zc-oCuYitzP6~5y)7`qq)4UoqKPwVY` zEO>Y3+;h)4_dCy9QmOYwXdtRDc<5-GM^>A!S>MP+MlRn}j#4JGz%}bZoG%GsQA{vG7 zI?Hr69D{Ri=ud7pOMiRlHSv5IA!IZBJ$^#oBQYWpi3Es1juQ>O6?mo~j|*0roJa<_ zK{8lk#p9r^j-bI;%wo~!Lu<%UHg_ejeybh0Lelu8X76pT! z9NB$+khAc;Z0H8Ct@YUO;91t21b8e!hpUTQ3G=H(0A+(q8C>l~Lhw5S;uXa24_Ev8 zKYCp6;PEv`Cf2oh{2RyU+c&sHg|#|pY7oS(PECy|fgGJ&u3fA2MT2gkC4WRaOtTb1 zNbTAErDKqJImuy&jJVGg3G?$r+B0;GK|bkOM@Y}QL^{Vv$D?i#q92c3z3Mp8F}S*& zY8`5n@=`dWYI@fEQFB!^DoN;KpF#e%si^P7+ozul563}VZAM&kSm>mFHKvKQ7y|dw zCCrF!Nf$#Fq<~dmThbt(gLU|wXWw6P?5S;{9kEV6B4|;n@oG$u#Bz)p`!>&%zZU8U z8{`K^!w)NKc)^KQ0RsFY<-=-#@@d{oq=NRF=Yr|3FokWU?5pRTN{rZu8VVd-Pa zcl7F11Z7$I6Hk#}Z;)G#{97x_-_#^Uu_AchSzK?BFAS~=P{3vUU97t0!JyA4iXxP{uXDhy zz#suo>kvgNU0g&GamPiO`eSeh*0k}2wDEbh$8%6$#T%}i;xjQN>xdc05nP|u=X){? zt6Y^82Uwqnf_(4|w;-=~!94*$%H$$^>j1GxgzHsVP_2AR$UmONlCnlY5viOtX136n zEmr(r1+uH5LL_($#Ka2HiI-H+EUC`xDj%RhAtvk5tfIL*MNW6~nx@yNu|&tOc~QC8 zA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Em@z&^(|+?U3){k;~R9gzz1Wp3{zB8cSCS~xwuR&7ncLr zW~xJ~0yoZ(5Dj$*N+xfy=&yE_3tFd_at{kK3ucRCqgmvWlJBwG8`&!_v)~DKXgfRe zE_>%7JNi1ivVmRr75jY?JN*uO>j1m=0(; z`V}_vbJqA8(^}cq8aDqbJ6XqG-_K6H#pa%8A2c%gBs;v19oWVe+SspsELFxX`dRxC zcK=0ocP~3~h)wQh^@rK-8d%3sMoQUl>e3)9cA r<8QF>ovisywr?v79A{%YlI=-?*Y35=4UMX(3db}^ziw6QvaJ6D$`kO> literal 0 Hc-jL100001 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 000000000000..467aa8b26121 --- /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 000000000000..bc558f7e8285 --- /dev/null +++ b/Mac/PythonLauncher/English.lproj/PreferenceWindow.nib/info.nib @@ -0,0 +1,16 @@ + + + + + IBDocumentLocation + 565 235 519 534 0 0 1280 1002 + IBFramework Version + 364.0 + IBOpenObjects + + 5 + + IBSystem Version + 7H63 + + 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 0000000000000000000000000000000000000000..3dfed33cbdb5b263001bd8bc5a1fd7ec268d704c GIT binary patch literal 5882 zc-oa%YitzP6~426;CEPXa4@C4rBMl_Bqgu5ZXRo!02W|K)&`|1CF9v^@5H+^%j_(+ zqdqdr>?l$bwcVPLmqhDY5voFp8--XEah+C?h)5Ha*0K=FRBe7mRe$wIsqzEio^$Vv zch`?3^<#GC%(>^D=XcKC>PB-c#bRmGU~jrMdM9(a~1<{sIUE%LE# z*Y!pPh2-*rr8|>0^`s!~7`H!qUf7EvAoj>zZlk zi3Bs8oMTJs7FR6l%9y6E5!7zSe!N**I*i8}m8T5aIl7}*;Jdj|Wh9QrE^mV;aaXVh9M+wcn(Ia}QKP9%e$cJb1 zQ-y2;A!ITKKNiVb(wml4+fE2x^Hcd8{@T^5qC|)U676t>h;EihSfSlwZ>D8>OqS#{ zGH=^Wft^Tsj6ZiOrYfGp++4it1ZS#h*6zGTvUQ+}U5$3-Y|gM3oOAnl;ZD2e>H8m2 zj@QC_P>$SMBnL@`C`2VOB9nc@fU5@g4Ax77&9e1$T_<{omN#8 zAF-sLACR)O*~lVnblZ~W{Af;05XXK4E;)O;aOZEn$hH@nr^S}A2&3Fk@`x3h9M21T zkOY1o2bY2p1omh+Y{r>^aZfw;tA(ok#k~Die#UMFhMpd-Y=;V*6BFShV`f~}=)V3Q z8dVH6WjZ!0nkDNA$^K+;f2D6w8M{=@p0lgeh?;!_f-plI2fYb3(#J;4y(&w@ zHouICTo)vAqa|Ik$cte}W4H!s{Hn;{+sf8q{yqBoYuRcEl8;0PIS(qeMVV;b>2P?KCZb%$@%}Ipc?&xYI0BwyOw8R zNB(*~_Xbukpv9HQVr~{pD5j80(3M90?vDc^ObMyWx4?Erc`^{1@&J4$0Y# z98%%GqeBJc;Ev|F$;E)JnWP5jUx&C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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 + +@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 +{ + 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 )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 000000000000..fc3937b3dcbd --- /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 )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 000000000000..1dd795f77660 --- /dev/null +++ b/Mac/PythonLauncher/Info.plist @@ -0,0 +1,65 @@ + + + + + CFBundleDevelopmentRegion + English + CFBundleDocumentTypes + + + CFBundleTypeExtensions + + py + pyw + + CFBundleTypeIconFile + PythonSource.icns + CFBundleTypeName + Python Script + CFBundleTypeRole + Viewer + NSDocumentClass + MyDocument + + + CFBundleTypeExtensions + + pyc + pyo + + CFBundleTypeIconFile + PythonCompiled.icns + CFBundleTypeName + Python Bytecode Document + CFBundleTypeRole + Viewer + NSDocumentClass + MyDocument + + + CFBundleExecutable + PythonLauncher + CFBundleGetInfoString + 2.5, © 001-2006 Python Software Foundation + CFBundleIconFile + PythonLauncher.icns + CFBundleIdentifier + org.python.PythonLauncher + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + Python Launcher + CFBundlePackageType + APPL + CFBundleShortVersionString + 2.5 + CFBundleSignature + PytL + CFBundleVersion + 2.5 + NSMainNibFile + MainMenu + NSPrincipalClass + NSApplication + + diff --git a/Mac/PythonLauncher/Makefile.in b/Mac/PythonLauncher/Makefile.in new file mode 100644 index 000000000000..19763a66ca77 --- /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 000000000000..097b54177c88 --- /dev/null +++ b/Mac/PythonLauncher/MyAppDelegate.h @@ -0,0 +1,15 @@ +/* MyAppDelegate */ + +#import + +@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 000000000000..a5ba7510784c --- /dev/null +++ b/Mac/PythonLauncher/MyAppDelegate.m @@ -0,0 +1,96 @@ +#import "MyAppDelegate.h" +#import "PreferencesWindowController.h" +#import +#import + +@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 000000000000..00c1bae54e24 --- /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 + +#import "FileSettings.h" + +@interface MyDocument : NSDocument +{ + 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 000000000000..5acc2dcc90c1 --- /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 = [@".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 000000000000..63469968c1e3 --- /dev/null +++ b/Mac/PythonLauncher/PreferencesWindowController.h @@ -0,0 +1,38 @@ +/* PreferencesWindowController */ + +#import + +#import "FileSettings.h" + +@interface PreferencesWindowController : NSWindowController +{ + 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 000000000000..311c37502bb2 --- /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: @""]]; +} + +- (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 000000000000..eef0b5641f67 --- /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 + +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 000000000000..3e4e22393c04 --- /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 +#import +#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 000000000000..120242135ce4 --- /dev/null +++ b/Mac/PythonLauncher/factorySettings.plist @@ -0,0 +1,87 @@ + + + + + Python GUI Script + + debug + + inspect + + interpreter_list + + /usr/local/bin/pythonw + /usr/bin/pythonw + /sw/bin/pythonw + + honourhashbang + + nosite + + optimize + + others + + verbose + + with_terminal + + + Python Script + + debug + + inspect + + interpreter_list + + /usr/local/bin/pythonw + /usr/local/bin/python + /usr/bin/pythonw + /usr/bin/python + /sw/bin/pythonw + /sw/bin/python + + honourhashbang + + nosite + + optimize + + others + + verbose + + with_terminal + + + Python Bytecode Document + + debug + + inspect + + interpreter_list + + /usr/local/bin/pythonw + /usr/local/bin/python + /usr/bin/pythonw + /usr/bin/python + /sw/bin/pythonw + /sw/bin/python + + honourhashbang + + nosite + + optimize + + others + + verbose + + with_terminal + + + + diff --git a/Mac/PythonLauncher/main.m b/Mac/PythonLauncher/main.m new file mode 100755 index 000000000000..6841433f429f --- /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 +#include + +int main(int argc, const char *argv[]) +{ + char *home = getenv("HOME"); + if (home) chdir(home); + return NSApplicationMain(argc, argv); +} -- 2.47.3