Format code
This commit is contained in:
parent
2f73f4f77e
commit
8fa3e71ce4
1 changed files with 14 additions and 9 deletions
|
@ -58,8 +58,8 @@ Role kRolesMap[] = {
|
||||||
// Menu item is located for ease of removing it from the parent owner
|
// Menu item is located for ease of removing it from the parent owner
|
||||||
static NSMenuItem* recentDocumentsMenuItem_ = nil;
|
static NSMenuItem* recentDocumentsMenuItem_ = nil;
|
||||||
|
|
||||||
// TODO(sethlu): Doc & find a better naming
|
// Submenu retained to be swapped back to |recentDocumentsMenuItem_|
|
||||||
static NSMenu* swapMenu_ = nil;
|
static NSMenu* recentDocumentsMenuSwap_ = nil;
|
||||||
|
|
||||||
@implementation AtomMenuController
|
@implementation AtomMenuController
|
||||||
|
|
||||||
|
@ -148,7 +148,7 @@ static NSMenu* swapMenu_ = nil;
|
||||||
[menu insertItem:separator atIndex:index];
|
[menu insertItem:separator atIndex:index];
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO(sethlu): Doc
|
// Empties the source menu items to the destination.
|
||||||
- (void)moveMenuItems:(NSMenu*)source
|
- (void)moveMenuItems:(NSMenu*)source
|
||||||
to:(NSMenu*)destination {
|
to:(NSMenu*)destination {
|
||||||
const long count = [source numberOfItems];
|
const long count = [source numberOfItems];
|
||||||
|
@ -159,23 +159,28 @@ static NSMenu* swapMenu_ = nil;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO(sethlu): Doc
|
// Replaces the item's submenu instance with the singleton recent documents
|
||||||
|
// menu. Previously replaced menu items will be recovered.
|
||||||
- (void)replaceSubmenuShowingRecentDocuments:(NSMenuItem*)item {
|
- (void)replaceSubmenuShowingRecentDocuments:(NSMenuItem*)item {
|
||||||
NSMenu* recentDocumentsMenu = [[[recentDocumentsMenuItem_ submenu]
|
NSMenu* recentDocumentsMenu = [[[recentDocumentsMenuItem_ submenu]
|
||||||
retain] autorelease];
|
retain] autorelease];
|
||||||
|
|
||||||
// Remove menu items in recent documents back to swap menu
|
// Remove menu items in recent documents back to swap menu
|
||||||
[self moveMenuItems:recentDocumentsMenu to:swapMenu_];
|
[self moveMenuItems:recentDocumentsMenu
|
||||||
|
to:recentDocumentsMenuSwap_];
|
||||||
// Swap back the submenu
|
// Swap back the submenu
|
||||||
[recentDocumentsMenuItem_ setSubmenu:swapMenu_];
|
[recentDocumentsMenuItem_ setSubmenu:recentDocumentsMenuSwap_];
|
||||||
|
|
||||||
// Release the previous swap menu if exists
|
// Release the previous swap menu if exists
|
||||||
if (swapMenu_) [swapMenu_ release];
|
if (recentDocumentsMenuSwap_)
|
||||||
|
[recentDocumentsMenuSwap_ release];
|
||||||
|
|
||||||
// Retain the item's submenu for a future recovery
|
// Retain the item's submenu for a future recovery
|
||||||
swapMenu_ = [[item submenu] retain];
|
recentDocumentsMenuSwap_ = [[item submenu] retain];
|
||||||
|
|
||||||
// Repopulate with items from the submenu to be replaced
|
// Repopulate with items from the submenu to be replaced
|
||||||
[self moveMenuItems:swapMenu_ to:recentDocumentsMenu];
|
[self moveMenuItems:recentDocumentsMenuSwap_
|
||||||
|
to:recentDocumentsMenu];
|
||||||
// Replace submenu
|
// Replace submenu
|
||||||
[item setSubmenu:recentDocumentsMenu];
|
[item setSubmenu:recentDocumentsMenu];
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue