mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-11 20:35:50 +00:00
hook up cmd-1..9 to load the Nth bookmark from the bookmark bar (bug 317186)
This commit is contained in:
parent
4bee5b5fce
commit
2d8ce84ddb
@ -52,8 +52,8 @@
|
||||
|
||||
typedef enum EBookmarkOpenBehavior
|
||||
{
|
||||
eBookmarkOpenBehavior_Preferred, // simply opens the bookmark
|
||||
eBookmarkOpenBehavior_NewWindowOrTab, // opens the bookmark in a new tab/window, depending on the pref
|
||||
eBookmarkOpenBehavior_Preferred, // opens the bookmark based on key combo and prefs
|
||||
eBookmarkOpenBehavior_ForceReuse, // ignore prefs and key combo, reuse the current browser
|
||||
eBookmarkOpenBehavior_NewWindow,
|
||||
eBookmarkOpenBehavior_NewTab
|
||||
};
|
||||
|
@ -524,6 +524,12 @@ const int kReuseWindowOnAE = 2;
|
||||
}
|
||||
break;
|
||||
|
||||
case eBookmarkOpenBehavior_ForceReuse:
|
||||
openInNewTab = NO;
|
||||
openInNewWindow = NO;
|
||||
newTabInBackground = NO;
|
||||
break;
|
||||
|
||||
case eBookmarkOpenBehavior_NewTab:
|
||||
openInNewTab = YES;
|
||||
newTabInBackground = browserWindowController && loadNewTabsInBackgroundPref;
|
||||
|
@ -105,6 +105,7 @@ static const int kEscapeKeyCode = 53;
|
||||
// Pass command-return off to the controller so that locations/searches may be opened in a new tab.
|
||||
// Pass command-plus off to the controller to enlarge the text size.
|
||||
// Pass command-shift-r off to the controller for force-reload.
|
||||
// Pass command-1..9 to the controller to load that bookmark bar item
|
||||
- (BOOL)performKeyEquivalent:(NSEvent *)theEvent
|
||||
{
|
||||
BrowserWindowController* windowController = (BrowserWindowController*)[self delegate];
|
||||
@ -121,6 +122,11 @@ static const int kEscapeKeyCode = 53;
|
||||
} else if (keyChar == 'R') { // Capital letter implies shift key.
|
||||
[windowController reload:nil]; // The window controller does the check for the shift key.
|
||||
handled = YES;
|
||||
} else if (keyChar >= '1' && keyChar <= '9') {
|
||||
// use |forceReuse| to disable looking at the modifier keys since we know the command
|
||||
// key is down right now.
|
||||
[windowController loadBookmarkBarIndex:(keyChar - '1') openBehavior:eBookmarkOpenBehavior_ForceReuse];
|
||||
handled = YES;
|
||||
}
|
||||
|
||||
if (handled)
|
||||
|
@ -38,6 +38,7 @@
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#import "BrowserWrapper.h"
|
||||
#import "Find.h"
|
||||
#import "MainController.h"
|
||||
|
||||
class nsIURIFixup;
|
||||
class nsIBrowserHistory;
|
||||
@ -356,4 +357,7 @@ typedef enum
|
||||
// handle command-return in location or search field
|
||||
- (BOOL)handleCommandReturn:(BOOL)aShiftIsDown;
|
||||
|
||||
// Load the item in the bookmark bar given by |inIndex| using the given behavior.
|
||||
- (BOOL)loadBookmarkBarIndex:(unsigned short)inIndex openBehavior:(EBookmarkOpenBehavior)inBehavior;
|
||||
|
||||
@end
|
||||
|
@ -62,7 +62,6 @@
|
||||
#import "SearchTextField.h"
|
||||
#import "SearchTextFieldCell.h"
|
||||
#import "STFPopUpButtonCell.h"
|
||||
#import "MainController.h"
|
||||
#import "DraggableImageAndTextCell.h"
|
||||
#import "MVPreferencesController.h"
|
||||
#import "ViewCertificateDialogController.h"
|
||||
@ -3760,6 +3759,21 @@ enum BWCOpenDest {
|
||||
return [mBrowserView currentCharset];
|
||||
}
|
||||
|
||||
//
|
||||
// -loadBookmarkBarIndex:
|
||||
//
|
||||
// Load the item in the bookmark bar given by |inIndex| using the given behavior.
|
||||
// Uses the top-level |-loadBookmark:...| in order to get the right behavior with folders and
|
||||
// tab groups.
|
||||
//
|
||||
- (BOOL)loadBookmarkBarIndex:(unsigned short)inIndex openBehavior:(EBookmarkOpenBehavior)inBehavior
|
||||
{
|
||||
BookmarkItem* item = [[[BookmarkManager sharedBookmarkManager] toolbarFolder] objectAtIndex:inIndex];
|
||||
if (item)
|
||||
[[NSApp delegate] loadBookmark:item withWindowController:self openBehavior:inBehavior];
|
||||
return YES;
|
||||
}
|
||||
|
||||
//
|
||||
// - handleCommandReturn:
|
||||
//
|
||||
@ -3947,3 +3961,4 @@ int TabBarVisiblePrefChangedCallback(const char* inPref, void* inBWC)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user