Mercurial > cpython-lru_cache-weakref
comparison Mac/scripts/EditPythonPrefs.py @ 4235:8f291dc8fa9b legacy-trunk
Added handling for new options, fixed applet option setting
| author | Jack Jansen <jack.jansen@cwi.nl> |
|---|---|
| date | Sat, 07 Sep 1996 17:01:47 +0000 |
| parents | 41a52ab263da |
| children | ec4c42bea69d |
comparison
equal
deleted
inserted
replaced
| 4234:7bf71a839661 | 4235:8f291dc8fa9b |
|---|---|
| 44 | 44 |
| 45 # Override IDs (in the applet) | 45 # Override IDs (in the applet) |
| 46 OVERRIDE_PATH_STRINGS_ID = 129 | 46 OVERRIDE_PATH_STRINGS_ID = 129 |
| 47 OVERRIDE_DIRECTORY_ID = 129 | 47 OVERRIDE_DIRECTORY_ID = 129 |
| 48 OVERRIDE_OPTIONS_ID = 129 | 48 OVERRIDE_OPTIONS_ID = 129 |
| 49 OVERRIDE_GUSI_ID = 10240 | 49 OVERRIDE_GUSI_ID = 10241 |
| 50 | 50 |
| 51 # Things we know about the GUSI resource. Note the code knows these too. | 51 # Things we know about the GUSI resource. Note the code knows these too. |
| 52 GUSIPOS_TYPE=0 | 52 GUSIPOS_TYPE=0 |
| 53 GUSIPOS_CREATOR=4 | 53 GUSIPOS_CREATOR=4 |
| 54 GUSIPOS_SKIP=8 | 54 GUSIPOS_SKIP=8 |
| 84 | 84 |
| 85 def message(str = "Hello, world!", id = MESSAGE_ID): | 85 def message(str = "Hello, world!", id = MESSAGE_ID): |
| 86 """Show a simple alert with a text message""" | 86 """Show a simple alert with a text message""" |
| 87 d = GetNewDialog(id, -1) | 87 d = GetNewDialog(id, -1) |
| 88 d.SetDialogDefaultItem(1) | 88 d.SetDialogDefaultItem(1) |
| 89 print 'd=', d | |
| 90 tp, h, rect = d.GetDialogItem(2) | 89 tp, h, rect = d.GetDialogItem(2) |
| 91 SetDialogItemText(h, str) | 90 SetDialogItemText(h, str) |
| 92 while 1: | 91 while 1: |
| 93 n = ModalDialog(None) | 92 n = ModalDialog(None) |
| 94 if n == 1: break | 93 if n == 1: break |
| 185 | 184 |
| 186 def getoptions(id): | 185 def getoptions(id): |
| 187 try: | 186 try: |
| 188 opr = GetResource('Popt', id) | 187 opr = GetResource('Popt', id) |
| 189 except (MacOS.Error, Res.Error): | 188 except (MacOS.Error, Res.Error): |
| 190 return [0]*7, None | 189 return [0]*9, None |
| 191 return map(lambda x: ord(x), opr.data), opr | 190 options = map(lambda x: ord(x), opr.data) |
| 191 while len(options) < 9: | |
| 192 options = options + [0] | |
| 193 return options, opr | |
| 192 | 194 |
| 193 def getgusioptions(id): | 195 def getgusioptions(id): |
| 194 try: | 196 try: |
| 195 opr = GetResource('GU\267I', id) | 197 opr = GetResource('GU\267I', id) |
| 196 except (MacOS.Error, Res.Error): | 198 except (MacOS.Error, Res.Error): |
| 299 newdata = setgusioptions(gusi_opr, creator, type, delaycons) | 301 newdata = setgusioptions(gusi_opr, creator, type, delaycons) |
| 300 if gusi_opr.HomeResFile() == preff_handle: | 302 if gusi_opr.HomeResFile() == preff_handle: |
| 301 gusi_opr.data = newdata | 303 gusi_opr.data = newdata |
| 302 gusi_opr.ChangedResource() | 304 gusi_opr.ChangedResource() |
| 303 else: | 305 else: |
| 304 print 'Created new GUSI option' | 306 ngusi_opr = Resource(newdata) |
| 305 ngusi_opr = Resource(gusi_opr.data) | |
| 306 ngusi_opr.AddResource('GU\267I', GUSI_ID, '') | 307 ngusi_opr.AddResource('GU\267I', GUSI_ID, '') |
| 307 | 308 |
| 308 CloseResFile(preff_handle) | 309 CloseResFile(preff_handle) |
| 309 | 310 |
| 310 def edit_applet(name): | 311 def edit_applet(name): |
| 340 notfound = 'options' | 341 notfound = 'options' |
| 341 options, dummy = getoptions(OPTIONS_ID) | 342 options, dummy = getoptions(OPTIONS_ID) |
| 342 saved_options = options[:] | 343 saved_options = options[:] |
| 343 | 344 |
| 344 creator, type, delaycons, gusi_opr = getgusioptions(OVERRIDE_GUSI_ID) | 345 creator, type, delaycons, gusi_opr = getgusioptions(OVERRIDE_GUSI_ID) |
| 345 if not opr: | 346 if not gusi_opr: |
| 346 if notfound: | 347 if notfound: |
| 347 notfound = notfound + ', GUSI options' | 348 notfound = notfound + ', GUSI options' |
| 348 else: | 349 else: |
| 349 notfound = 'GUSI options' | 350 notfound = 'GUSI options' |
| 350 creator, type, delaycons, dummy = getgusioptions(GUSI_ID) | 351 creator, type, delaycons, gusi_opr = getgusioptions(GUSI_ID) |
| 351 saved_gusi_options = creator, type, delaycons | 352 saved_gusi_options = creator, type, delaycons |
| 352 | 353 |
| 353 dummy = dummy2 = None # Discard them. | 354 dummy = dummy2 = None # Discard them. |
| 354 | 355 |
| 355 if notfound: | 356 if notfound: |
| 359 | 360 |
| 360 # See what we have to update, and how | 361 # See what we have to update, and how |
| 361 if result == None: | 362 if result == None: |
| 362 sys.exit(0) | 363 sys.exit(0) |
| 363 | 364 |
| 364 pathlist, nfss, options = result | 365 pathlist, nfss, (options, creator, type, delaycons) = result |
| 365 if nfss != fss: | 366 if nfss != fss: |
| 366 fss_changed = 1 | 367 fss_changed = 1 |
| 367 | 368 |
| 368 if fss_changed: | 369 if fss_changed: |
| 369 alias = nfss.NewAlias() | 370 alias = nfss.NewAlias() |
| 394 opr = Resource(newdata) | 395 opr = Resource(newdata) |
| 395 opr.AddResource('Popt', OVERRIDE_OPTIONS_ID, '') | 396 opr.AddResource('Popt', OVERRIDE_OPTIONS_ID, '') |
| 396 | 397 |
| 397 if (creator, type, delaycons) != saved_gusi_options: | 398 if (creator, type, delaycons) != saved_gusi_options: |
| 398 newdata = setgusioptions(gusi_opr, creator, type, delaycons) | 399 newdata = setgusioptions(gusi_opr, creator, type, delaycons) |
| 399 if gusi_opr.HomeResFile == app_handle: | 400 id, type, name = gusi_opr.GetResInfo() |
| 401 if gusi_opr.HomeResFile() == app_handle and id == OVERRIDE_GUSI_ID: | |
| 400 gusi_opr.data = newdata | 402 gusi_opr.data = newdata |
| 401 gusi_opr.ChangedResource() | 403 gusi_opr.ChangedResource() |
| 402 else: | 404 else: |
| 403 gusi_opr = Resource(gusi_opr.data) | 405 ngusi_opr = Resource(newdata) |
| 404 gusi_opr.AddResource('GU\267I', OVERRIDE_GUSI_ID, '') | 406 ngusi_opr.AddResource('GU\267I', OVERRIDE_GUSI_ID, '') |
| 405 | 407 |
| 406 CloseResFile(app_handle) | 408 CloseResFile(app_handle) |
| 407 | 409 |
| 408 def main(): | 410 def main(): |
| 409 try: | 411 try: |
