comparison 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
comparison
equal deleted inserted replaced
12445:9c4a4e6bd555 12446:e367ad3ea59a
3 */ 3 */
4 4
5 #define GUSI_SOURCE 5 #define GUSI_SOURCE
6 #include <GUSIConfig.h> 6 #include <GUSIConfig.h>
7 #include <sys/cdefs.h> 7 #include <sys/cdefs.h>
8 #include <Resources.h>
8 9
9 #include "Python.h" 10 #include "Python.h"
10 #include "macglue.h" 11 #include "macglue.h"
12 #include "pythonresources.h"
11 13
12 static void 14 static void
13 PyMac_GUSISpin(bool wait) 15 PyMac_GUSISpin(bool wait)
14 { 16 {
15 static Boolean inForeground = true; 17 static Boolean inForeground = true;
77 #endif 79 #endif
78 80
79 GUSIConfiguration::FileSuffix sSuffices[] = { 81 GUSIConfiguration::FileSuffix sSuffices[] = {
80 "", '????', '????' 82 "", '????', '????'
81 }; 83 };
82
83 extern "C" void GUSISetupConfig() 84 extern "C" void GUSISetupConfig()
84 { 85 {
86 Handle h;
87 short oldrh, prefrh = -1;
88 short resource_id = GUSIConfiguration::kNoResource;
89
90 oldrh = CurResFile();
91
92 /* Try override from the application resource fork */
93 UseResFile(PyMac_AppRefNum);
94 h = Get1Resource('GU\267I', GUSIOPTIONSOVERRIDE_ID);
95 if ( h ) {
96 resource_id = GUSIOPTIONSOVERRIDE_ID;
97 } else {
98 /* Next try normal resource from preference file */
99 prefrh = PyMac_OpenPrefFile();
100 h = Get1Resource('GU\267I', GUSIOPTIONS_ID);
101 if ( h ) {
102 resource_id = GUSIOPTIONS_ID;
103 } else {
104 /* Finally try normal resource from application */
105 if ( prefrh != -1 ) {
106 CloseResFile(prefrh);
107 prefrh = -1;
108 }
109 resource_id = GUSIOPTIONS_ID;
110 }
111 }
112
113 /* Now we have the right resource file topmost and the id. Init GUSI. */
85 GUSIConfiguration * config = 114 GUSIConfiguration * config =
86 GUSIConfiguration::CreateInstance(GUSIConfiguration::kNoResource); 115 GUSIConfiguration::CreateInstance(resource_id);
87 116
88 config->ConfigureDefaultTypeCreator('TEXT', 'TEXT'); 117 /* Finally restore the old resource file */
118 if ( prefrh != -1) CloseResFile(prefrh);
119 UseResFile(oldrh);
120
121 config->ConfigureDefaultTypeCreator('ttxt', 'TEXT');
89 config->ConfigureSuffices( 122 config->ConfigureSuffices(
90 sizeof(sSuffices)/sizeof(GUSIConfiguration::FileSuffix)-1, sSuffices); 123 sizeof(sSuffices)/sizeof(GUSIConfiguration::FileSuffix)-1, sSuffices);
91 config->ConfigureAutoInitGraf(false); 124 config->ConfigureAutoInitGraf(false);
92 config->ConfigureAutoSpin(false); 125 config->ConfigureAutoSpin(false);
93 config->ConfigureHandleAppleEvents(false); 126 config->ConfigureHandleAppleEvents(false);