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

Skip to content

Commit 3469e99

Browse files
committed
Python about box implemented. Slightly convoluted, since (a) we have
to override an internal sioux routine and (b) we have to override the "about sioux" menuitem after sioux has created its menus.
1 parent c204c70 commit 3469e99

5 files changed

Lines changed: 463 additions & 58 deletions

File tree

Mac/Include/macglue.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ PyObject *PyErr_Mac(PyObject *, int); /* Exception with a mac error */
6363
PyObject *PyMac_Error(OSErr); /* Uses PyMac_GetOSErrException */
6464
void PyMac_HandleEvent Py_PROTO((EventRecord *)); /* Handle one event, if possible */
6565

66+
void PyMac_InitMenuBar(void); /* Setup menu bar as we want it */
67+
6668
int PyMac_FindResourceModule(char *, char *); /* Test for 'PYC ' resource in a file */
6769
PyObject * PyMac_LoadResourceModule(char *, char *); /* Load 'PYC ' resource from file */
6870

Mac/Include/pythonresources.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@
5656
/* Dialog for 'Bad preference file' */
5757
#define BADPREFFILE_ID 135
5858

59+
/* About box */
60+
#define ABOUT_ID 136
61+
5962
/*
6063
** The following are valid both in the binary (or shared library)
6164
** and in the Preferences file.
@@ -83,6 +86,9 @@
8386
#define POPT_KEEPNORM 5
8487
#define POPT_KEEPERR 6
8588

89+
/* Our menu bar */
90+
#define MENUBAR_ID 128
91+
8692
/* From macgetpath.c: */
8793
void PyMac_PreferenceOptions Py_PROTO((int *inspect, int *verbose, int *suppress_print,
8894
int *unbuffered, int *debugging, int *keep_normal,

Mac/Python/macglue.c

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,9 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
6868
#include <GUSI.h>
6969
#endif
7070

71+
/* The ID of the Sioux apple menu */
72+
#define SIOUX_APPLEID 32000
73+
7174
#ifndef HAVE_UNIVERSAL_HEADERS
7275
#define GetResourceSizeOnDisk(x) SizeResource(x)
7376
typedef DlgHookYDProcPtr DlgHookYDUPP;
@@ -517,6 +520,35 @@ PyMac_Idle()
517520
}
518521
#endif
519522

523+
/*
524+
** Install our menu bar.
525+
*/
526+
void
527+
PyMac_InitMenuBar()
528+
{
529+
Handle bar;
530+
MenuHandle applemenu;
531+
532+
if ( (bar=GetMenuBar()) == NULL ) return;
533+
if ( (applemenu=GetMHandle(SIOUX_APPLEID)) == NULL ) return;
534+
SetMenuItemText(applemenu, 1, "\pAbout Python...");
535+
}
536+
537+
/*
538+
** Our replacement about box
539+
*/
540+
void
541+
SIOUXDoAboutBox(void)
542+
{
543+
DialogPtr theDialog;
544+
short item;
545+
546+
if( (theDialog = GetNewDialog(ABOUT_ID, NULL, (WindowPtr)-1)) == NULL )
547+
return;
548+
ModalDialog(NULL, &item);
549+
DisposeDialog(theDialog);
550+
}
551+
520552
/*
521553
** Returns true if the argument has a resource fork, and it contains
522554
** a 'PYC ' resource of the correct name

Mac/Python/macmain.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,12 @@ Py_Main(argc, argv)
351351
}
352352
}
353353

354+
/*
355+
** For reasons I don't fully understand we cannot insert our
356+
** menu earlier. Leave it here, we hope to be rid of Sioux soon anyway.
357+
*/
358+
PyMac_InitMenuBar();
359+
354360
Py_Initialize();
355361

356362
PySys_SetArgv(argc-1, argv+1);

0 commit comments

Comments
 (0)