Mercurial > cpython-lru_cache-weakref
diff Mac/Python/gusiconfig.cpp @ 12446:e367ad3ea59a legacy-trunk
Made the GUSI options work again with GUSI 2.
| author | Jack Jansen <jack.jansen@cwi.nl> |
|---|---|
| date | Fri, 21 Apr 2000 23:53:37 +0000 |
| parents | 51c0c3b6d919 |
| children | 6b143ca4fd7f |
line wrap: on
line diff
--- a/Mac/Python/gusiconfig.cpp Fri Apr 21 21:43:40 2000 +0000 +++ b/Mac/Python/gusiconfig.cpp Fri Apr 21 23:53:37 2000 +0000 @@ -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 @@ 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); - config->ConfigureDefaultTypeCreator('TEXT', 'TEXT'); + /* Finally restore the old resource file */ + if ( prefrh != -1) CloseResFile(prefrh); + UseResFile(oldrh); + + config->ConfigureDefaultTypeCreator('ttxt', 'TEXT'); config->ConfigureSuffices( sizeof(sSuffices)/sizeof(GUSIConfiguration::FileSuffix)-1, sSuffices); config->ConfigureAutoInitGraf(false);
