Camino only - Bug 356488: Move GoMenu.{h,mm} to HistoryMenu.{h,mm}, and rename the GoMenu and HistoryMenu classes. sr=pink

git-svn-id: svn://10.0.0.236/trunk@249765 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
stuart.morgan%alumni.case.edu 2008-04-08 03:11:59 +00:00
parent 58a41c4637
commit d1cc808fbe
6 changed files with 55 additions and 47 deletions

View File

@ -354,7 +354,7 @@
3F44AC9905BDFB9E00CB4B08 /* PreferenceManager.mm in Sources */ = {isa = PBXBuildFile; fileRef = F52D5CD8027D3D5001A80166 /* PreferenceManager.mm */; };
3F44AC9A05BDFB9E00CB4B08 /* HistoryDataSource.mm in Sources */ = {isa = PBXBuildFile; fileRef = F52F87CD027D75C301A80165 /* HistoryDataSource.mm */; };
3F44AC9C05BDFB9E00CB4B08 /* PageProxyIcon.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2E2939FF027F33604B000102 /* PageProxyIcon.mm */; };
3F44AC9D05BDFB9E00CB4B08 /* GoMenu.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2E748B73029A448D4B000102 /* GoMenu.mm */; };
3F44AC9D05BDFB9E00CB4B08 /* HistoryMenu.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2E748B73029A448D4B000102 /* HistoryMenu.mm */; };
3F44AC9D85BDFB9E00CB4B08 /* nsStaticComponents.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F56F241F02AC6D0401A967F3 /* nsStaticComponents.cpp */; };
3F44AC9E05BDFB9E00CB4B08 /* BookmarkInfoController.mm in Sources */ = {isa = PBXBuildFile; fileRef = F53E012C02AEE93601A967F3 /* BookmarkInfoController.mm */; };
3F44AC9F05BDFB9E00CB4B08 /* BrowserWindow.mm in Sources */ = {isa = PBXBuildFile; fileRef = F632AF8402B9AEBB01000103 /* BrowserWindow.mm */; };
@ -633,7 +633,7 @@
3F44AED205BDFBA000CB4B08 /* PreferenceManager.mm in Sources */ = {isa = PBXBuildFile; fileRef = F52D5CD8027D3D5001A80166 /* PreferenceManager.mm */; };
3F44AED305BDFBA000CB4B08 /* HistoryDataSource.mm in Sources */ = {isa = PBXBuildFile; fileRef = F52F87CD027D75C301A80165 /* HistoryDataSource.mm */; };
3F44AED505BDFBA000CB4B08 /* PageProxyIcon.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2E2939FF027F33604B000102 /* PageProxyIcon.mm */; };
3F44AED605BDFBA000CB4B08 /* GoMenu.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2E748B73029A448D4B000102 /* GoMenu.mm */; };
3F44AED605BDFBA000CB4B08 /* HistoryMenu.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2E748B73029A448D4B000102 /* HistoryMenu.mm */; };
3F44AED705BDFBA000CB4B08 /* nsStaticComponents.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F56F241F02AC6D0401A967F3 /* nsStaticComponents.cpp */; };
3F44AED805BDFBA000CB4B08 /* BookmarkInfoController.mm in Sources */ = {isa = PBXBuildFile; fileRef = F53E012C02AEE93601A967F3 /* BookmarkInfoController.mm */; };
3F44AED905BDFBA000CB4B08 /* AppDirServiceProvider.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F59236C002C89AC90100012B /* AppDirServiceProvider.cpp */; };
@ -2303,8 +2303,8 @@
29B97325FDCFA39411CA2CEA /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = /System/Library/Frameworks/Foundation.framework; sourceTree = "<absolute>"; };
2E2939FF027F33604B000102 /* PageProxyIcon.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; name = PageProxyIcon.mm; path = src/browser/PageProxyIcon.mm; sourceTree = "<group>"; };
2E293A00027F33604B000102 /* PageProxyIcon.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = PageProxyIcon.h; path = src/browser/PageProxyIcon.h; sourceTree = "<group>"; };
2E748B72029A448D4B000102 /* GoMenu.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = GoMenu.h; path = src/browser/GoMenu.h; sourceTree = "<group>"; };
2E748B73029A448D4B000102 /* GoMenu.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; name = GoMenu.mm; path = src/browser/GoMenu.mm; sourceTree = "<group>"; };
2E748B72029A448D4B000102 /* HistoryMenu.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = HistoryMenu.h; path = src/browser/HistoryMenu.h; sourceTree = "<group>"; };
2E748B73029A448D4B000102 /* HistoryMenu.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; name = HistoryMenu.mm; path = src/browser/HistoryMenu.mm; sourceTree = "<group>"; };
3312BF340C84C2B4000E6965 /* arrow.gif */ = {isa = PBXFileReference; lastKnownFileType = image.gif; name = arrow.gif; path = ../dist/Embed/res/arrow.gif; sourceTree = SOURCE_ROOT; };
3312BF350C84C2B4000E6965 /* arrowd.gif */ = {isa = PBXFileReference; lastKnownFileType = image.gif; name = arrowd.gif; path = ../dist/Embed/res/arrowd.gif; sourceTree = SOURCE_ROOT; };
3316F4470D11F1900025ED19 /* TabButtonView.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = TabButtonView.h; path = src/browser/TabButtonView.h; sourceTree = "<group>"; };
@ -3681,8 +3681,8 @@
33563A540C84ED5800DC4D06 /* UI */ = {
isa = PBXGroup;
children = (
2E748B72029A448D4B000102 /* GoMenu.h */,
2E748B73029A448D4B000102 /* GoMenu.mm */,
2E748B72029A448D4B000102 /* HistoryMenu.h */,
2E748B73029A448D4B000102 /* HistoryMenu.mm */,
335638FD0C84D82200DC4D06 /* HistoryOutlineViewDelegate.h */,
0FBC0EDC0798F9B400E8E0E2 /* HistoryOutlineViewDelegate.mm */,
);
@ -5337,7 +5337,7 @@
3F44AC9905BDFB9E00CB4B08 /* PreferenceManager.mm in Sources */,
3F44AC9A05BDFB9E00CB4B08 /* HistoryDataSource.mm in Sources */,
3F44AC9C05BDFB9E00CB4B08 /* PageProxyIcon.mm in Sources */,
3F44AC9D05BDFB9E00CB4B08 /* GoMenu.mm in Sources */,
3F44AC9D05BDFB9E00CB4B08 /* HistoryMenu.mm in Sources */,
3F44AC9D85BDFB9E00CB4B08 /* nsStaticComponents.cpp in Sources */,
3F44AC9E05BDFB9E00CB4B08 /* BookmarkInfoController.mm in Sources */,
3F44AC9F05BDFB9E00CB4B08 /* BrowserWindow.mm in Sources */,
@ -5518,7 +5518,7 @@
3F44AED205BDFBA000CB4B08 /* PreferenceManager.mm in Sources */,
3F44AED305BDFBA000CB4B08 /* HistoryDataSource.mm in Sources */,
3F44AED505BDFBA000CB4B08 /* PageProxyIcon.mm in Sources */,
3F44AED605BDFBA000CB4B08 /* GoMenu.mm in Sources */,
3F44AED605BDFBA000CB4B08 /* HistoryMenu.mm in Sources */,
3F44AED705BDFBA000CB4B08 /* nsStaticComponents.cpp in Sources */,
3F44AED805BDFBA000CB4B08 /* BookmarkInfoController.mm in Sources */,
3F44AED905BDFBA000CB4B08 /* AppDirServiceProvider.cpp in Sources */,

View File

@ -392,7 +392,7 @@
/* History labels */
"Tomorrow" = "Tomorrow";
"Today" = "Today";
"GoMenuEarlierToday" = "Earlier Today";
"TopLevelHistoryMenuEarlierToday" = "Earlier Today";
"Yesterday" = "Yesterday";
"HistoryMoreThanAWeek" = "More than a week ago";
"LocalFilesCategoryTitle" = "Local Files";

View File

@ -127,13 +127,7 @@
LANGUAGE = ObjC;
SUPERCLASS = NSObject;
},
{CLASS = GoMenu; LANGUAGE = ObjC; SUPERCLASS = HistoryMenu; },
{
CLASS = HistoryMenu;
LANGUAGE = ObjC;
OUTLETS = {mItemBeforeHistoryItems = NSMenuItem; };
SUPERCLASS = NSMenu;
},
{CLASS = HistorySubmenu; LANGUAGE = ObjC; SUPERCLASS = NSMenu; },
{
ACTIONS = {
aboutPlugins = id;
@ -231,6 +225,12 @@
LANGUAGE = ObjC;
OUTLETS = {mBrowserView = id; mWindow = id; };
SUPERCLASS = NSObject;
},
{
CLASS = TopLevelHistoryMenu;
LANGUAGE = ObjC;
OUTLETS = {mItemBeforeHistoryItems = NSMenuItem; };
SUPERCLASS = HistorySubmenu;
}
);
IBVersion = 1;

