From dff7770b7f19b3cfdcbcbc4dc205f53ef6170c2d Mon Sep 17 00:00:00 2001 From: Jack Jansen Date: Wed, 5 Sep 2001 22:07:52 +0000 Subject: Changes to make these work under OSX as the main program for a fullblown drag and drop application. To my surprise it is starting to work already: Python actually executes a script dropped on it. To be done: - Make sure this still works in MacPython - Don't lose argv[0] in the process - Applet support --- Mac/Python/macmain.c | 113 +++++++++++++++++++++++++++++++++------------------ 1 file changed, 74 insertions(+), 39 deletions(-) (limited to 'Mac/Python/macmain.c') diff --git a/Mac/Python/macmain.c b/Mac/Python/macmain.c index c72bc33774..39f62221d9 100644 --- a/Mac/Python/macmain.c +++ b/Mac/Python/macmain.c @@ -30,6 +30,7 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include "marshal.h" #include "macglue.h" +#ifdef WITHOUT_FRAMEWORKS #include #include #include @@ -41,21 +42,23 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include #include #endif /* USE_APPEARANCE */ +#else +#include +#endif /* WITHOUT_FRAMEWORKS */ + #ifdef __MWERKS__ #include #define USE_SIOUX extern int ccommand(char ***); #if __profile__ == 1 #include -#endif -#endif +#endif /* __profile__ */ +#endif /* __MWERKS__ */ + #include #ifdef USE_MAC_SHARED_LIBRARY extern PyMac_AddLibResources(void); #endif -//#ifdef USE_GUSI -//#include "GUSISIOUX.h" -//#endif #define STARTUP "PythonStartup" @@ -81,7 +84,7 @@ PyMac_PrefRecord PyMac_options; static void Py_Main(int, char **); /* Forward */ void PyMac_Exit(int); /* Forward */ -static void init_appearance() +static void init_appearance(void) { #ifdef USE_APPEARANCE OSErr err; @@ -99,7 +102,7 @@ no_appearance: /* Initialize the Mac toolbox world */ static void -init_mac_world() +init_mac_world(void) { #if !TARGET_API_MAC_CARBON /* These aren't needed for carbon */ @@ -127,8 +130,6 @@ PyMac_InteractiveOptions(PyMac_PrefRecord *p, int *argcp, char ***argvp) ControlHandle handle; DialogPtr dialog; Rect rect; - int old_argc = *argcp; - int i; /* ** If the preferences disallows interactive options we return, @@ -191,7 +192,10 @@ PyMac_InteractiveOptions(PyMac_PrefRecord *p, int *argcp, char ***argvp) HMSetBalloons(!HMGetBalloons()); } #endif +#if !TARGET_API_MAC_OSX if ( item == OPT_CMDLINE ) { + int old_argc = *argcp; + int i; int new_argc, newer_argc; char **new_argv, **newer_argv; @@ -209,6 +213,7 @@ PyMac_InteractiveOptions(PyMac_PrefRecord *p, int *argcp, char ***argvp) /* XXXX Is it not safe to use free() here, apparently */ } +#endif /* !TARGET_API_MAC_OSX */ #define OPT_ITEM(num, var) \ if ( item == (num) ) { \ p->var = !p->var; \ @@ -283,7 +288,9 @@ init_common(int *argcp, char ***argvp, int embedded) #ifdef USE_SIOUX /* Set various SIOUX flags. Some are changed later based on options */ -/* SIOUXSettings.standalone = 0; /* XXXX Attempting to keep sioux from eating events */ +#if 0 + SIOUXSettings.standalone = 0; /* XXXX Attempting to keep sioux from eating events */ +#endif SIOUXSettings.asktosaveonclose = 0; SIOUXSettings.showstatusline = 0; SIOUXSettings.tabspaces = 4; @@ -291,8 +298,11 @@ init_common(int *argcp, char ***argvp, int embedded) /* Get options from preference file (or from applet resource fork) */ PyMac_options.keep_console = POPT_KEEPCONSOLE_OUTPUT; /* default-default */ + PyMac_options.unixnewlines = 1; +#if !TARGET_API_MAC_OSX PyMac_PreferenceOptions(&PyMac_options); - +#endif + if ( embedded ) { static char *emb_argv[] = {"embedded-python", 0}; @@ -301,6 +311,7 @@ init_common(int *argcp, char ***argvp, int embedded) } else { /* Create argc/argv. Do it before we go into the options event loop. */ *argcp = PyMac_GetArgv(argvp, PyMac_options.noargs); +#if !TARGET_API_MAC_OSX #ifndef NO_ARGV0_CHDIR if (*argcp >= 1 && (*argvp)[0] && (*argvp)[0][0]) { /* Workaround for MacOS X, which currently (DP4) doesn't set @@ -313,6 +324,7 @@ init_common(int *argcp, char ***argvp, int embedded) if ( p ) *p = 0; chdir(app_wd); } +#endif #endif /* Do interactive option setting, if allowed and