mirror of
https://github.com/python/cpython.git
synced 2025-07-23 19:25:40 +00:00
Made the GUSI options work again with GUSI 2.
This commit is contained in:
parent
6dd9fc1a2c
commit
ee0810403d
3 changed files with 43 additions and 6 deletions
|
@ -127,6 +127,10 @@ PyObject *PyMac_Buildwide(wide *); /* Convert wide to PyObject */
|
||||||
void PyMac_InitApplet(void); /* Initialize and run an Applet */
|
void PyMac_InitApplet(void); /* Initialize and run an Applet */
|
||||||
void PyMac_Initialize(void); /* Initialize function for embedding Python */
|
void PyMac_Initialize(void); /* Initialize function for embedding Python */
|
||||||
|
|
||||||
|
#ifdef USE_GUSI2
|
||||||
|
short PyMac_OpenPrefFile(void); /* From macgetpath.c, open and return preference file */
|
||||||
|
#endif
|
||||||
|
|
||||||
/* From macfiletype.c: */
|
/* From macfiletype.c: */
|
||||||
|
|
||||||
long getfiletype(char *); /* Get file type */
|
long getfiletype(char *); /* Get file type */
|
||||||
|
|
|
@ -5,9 +5,11 @@
|
||||||
#define GUSI_SOURCE
|
#define GUSI_SOURCE
|
||||||
#include <GUSIConfig.h>
|
#include <GUSIConfig.h>
|
||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
|
#include <Resources.h>
|
||||||
|
|
||||||
#include "Python.h"
|
#include "Python.h"
|
||||||
#include "macglue.h"
|
#include "macglue.h"
|
||||||
|
#include "pythonresources.h"
|
||||||
|
|
||||||
static void
|
static void
|
||||||
PyMac_GUSISpin(bool wait)
|
PyMac_GUSISpin(bool wait)
|
||||||
|
@ -79,13 +81,44 @@ void GUSISetupDevices()
|
||||||
GUSIConfiguration::FileSuffix sSuffices[] = {
|
GUSIConfiguration::FileSuffix sSuffices[] = {
|
||||||
"", '????', '????'
|
"", '????', '????'
|
||||||
};
|
};
|
||||||
|
|
||||||
extern "C" void GUSISetupConfig()
|
extern "C" void GUSISetupConfig()
|
||||||
{
|
{
|
||||||
GUSIConfiguration * config =
|
Handle h;
|
||||||
GUSIConfiguration::CreateInstance(GUSIConfiguration::kNoResource);
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
config->ConfigureDefaultTypeCreator('TEXT', 'TEXT');
|
/* Now we have the right resource file topmost and the id. Init GUSI. */
|
||||||
|
GUSIConfiguration * config =
|
||||||
|
GUSIConfiguration::CreateInstance(resource_id);
|
||||||
|
|
||||||
|
/* Finally restore the old resource file */
|
||||||
|
if ( prefrh != -1) CloseResFile(prefrh);
|
||||||
|
UseResFile(oldrh);
|
||||||
|
|
||||||
|
config->ConfigureDefaultTypeCreator('ttxt', 'TEXT');
|
||||||
config->ConfigureSuffices(
|
config->ConfigureSuffices(
|
||||||
sizeof(sSuffices)/sizeof(GUSIConfiguration::FileSuffix)-1, sSuffices);
|
sizeof(sSuffices)/sizeof(GUSIConfiguration::FileSuffix)-1, sSuffices);
|
||||||
config->ConfigureAutoInitGraf(false);
|
config->ConfigureAutoInitGraf(false);
|
||||||
|
|
|
@ -189,7 +189,7 @@ Py_GetPath()
|
||||||
/*
|
/*
|
||||||
** Open/create the Python Preferences file, return the handle
|
** Open/create the Python Preferences file, return the handle
|
||||||
*/
|
*/
|
||||||
static short
|
short
|
||||||
PyMac_OpenPrefFile()
|
PyMac_OpenPrefFile()
|
||||||
{
|
{
|
||||||
AliasHandle handle;
|
AliasHandle handle;
|
||||||
|
@ -467,4 +467,4 @@ PyMac_SetGUSIOptions()
|
||||||
if ( prefrh != -1) CloseResFile(prefrh);
|
if ( prefrh != -1) CloseResFile(prefrh);
|
||||||
UseResFile(oldrh);
|
UseResFile(oldrh);
|
||||||
}
|
}
|
||||||
#endif /* USE_GUSI */
|
#endif /* USE_GUSI1 */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue