Camino only - Bug 529500: Add a notification when history is cleared, and key recent page menu reset off of that. r/sr=pink

git-svn-id: svn://10.0.0.236/trunk@260318 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
stuart.morgan%alumni.case.edu
2010-05-16 19:48:40 +00:00
parent dfe45d010b
commit 9ae3c77105
3 changed files with 20 additions and 9 deletions

View File

@@ -418,6 +418,12 @@ static const unsigned int kMaxTitleLength = 50;
selector:@selector(browserClosed:)
name:kBrowserInstanceClosedNotification
object:nil];
// Listen for history being cleared.
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(historyCleared:)
name:kNotificationNameHistoryDataSourceCleared
object:[HistoryMenuDataSourceOwner sharedHistoryDataSource]];
}
- (void)appLaunchFinished:(NSNotification*)inNotification
@@ -581,15 +587,6 @@ static const unsigned int kMaxTitleLength = 50;
if (!rootChangedItem) {
[mTodayItem release];
mTodayItem = nil;
// We can get here either when the history is being cleared (in which case
// we will already have an mRootItem) or when we are doing the lazy
// construction of the root item as the menu is shown (in which case
// mRootItem is still |nil|). If it's the former, clear the recently closed
// pages as well.
if (mRootItem) {
[mRecentlyClosedMenu release];
mRecentlyClosedMenu = [[NSMenu alloc] initWithTitle:NSLocalizedString(@"RecentlyClosed", nil)];
}
}
else if (mTodayItem == rootChangedItem ||
mTodayItem == [rootChangedItem parentItem])
@@ -600,4 +597,9 @@ static const unsigned int kMaxTitleLength = 50;
[super historyChanged:inNotification];
}
- (void)historyCleared:(NSNotification*)inNotification {
[mRecentlyClosedMenu release];
mRecentlyClosedMenu = [[NSMenu alloc] initWithTitle:NSLocalizedString(@"RecentlyClosed", nil)];
}
@end

View File

@@ -58,6 +58,9 @@ extern NSString* const kNotificationHistoryDataSourceChangedUserInfoChangedItem;
// if true, this indicates that just the item changed, not its children (it's an NSNumber with bool)
extern NSString* const kNotificationHistoryDataSourceChangedUserInfoChangedItemOnly;
// Sent when history is cleared. Notification object is the data source.
extern NSString* const kNotificationNameHistoryDataSourceCleared;
@class HistoryTreeBuilder;
@interface HistoryDataSource : NSObject

View File

@@ -72,6 +72,7 @@ NSString* const kHistoryViewFlat = @"flat";
NSString* const kNotificationNameHistoryDataSourceChanged = @"history_changed";
NSString* const kNotificationHistoryDataSourceChangedUserInfoChangedItem = @"changed_item";
NSString* const kNotificationHistoryDataSourceChangedUserInfoChangedItemOnly = @"item_only";
NSString* const kNotificationNameHistoryDataSourceCleared = @"history_cleared";
struct SortData
{
@@ -1146,6 +1147,11 @@ NS_IMPL_ISUPPORTS1(nsNavHistoryObserver, nsINavHistoryObserver);
{
[mHistoryItems removeAllObjects];
[mHistoryItemsDictionary removeAllObjects];
[[NSNotificationCenter defaultCenter]
postNotificationName:kNotificationNameHistoryDataSourceCleared
object:self
userInfo:nil];
}
#pragma mark -