summaryrefslogtreecommitdiffstats
path: root/Mac/Python
diff options
context:
space:
mode:
authorJack Jansen <jack.jansen@cwi.nl>2000-04-21 23:53:37 (GMT)
committerJack Jansen <jack.jansen@cwi.nl>2000-04-21 23:53:37 (GMT)
commitee0810403dc95f232c0217876e026bac6667e8ae (patch)
tree4181684b1b2b2a37cac61fd29e22a6b87abb273a /Mac/Python
parent6dd9fc1a2cf48a1db9881eb8607575d6fe5adab5 (diff)
downloadcpython-ee0810403dc95f232c0217876e026bac6667e8ae.zip
cpython-ee0810403dc95f232c0217876e026bac6667e8ae.tar.gz
cpython-ee0810403dc95f232c0217876e026bac6667e8ae.tar.bz2
Made the GUSI options work again with GUSI 2.
Diffstat (limited to 'Mac/Python')
-rw-r--r--Mac/Python/gusiconfig.cpp39
-rw-r--r--Mac/Python/macgetpath.c4
2 files changed, 38 insertions, 5 deletions
diff --git a/Mac/Python/gusiconfig.cpp b/Mac/Python/gusiconfig.cpp
index c69498f..943a0a6 100644
--- a/Mac/Python/gusiconfig.cpp
+++ b/Mac/Python/gusiconfig.cpp
@@ -5,9 +5,11 @@
#define GUSI_SOURCE
#include <GUSIConfig.h>
#include <sys/cdefs.h>
+#include <Resources.h>
#include "Python.h"
#include "macglue.h"
+#include "pythonresources.h"
static void
PyMac_GUSISpin(bool wait)
@@ -79,13 +81,44 @@ void GUSISetupDevices()
GUSIConfiguration::FileSuffix sSuffices[] = {
"", '????', '????'
};
-
extern "C" void GUSISetupConfig()
{
+ Handle h;
+ short oldrh, prefrh = -1;
+ short resource_id = GUSIConfiguration::kNoResource;
+
+ oldrh = CurResFile();
+
+ /* Try override from the application resource fork */
+ UseResFile(PyMac_AppRefNum);
+ h = Get1Resource('GU\267I', GUSIOPTIONSOVERRIDE_ID);
+ if ( h ) {
+ resource_id = GUSIOPTIONSOVERRIDE_ID;
+ } else {
+ /* Next try normal resource from preference file */
+ prefrh = PyMac_OpenPrefFile();
+ h = Get1Resource('GU\267I', GUSIOPTIONS_ID);
+ if ( h ) {
+ resource_id = GUSIOPTIONS_ID;
+ } else {
+ /* Finally try normal resource from application */
+ if ( prefrh != -1 ) {
+ CloseResFile(prefrh);
+ prefrh = -1;
+ }
+ resource_id = GUSIOPTIONS_ID;
+ }
+ }
+
+ /* Now we have the right resource file topmost and the id. Init GUSI. */
GUSIConfiguration * config =
- GUSIConfiguration::CreateInstance(GUSIConfiguration::kNoResource);
+ GUSIConfiguration::CreateInstance(resource_id);
+
+ /* Finally restore the old resource file */
+ if ( prefrh != -1) CloseResFile(prefrh);
+ UseResFile(oldrh);
- config->ConfigureDefaultTypeCreator('TEXT', 'TEXT');
+ config->ConfigureDefaultTypeCreator('ttxt', 'TEXT');
config->ConfigureSuffices(
sizeof(sSuffices)/sizeof(GUSIConfiguration::FileSuffix)-1, sSuffices);
config->ConfigureAutoInitGraf(false);
diff --git a/Mac/Python/macgetpath.c b/Mac/Python/macgetpath.c
index d1c60a0..bc957cc 100644
--- a/Mac/Python/macgetpath.c
+++ b/Mac/Python/macgetpath.c
@@ -189,7 +189,7 @@ Py_GetPath()
/*
** Open/create the Python Preferences file, return the handle
*/
-static short
+short
PyMac_OpenPrefFile()
{
AliasHandle handle;
@@ -467,4 +467,4 @@ PyMac_SetGUSIOptions()
if ( prefrh != -1) CloseResFile(prefrh);
UseResFile(oldrh);
}
-#endif /* USE_GUSI */
+#endif /* USE_GUSI1 */