mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-12-04 11:54:59 +00:00
Imrpoved identifying main menus in cibs.
Reviewed by me.
This commit is contained in:
1 parent
1a7a07b51a
commit
78fe93be68
5 files changed
+60
-28
No files matched your search
+10
-5
@@ -497,13 +497,18 @@ CPRunContinuesResponse = -1002;
|
||||
*/
|
||||
- (void)setMainMenu:(CPMenu)aMenu
|
||||
{
|
||||
if (_mainMenu === aMenu)
|
||||
return;
|
||||
if ([aMenu _menuName] === "CPMainMenu")
|
||||
{
|
||||
if (_mainMenu === aMenu)
|
||||
return;
|
||||
|
||||
_mainMenu = aMenu;
|
||||
_mainMenu = aMenu;
|
||||
|
||||
if ([CPPlatform supportsNativeMainMenu])
|
||||
window.cpSetMainMenu(_mainMenu);
|
||||
if ([CPPlatform supportsNativeMainMenu])
|
||||
window.cpSetMainMenu(_mainMenu);
|
||||
}
|
||||
else
|
||||
[aMenu _setMenuName:@"CPMainMenu"];
|
||||
}
|
||||
|
||||
- (void)orderFrontColorPanel:(id)aSender
|
||||
|
||||
@@ -60,6 +60,7 @@ var _CPMenuBarVisible = NO,
|
||||
CPMenu _supermenu;
|
||||
|
||||
CPString _title;
|
||||
CPString _name;
|
||||
|
||||
CPMutableArray _items;
|
||||
CPMenu _attachedMenu;
|
||||
@@ -824,10 +825,36 @@ var _CPMenuBarVisible = NO,
|
||||
[[_items[_highlightedIndex] _menuItemView] highlight:YES];
|
||||
}
|
||||
|
||||
- (void)_setMenuName:(CPString)aName
|
||||
{
|
||||
if (_name === aName)
|
||||
return;
|
||||
|
||||
_name = aName;
|
||||
|
||||
if (_name === @"CPMainMenu")
|
||||
[CPApp setMainMenu:self];
|
||||
}
|
||||
|
||||
- (CPString)_menuName
|
||||
{
|
||||
return _name;
|
||||
}
|
||||
|
||||
- (void)awakeFromCib
|
||||
{
|
||||
if (_name === @"_CPMainMenu")
|
||||
{
|
||||
[self _setMenuName:@"CPMainMenu"];
|
||||
[CPMenu setMenuBarVisible:YES];
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
var CPMenuTitleKey = @"CPMenuTitleKey",
|
||||
CPMenuNameKey = @"CPMenuNameKey",
|
||||
CPMenuItemsKey = @"CPMenuItemsKey",
|
||||
CPMenuShowsStateColumnKey = @"CPMenuShowsStateColumnKey";
|
||||
|
||||
@@ -847,6 +874,8 @@ var CPMenuTitleKey = @"CPMenuTitleKey",
|
||||
_title = [aCoder decodeObjectForKey:CPMenuTitleKey];
|
||||
_items = [aCoder decodeObjectForKey:CPMenuItemsKey];
|
||||
|
||||
[self _setMenuName:[aCoder decodeObjectForKey:CPMenuNameKey]];
|
||||
|
||||
_showsStateColumn = ![aCoder containsValueForKey:CPMenuShowsStateColumnKey] || [aCoder decodeBoolForKey:CPMenuShowsStateColumnKey];
|
||||
}
|
||||
|
||||
@@ -860,6 +889,10 @@ var CPMenuTitleKey = @"CPMenuTitleKey",
|
||||
- (void)encodeWithCoder:(CPCoder)aCoder
|
||||
{
|
||||
[aCoder encodeObject:_title forKey:CPMenuTitleKey];
|
||||
|
||||
if (_name)
|
||||
[aCoder encodeObject:_name forKey:CPMenuNameKey];
|
||||
|
||||
[aCoder encodeObject:_items forKey:CPMenuItemsKey];
|
||||
|
||||
if (!_showsStateColumn)
|
||||
|
||||
@@ -150,14 +150,6 @@ var CPCibObjectDataKey = @"CPCibObjectDataKey";
|
||||
[objectData establishConnectionsWithOwner:owner topLevelObjects:topLevelObjects];
|
||||
[objectData awakeWithOwner:owner topLevelObjects:topLevelObjects];
|
||||
|
||||
var menu;
|
||||
|
||||
if ((menu = [objectData mainMenu]) != nil)
|
||||
{
|
||||
[CPApp setMainMenu:menu];
|
||||
[CPMenu setMenuBarVisible:YES];
|
||||
}
|
||||
|
||||
// Display Visible Windows.
|
||||
[objectData displayVisibleWindows];
|
||||
|
||||
|
||||
@@ -100,21 +100,6 @@
|
||||
return self;
|
||||
}
|
||||
|
||||
- (CPMenu)mainMenu
|
||||
{
|
||||
var index = [_namesValues indexOfObjectIdenticalTo:"MainMenu"];
|
||||
|
||||
if (index === CPNotFound)
|
||||
{
|
||||
index = [_namesValues indexOfObjectIdenticalTo:"Main Menu"];
|
||||
|
||||
if (index === CPNotFound)
|
||||
return nil;
|
||||
}
|
||||
|
||||
return _namesKeys[index];
|
||||
}
|
||||
|
||||
- (void)displayVisibleWindows
|
||||
{
|
||||
var object = nil,
|
||||
|
||||
@@ -25,6 +25,17 @@
|
||||
@import "NSMenuItem.j"
|
||||
|
||||
|
||||
NS_CPMenuNameMap =
|
||||
{
|
||||
_NSMainMenu : @"_CPMainMenu",
|
||||
_NSAppleMenu : @"_CPApplicationMenu",
|
||||
_NSServicesMenu : @"_CPServicesMenu",
|
||||
_NSWindowsMenu : @"_CPWindowsMenu",
|
||||
_NSFontMenu : @"_CPFontMenu",
|
||||
_NSRecentDocumentsMenu : @"_CPRecentDocumentsMenu",
|
||||
_NSOpenDocumentsMenu : @"_CPOpenDocumentsMenu"
|
||||
};
|
||||
|
||||
@implementation CPMenu (NSCoding)
|
||||
|
||||
- (id)NS_initWithCoder:(CPCoder)aCoder
|
||||
@@ -35,6 +46,12 @@
|
||||
{
|
||||
_title = [aCoder decodeObjectForKey:@"NSTitle"];
|
||||
_items = [aCoder decodeObjectForKey:@"NSMenuItems"];
|
||||
_name = [aCoder decodeObjectForKey:@"NSName"];
|
||||
|
||||
var mappedName = NS_CPMenuNameMap[_name];
|
||||
|
||||
if (mappedName)
|
||||
_name = mappedName;
|
||||
|
||||
_showsStateColumn = YES;
|
||||
//_showsStateColumn = ![aCoder containsValueForKey:@"NSMenuExcludeMarkColumn"] || ![aCoder decodeBoolForKey:@"NSMenuExcludeMarkColumn"];
|
||||
|
||||
Reference in new issue
Block a user