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

Skip to content

Commit 52306a7

Browse files
committed
The new menu initialization code would also add the SIOUX menus if a (frozen) Python program had installed its own menubar previously. We now guard against this, with a bit of a hack: FrameWork uses the same Menu ID as Sioux, and the init code checks that the text in the menu is "About SIOUX" before replacing it.
1 parent 1d961f5 commit 52306a7

2 files changed

Lines changed: 15 additions & 6 deletions

File tree

Mac/Lib/FrameWork.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@
3030
kHighLevelEvent = 23 # Don't know what header file this should come from
3131
SCROLLBARWIDTH = 16 # Again, not a clue...
3232

33+
# Trick to forestall a set of SIOUX menus being added to our menubar
34+
SIOUX_APPLEMENU_ID=32000
35+
3336

3437
# Map event 'what' field to strings
3538
eventname = {}
@@ -442,8 +445,9 @@ def close(self):
442445
self.bar = None
443446
self.menus = None
444447

445-
def addmenu(self, title, after = 0):
446-
id = self.getnextid()
448+
def addmenu(self, title, after = 0, id=None):
449+
if id == None:
450+
id = self.getnextid()
447451
if DEBUG: print 'Newmenu', title, id # XXXX
448452
m = NewMenu(id, title)
449453
m.InsertMenu(after)
@@ -507,9 +511,9 @@ def dispatch(self, id, item, window, event):
507511
class Menu:
508512
"One menu."
509513

510-
def __init__(self, bar, title, after=0):
514+
def __init__(self, bar, title, after=0, id=None):
511515
self.bar = bar
512-
self.id, self.menu = self.bar.addmenu(title, after)
516+
self.id, self.menu = self.bar.addmenu(title, after, id)
513517
bar.menus[self.id] = self
514518
self.items = []
515519
self._parent = None
@@ -675,7 +679,7 @@ def SubMenu(menu, label, title=''):
675679
class AppleMenu(Menu):
676680

677681
def __init__(self, bar, abouttext="About me...", aboutcallback=None):
678-
Menu.__init__(self, bar, "\024")
682+
Menu.__init__(self, bar, "\024", id=SIOUX_APPLEMENU_ID)
679683
if MacOS.runtimemodel == 'ppc':
680684
self.additem(abouttext, None, aboutcallback)
681685
self.addseparator()

Mac/Python/macglue.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -720,6 +720,8 @@ void
720720
PyMac_InitMenuBar()
721721
{
722722
MenuHandle applemenu;
723+
Str255 about_text;
724+
static unsigned char about_sioux[] = "\pAbout SIOUX";
723725

724726
if ( sioux_mbar ) return;
725727
#if 0
@@ -737,7 +739,10 @@ PyMac_InitMenuBar()
737739
return;
738740
}
739741
if ( (applemenu=GetMenuHandle(SIOUX_APPLEID)) == NULL ) return;
740-
SetMenuItemText(applemenu, 1, "\pAbout Python...");
742+
GetMenuItemText(applemenu, 1, about_text);
743+
if ( about_text[0] == about_sioux[0] &&
744+
strncmp((char *)(about_text+1), (char *)(about_sioux+1), about_text[0]) == 0 )
745+
SetMenuItemText(applemenu, 1, "\pAbout Python...");
741746
}
742747

743748
/*

0 commit comments

Comments
 (0)