mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
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.
This commit is contained in:
parent
1d961f5e5f
commit
52306a780b
2 changed files with 15 additions and 6 deletions
|
@ -30,6 +30,9 @@ import EasyDialogs
|
||||||
kHighLevelEvent = 23 # Don't know what header file this should come from
|
kHighLevelEvent = 23 # Don't know what header file this should come from
|
||||||
SCROLLBARWIDTH = 16 # Again, not a clue...
|
SCROLLBARWIDTH = 16 # Again, not a clue...
|
||||||
|
|
||||||
|
# Trick to forestall a set of SIOUX menus being added to our menubar
|
||||||
|
SIOUX_APPLEMENU_ID=32000
|
||||||
|
|
||||||
|
|
||||||
# Map event 'what' field to strings
|
# Map event 'what' field to strings
|
||||||
eventname = {}
|
eventname = {}
|
||||||
|
@ -442,8 +445,9 @@ class MenuBar:
|
||||||
self.bar = None
|
self.bar = None
|
||||||
self.menus = None
|
self.menus = None
|
||||||
|
|
||||||
def addmenu(self, title, after = 0):
|
def addmenu(self, title, after = 0, id=None):
|
||||||
id = self.getnextid()
|
if id == None:
|
||||||
|
id = self.getnextid()
|
||||||
if DEBUG: print 'Newmenu', title, id # XXXX
|
if DEBUG: print 'Newmenu', title, id # XXXX
|
||||||
m = NewMenu(id, title)
|
m = NewMenu(id, title)
|
||||||
m.InsertMenu(after)
|
m.InsertMenu(after)
|
||||||
|
@ -507,9 +511,9 @@ class MenuBar:
|
||||||
class Menu:
|
class Menu:
|
||||||
"One menu."
|
"One menu."
|
||||||
|
|
||||||
def __init__(self, bar, title, after=0):
|
def __init__(self, bar, title, after=0, id=None):
|
||||||
self.bar = bar
|
self.bar = bar
|
||||||
self.id, self.menu = self.bar.addmenu(title, after)
|
self.id, self.menu = self.bar.addmenu(title, after, id)
|
||||||
bar.menus[self.id] = self
|
bar.menus[self.id] = self
|
||||||
self.items = []
|
self.items = []
|
||||||
self._parent = None
|
self._parent = None
|
||||||
|
@ -675,7 +679,7 @@ def SubMenu(menu, label, title=''):
|
||||||
class AppleMenu(Menu):
|
class AppleMenu(Menu):
|
||||||
|
|
||||||
def __init__(self, bar, abouttext="About me...", aboutcallback=None):
|
def __init__(self, bar, abouttext="About me...", aboutcallback=None):
|
||||||
Menu.__init__(self, bar, "\024")
|
Menu.__init__(self, bar, "\024", id=SIOUX_APPLEMENU_ID)
|
||||||
if MacOS.runtimemodel == 'ppc':
|
if MacOS.runtimemodel == 'ppc':
|
||||||
self.additem(abouttext, None, aboutcallback)
|
self.additem(abouttext, None, aboutcallback)
|
||||||
self.addseparator()
|
self.addseparator()
|
||||||
|
|
|
@ -720,6 +720,8 @@ void
|
||||||
PyMac_InitMenuBar()
|
PyMac_InitMenuBar()
|
||||||
{
|
{
|
||||||
MenuHandle applemenu;
|
MenuHandle applemenu;
|
||||||
|
Str255 about_text;
|
||||||
|
static unsigned char about_sioux[] = "\pAbout SIOUX";
|
||||||
|
|
||||||
if ( sioux_mbar ) return;
|
if ( sioux_mbar ) return;
|
||||||
#if 0
|
#if 0
|
||||||
|
@ -737,7 +739,10 @@ PyMac_InitMenuBar()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if ( (applemenu=GetMenuHandle(SIOUX_APPLEID)) == NULL ) return;
|
if ( (applemenu=GetMenuHandle(SIOUX_APPLEID)) == NULL ) return;
|
||||||
SetMenuItemText(applemenu, 1, "\pAbout Python...");
|
GetMenuItemText(applemenu, 1, about_text);
|
||||||
|
if ( about_text[0] == about_sioux[0] &&
|
||||||
|
strncmp((char *)(about_text+1), (char *)(about_sioux+1), about_text[0]) == 0 )
|
||||||
|
SetMenuItemText(applemenu, 1, "\pAbout Python...");
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue