mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-01 06:35:42 +00:00
Fix the menu title and enabled state of the Show/Hide bookmarks item when toggling bookmarks. No bug.
This commit is contained in:
parent
e35d06c35e
commit
cff8ff9bf3
@ -725,7 +725,38 @@ Otherwise, we return the URL we originally got. Right now this supports .url and
|
||||
[mAddBookmarkMenuItem setEnabled:inBrowserWindowFrontmost];
|
||||
[mCreateBookmarksFolderMenuItem setEnabled:inBrowserWindowFrontmost];
|
||||
[mCreateBookmarksSeparatorMenuItem setEnabled:YES];
|
||||
[mShowAllBookmarksMenuItem setEnabled:YES]; // always enabled.
|
||||
|
||||
|
||||
// We need the frontmost browser for the case of the dl/about window
|
||||
// is the main so we can ensure the "show/hide all bookmarks" has the correct
|
||||
// state for that window. Unfortunately, we can't rely on |-getFrontmostBrowserWindow| in all
|
||||
// cases, such as when a window has just been opened. As a result, first
|
||||
// try |-getMainWindowBrowserController| and if that fails use fFBW as a fallback.
|
||||
BrowserWindowController* browserController = [self getMainWindowBrowserController];
|
||||
if (!browserController)
|
||||
browserController = (BrowserWindowController*)[[self getFrontmostBrowserWindow] windowController];
|
||||
|
||||
BOOL showBookmarksEnabled = YES;
|
||||
BOOL useShowLabel = YES;
|
||||
|
||||
if (browserController)
|
||||
{
|
||||
if ([browserController bookmarkManagerIsVisible])
|
||||
{
|
||||
useShowLabel = NO;
|
||||
showBookmarksEnabled = [browserController canHideBookmarks];
|
||||
}
|
||||
else
|
||||
{
|
||||
useShowLabel = YES;
|
||||
}
|
||||
}
|
||||
|
||||
NSString* showBMLabel = useShowLabel ? NSLocalizedString(@"Show All Bookmarks", @"")
|
||||
: NSLocalizedString(@"Hide All Bookmarks", @"");
|
||||
|
||||
[mShowAllBookmarksMenuItem setTitle:showBMLabel];
|
||||
[mShowAllBookmarksMenuItem setEnabled:showBookmarksEnabled];
|
||||
}
|
||||
|
||||
- (NSView*)getSavePanelView
|
||||
|
@ -251,6 +251,7 @@ typedef enum
|
||||
- (IBAction)manageHistory: (id)aSender;
|
||||
|
||||
- (BOOL)bookmarkManagerIsVisible;
|
||||
- (BOOL)canHideBookmarks;
|
||||
- (BOOL)singleBookmarkIsSelected;
|
||||
|
||||
- (void)createNewTab:(ENewTabContents)contents;
|
||||
|
@ -1311,6 +1311,12 @@ enum BWCOpenDest {
|
||||
return [mURLBar userHasTyped];
|
||||
}
|
||||
|
||||
- (void)contentViewChangedTo:(NSView*)inView forURL:(NSString*)inURL
|
||||
{
|
||||
// update bookmarks menu
|
||||
[[NSApp delegate] adjustBookmarksMenuItemsEnabling:[[self window] isMainWindow]];
|
||||
}
|
||||
|
||||
- (void)updateFromFrontmostTab
|
||||
{
|
||||
[[self window] setTitle: [mBrowserView windowTitle]];
|
||||
@ -1466,7 +1472,9 @@ enum BWCOpenDest {
|
||||
if ([self bookmarkManagerIsVisible])
|
||||
[self back:aSender];
|
||||
else
|
||||
[self loadURL:@"about:bookmarks" referrer:nil activate:YES allowPopups:YES];
|
||||
[self loadURL:@"about:bookmarks" referrer:nil activate:YES allowPopups:NO];
|
||||
|
||||
[[NSApp delegate] adjustBookmarksMenuItemsEnabling:[[self window] isMainWindow]];
|
||||
}
|
||||
|
||||
//
|
||||
@ -1847,6 +1855,11 @@ enum BWCOpenDest {
|
||||
return [currentURL isEqualToString:@"about:bookmarks"] || [currentURL isEqualToString:@"about:history"];
|
||||
}
|
||||
|
||||
- (BOOL)canHideBookmarks
|
||||
{
|
||||
return [self bookmarkManagerIsVisible] && [[mBrowserView getBrowserView] canGoBack];
|
||||
}
|
||||
|
||||
- (BOOL)singleBookmarkIsSelected
|
||||
{
|
||||
if (![self bookmarkManagerIsVisible])
|
||||
|
@ -68,6 +68,8 @@ class nsISupportsArray;
|
||||
|
||||
- (BOOL)userChangedLocationField;
|
||||
|
||||
- (void)contentViewChangedTo:(NSView*)inView forURL:(NSString*)inURL;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
|
@ -391,15 +391,14 @@ static NSString* const kOfflineNotificationName = @"offlineModeChanged";
|
||||
|
||||
- (void)checkForCustomViewOnLoad:(NSString*)inURL
|
||||
{
|
||||
NSView* newView = [self contentProviderViewForURL:inURL];
|
||||
if (newView)
|
||||
NSView* newContentView = [self contentProviderViewForURL:inURL];
|
||||
if (!newContentView)
|
||||
newContentView = mBrowserView; // put the browser view back
|
||||
|
||||
if ([self firstSubview] != newContentView)
|
||||
{
|
||||
[self swapFirstSubview:newView];
|
||||
}
|
||||
else
|
||||
{
|
||||
// put the browser view back
|
||||
[self swapFirstSubview:mBrowserView];
|
||||
[self swapFirstSubview:newContentView];
|
||||
[mDelegate contentViewChangedTo:newContentView forURL:inURL];
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user