Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit caa7c46

Browse files
committed
- Restore SIOUX menubar just before exiting, if the console window is kept
open (so the user can quit with cmd-Q, print, etc) - Removed a few unused routines
1 parent 455838a commit caa7c46

2 files changed

Lines changed: 27 additions & 21 deletions

File tree

Mac/Python/macglue.c

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,11 @@ int PyMac_DoYieldEnabled = 1;
159159
*/
160160
int PyMac_ConsoleIsDead;
161161

162+
/*
163+
** Sioux menu bar, saved early so we can restore it
164+
*/
165+
static Handle sioux_mbar;
166+
162167
/*
163168
** Some stuff for our GetDirectory and PromptGetFile routines
164169
*/
@@ -415,8 +420,6 @@ scan_event_queue(flush)
415420
}
416421
}
417422

418-
#define TICKCOUNT 6
419-
420423
int
421424
PyOS_InterruptOccurred()
422425
{
@@ -426,6 +429,7 @@ PyOS_InterruptOccurred()
426429
schedparams.next_check = (unsigned long)LMGetTicks()
427430
+ schedparams.check_interval;
428431
if (interrupted) {
432+
scan_event_queue(1); /* Eat events up to cmd-. */
429433
interrupted = 0;
430434
return 1;
431435
}
@@ -434,23 +438,6 @@ PyOS_InterruptOccurred()
434438
return 0;
435439
}
436440

437-
#if 0
438-
439-
/* intrpeek() is like intrcheck(), but it doesn't flush the events. The
440-
** idea is that you call intrpeek() somewhere in a busy-wait loop, and return
441-
** None as soon as it returns 1. The mainloop will then pick up the cmd-. soon
442-
** thereafter.
443-
*/
444-
static int
445-
intrpeek()
446-
{
447-
#ifdef THINK_C
448-
scan_event_queue(0);
449-
#endif
450-
return interrupted;
451-
}
452-
#endif
453-
454441
/* Check whether we are in the foreground */
455442
int
456443
PyMac_InForeground()
@@ -505,6 +492,7 @@ PyMac_HandleEvent(evp, maycallpython)
505492
}
506493
}
507494
#endif /* !__MWERKS__ */
495+
printf("not handled\n");
508496
}
509497

510498
/*
@@ -596,20 +584,36 @@ PyMac_SetSchedParams(PyMacSchedParams *sp)
596584
schedparams.enabled = 0;
597585
schedparams.next_check = 0; /* Check immedeately */
598586
}
587+
599588
/*
600589
** Install our menu bar.
601590
*/
602591
void
603592
PyMac_InitMenuBar()
604593
{
605-
Handle bar;
606594
MenuHandle applemenu;
607595

608-
if ( (bar=GetMenuBar()) == NULL ) return;
596+
if ( (sioux_mbar=GetMenuBar()) == NULL ) {
597+
/* Sioux menu not installed yet. Do so */
598+
SIOUXSetupMenus();
599+
if ( (sioux_mbar=GetMenuBar()) == NULL )
600+
return;
601+
}
609602
if ( (applemenu=GetMenuHandle(SIOUX_APPLEID)) == NULL ) return;
610603
SetMenuItemText(applemenu, 1, "\pAbout Python...");
611604
}
612605

606+
/*
607+
** Restore sioux menu bar
608+
*/
609+
void
610+
PyMac_RestoreMenuBar()
611+
{
612+
if ( sioux_mbar )
613+
SetMenuBar(sioux_mbar);
614+
}
615+
616+
613617
/*
614618
** Our replacement about box
615619
*/

Mac/Python/macmain.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,7 @@ init_common(int *argcp, char ***argvp, int embedded)
214214

215215
#ifdef USE_SIOUX
216216
/* Set various SIOUX flags. Some are changed later based on options */
217+
/* SIOUXSettings.standalone = 0; /* XXXX Attempting to keep sioux from eating events */
217218
SIOUXSettings.asktosaveonclose = 0;
218219
SIOUXSettings.showstatusline = 0;
219220
SIOUXSettings.tabspaces = 4;
@@ -462,6 +463,7 @@ PyMac_Exit(status)
462463
SIOUXSettings.standalone = 1;
463464
SIOUXSettings.autocloseonquit = 0;
464465
SIOUXSetTitle("\p\307terminated\310");
466+
PyMac_RestoreMenuBar();
465467
#ifdef USE_MSL
466468
/*
467469
** Temporary workaround: autocloseonquit clearing does not

0 commit comments

Comments
 (0)