View File

@ -22,6 +22,7 @@
*
* Contributor(s):
* Joe Hewitt <hewitt@netscape.com> (Original Author)
* Stuart Morgan <stuart.morgan@alumni.case.edu>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
@ -39,11 +40,11 @@
#import <AppKit/AppKit.h>
@class HistoryDataSource;
@class HistoryItem;
@interface HistoryMenu : NSMenu
// A class that builds and maintains a menu heirarchy parallel to some portion
// of the history backend.
@interface HistorySubmenu : NSMenu
{
HistoryItem* mRootItem; // root history item for this menu (retained)
HistoryItem* mAdditionalItemsParent; // may also contain children of this item (retained)
@ -67,7 +68,9 @@
@end
@interface GoMenu : HistoryMenu
// Encapsulates all of the logic of building, displaying, and handling the
// top-level "History" menu.
@interface TopLevelHistoryMenu : HistorySubmenu
{
IBOutlet NSMenuItem* mItemBeforeHistoryItems; // the item after which we add history items.
HistoryItem* mTodayItem; // the "Today" history group

View File

@ -38,7 +38,7 @@
*
* ***** END LICENSE BLOCK ***** */
#import "GoMenu.h"
#import "HistoryMenu.h"
#import "NSString+Utils.h"
#import "NSMenu+Utils.h"
@ -65,12 +65,12 @@ static const unsigned int kMaxTitleLength = 50;
// this little class manages the singleton history data source, and takes
// care of shutting it down at XPCOM shutdown time.
@interface GoMenuHistoryDataSourceOwner : NSObject
@interface HistoryMenuDataSourceOwner : NSObject
{
HistoryDataSource* mHistoryDataSource;
}
+ (GoMenuHistoryDataSourceOwner*)sharedGoMenuHistoryDataSourceOwner;
+ (HistoryMenuDataSourceOwner*)sharedHistoryMenuDataSourceOwner;
+ (HistoryDataSource*)sharedHistoryDataSource; // just a shortcut
- (HistoryDataSource*)historyDataSource;
@ -78,20 +78,20 @@ static const unsigned int kMaxTitleLength = 50;
@end
@implementation GoMenuHistoryDataSourceOwner
@implementation HistoryMenuDataSourceOwner
+ (GoMenuHistoryDataSourceOwner*)sharedGoMenuHistoryDataSourceOwner
+ (HistoryMenuDataSourceOwner*)sharedHistoryMenuDataSourceOwner
{
static GoMenuHistoryDataSourceOwner* sHistoryOwner = nil;
static HistoryMenuDataSourceOwner* sHistoryOwner = nil;
if (!sHistoryOwner)
sHistoryOwner = [[GoMenuHistoryDataSourceOwner alloc] init];
sHistoryOwner = [[HistoryMenuDataSourceOwner alloc] init];
return sHistoryOwner;
}
+ (HistoryDataSource*)sharedHistoryDataSource
{
return [[GoMenuHistoryDataSourceOwner sharedGoMenuHistoryDataSourceOwner] historyDataSource];
return [[HistoryMenuDataSourceOwner sharedHistoryMenuDataSourceOwner] historyDataSource];
}
- (id)init
@ -130,12 +130,12 @@ static const unsigned int kMaxTitleLength = 50;
return mHistoryDataSource;
}
@end // GoMenuHistoryDataSourceOwner
@end // HistoryMenuDataSourceOwner
#pragma mark -
@interface HistoryMenu(Private)
@interface HistorySubmenu(Private)
- (NSString*)menuItemTitleForHistoryItem:(HistoryItem*)inItem;
@ -152,7 +152,7 @@ static const unsigned int kMaxTitleLength = 50;
#pragma mark -
@implementation HistoryMenu
@implementation HistorySubmenu
- (NSString*)menuItemTitleForHistoryItem:(HistoryItem*)inItem
{
@ -179,7 +179,7 @@ static const unsigned int kMaxTitleLength = 50;
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(historyChanged:)
name:kNotificationNameHistoryDataSourceChanged
object:[GoMenuHistoryDataSourceOwner sharedHistoryDataSource]];
object:[HistoryMenuDataSourceOwner sharedHistoryDataSource]];
// register for menu display
[[NSNotificationCenter defaultCenter] addObserver:self
@ -222,7 +222,7 @@ static const unsigned int kMaxTitleLength = 50;
// We could optimize by only changing single menu items if itemOnlyChanged is true. Normally this will also be a visit
// date change, which we can ignore.
//BOOL itemOnlyChanged = [[[inNotification userInfo] objectForKey:kNotificationHistoryDataSourceChangedUserInfoChangedItemOnly] boolValue];
// If rootChangedItem is nil, the whole history tree is being rebuilt.
// We need to clear our root item, because it will become invalid. We'll set it again when we rebuild.
if (!rootChangedItem) {
@ -284,7 +284,7 @@ static const unsigned int kMaxTitleLength = 50;
keyEquivalent:@""] autorelease];
[newItem setImage:[curChild iconAllowingLoad:NO]];
HistoryMenu* newSubmenu = [[HistoryMenu alloc] initWithTitle:itemTitle];
HistorySubmenu* newSubmenu = [[HistorySubmenu alloc] initWithTitle:itemTitle];
[newSubmenu setRootHistoryItem:curChild];
[newItem setSubmenu:newSubmenu];
@ -333,7 +333,7 @@ static const unsigned int kMaxTitleLength = 50;
id repObject = [sender representedObject];
if ([repObject isKindOfClass:[HistoryItem class]]) {
NSString* itemURL = [repObject url];
// XXX share this logic with MainController and HistoryOutlineViewDelegate
BrowserWindowController* bwc = [(MainController *)[NSApp delegate] mainWindowBrowserController];
if (bwc) {
@ -363,14 +363,14 @@ static const unsigned int kMaxTitleLength = 50;
#pragma mark -
@interface GoMenu(Private)
@interface TopLevelHistoryMenu(Private)
- (void)appLaunchFinished:(NSNotification*)inNotification;
- (NSMenuItem*)todayMenuItem;
@end
@implementation GoMenu
@implementation TopLevelHistoryMenu
- (NSString*)menuItemTitleForHistoryItem:(HistoryItem*)inItem
{
@ -379,7 +379,7 @@ static const unsigned int kMaxTitleLength = 50;
if ([inItem respondsToSelector:@selector(isTodayCategory)] &&
[(HistoryDateCategoryItem*)inItem isTodayCategory])
{
return NSLocalizedString(@"GoMenuEarlierToday", nil);
return NSLocalizedString(@"TopLevelHistoryMenuEarlierToday", nil);
}
return [super menuItemTitleForHistoryItem:inItem];
@ -416,13 +416,13 @@ static const unsigned int kMaxTitleLength = 50;
if (mAppLaunchDone) {
// the root item is nil at launch, and if the history gets totally rebuilt
if (!mRootItem) {
HistoryDataSource* dataSource = [GoMenuHistoryDataSourceOwner sharedHistoryDataSource];
HistoryDataSource* dataSource = [HistoryMenuDataSourceOwner sharedHistoryDataSource];
[dataSource loadLazily];
mRootItem = [[dataSource rootItem] retain];
}
}
[super menuWillBeDisplayed];
}
@ -437,7 +437,7 @@ static const unsigned int kMaxTitleLength = 50;
NSMenuItem* todayMenuItem = [self todayMenuItem];
[mTodayItem autorelease];
mTodayItem = [[(HistoryMenu*)[todayMenuItem submenu] rootItem] retain];
mTodayItem = [[(HistorySubmenu*)[todayMenuItem submenu] rootItem] retain];
// Promote the kMaxTodayItems most recent items into the top-level menu.
unsigned int maxItems = std::min(kMaxTodayItems, [[mTodayItem children] count]);
@ -463,9 +463,14 @@ static const unsigned int kMaxTitleLength = 50;
// Prevent the "Earlier Today" menu from showing the promoted items,
// and remove it if nothing is left.
[(HistoryMenu*)[todayMenuItem submenu] setNumLeadingItemsToIgnore:maxItems];
if ([[mTodayItem children] count] <= maxItems)
[self removeItem:todayMenuItem];
[(HistorySubmenu*)[todayMenuItem submenu] setNumLeadingItemsToIgnore:maxItems];
if ([[mTodayItem children] count] <= maxItems) {
int todayMenuIndex = [self indexOfItem:todayMenuItem];
[self removeItemAtIndex:todayMenuIndex];
// If that was the only day folder, we have an extra separator now.
if ([[self itemAtIndex:todayMenuIndex] isSeparatorItem])
[self removeItemAtIndex:todayMenuIndex];
}
}
}
@ -475,7 +480,7 @@ static const unsigned int kMaxTitleLength = 50;
NSMenuItem* menuItem;
while ((menuItem = [menuEnumerator nextObject])) {
if ([[menuItem submenu] respondsToSelector:@selector(rootItem)]) {
HistoryItem* historyItem = [(HistoryMenu*)[menuItem submenu] rootItem];
HistoryItem* historyItem = [(HistorySubmenu*)[menuItem submenu] rootItem];
if ([historyItem respondsToSelector:@selector(isTodayCategory)] &&
[(HistoryDateCategoryItem*)historyItem isTodayCategory])
{