Camino only - Bug 340099: Highlight bookmark bar buttons when using Cmd-1 through 9. r=stridey sr=pink

This commit is contained in:
stuart.morgan%alumni.case.edu 2006-12-27 17:54:32 +00:00
Родитель 580476d74e
Коммит 6cfbdedfd4
4 изменённых файлов: 41 добавлений и 14 удалений

Просмотреть файл

@ -73,4 +73,6 @@
- (IBAction)addFolder:(id)aSender;
- (void)momentarilyHighlightButtonAtIndex:(int)aIndex;
@end

Просмотреть файл

@ -307,6 +307,22 @@ static void VerticalGrayGradient(void* inInfo, float const* inData, float* outDa
[self reflowButtonsStartingAtIndex:0];
}
- (void)momentarilyHighlightButtonAtIndex:(int)aIndex
{
BookmarkButton* button = [mButtons objectAtIndex:aIndex];
[button highlight:YES];
[NSTimer scheduledTimerWithTimeInterval:0.2
target:self
selector:@selector(unhighlightButton:)
userInfo:(id)button
repeats:NO];
}
- (void)unhighlightButton:(NSTimer*)timer
{
[(BookmarkButton*)[timer userInfo] highlight:NO];
}
#define kBookmarkButtonHeight 16.0
#define kMinBookmarkButtonWidth 16.0
#define kMaxBookmarkButtonWidth 150.0

Просмотреть файл

@ -127,8 +127,7 @@ static const int kEscapeKeyCode = 53;
if (cmdKeyIsDown) {
// 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;
handled = [windowController loadBookmarkBarIndex:(keyChar - '1') openBehavior:eBookmarkOpenBehavior_ForceReuse];
}
}
//Alpha shortcuts need to be handled differently because layouts like Dvorak-Qwerty Command give

Просмотреть файл

@ -4605,26 +4605,36 @@ enum BWCOpenDest {
//
- (BOOL)loadBookmarkBarIndex:(unsigned short)inIndex openBehavior:(EBookmarkOpenBehavior)inBehavior
{
// We don't want to trigger bookmark bar loads if the bookmark bar isn't visible
if (![mPersonalToolbar isVisible])
return NO;
NSArray* bookmarkBarChildren = [[[BookmarkManager sharedBookmarkManager] toolbarFolder] childArray];
unsigned int loadableItemIndex = 0; // holds the number of loadable items we've cycled through
NSEnumerator* enumerator = [bookmarkBarChildren objectEnumerator];
id item;
unsigned int bookmarkBarCount = [bookmarkBarChildren count];
unsigned int i;
int loadableItemIndex = -1;
BookmarkItem* item;
// We cycle through all the toolbar items. When we've skipped enough loadable items
// (ie loadableItemIndex > inIndex), we've gotten there and |item| is the bookmark we want to load.
while ((loadableItemIndex <= inIndex) && (item = [enumerator nextObject])) {
// Only if it's a real non-seperator bookmark, or a tab group
// (i.e., loadableItemIndex == inIndex), we've gotten there and |item| is the bookmark we want to load.
for (i = 0; i < bookmarkBarCount; ++i) {
item = [bookmarkBarChildren objectAtIndex:i];
// Only real (non-seperator) bookmarks and tab groups count
if (([item isKindOfClass:[Bookmark class]] && ![(Bookmark *)item isSeparator]) ||
([item isKindOfClass:[BookmarkFolder class]] && [(BookmarkFolder *)item isGroup]))
++loadableItemIndex;
{
if (++loadableItemIndex == inIndex)
break;
}
}
if (item)
if (loadableItemIndex == inIndex) {
[[NSApp delegate] loadBookmark:item withBWC:self openBehavior:inBehavior reverseBgToggle:NO];
else // We ran out of toolbar items before finding the nth loadable one
NSBeep();
return YES;
[mPersonalToolbar momentarilyHighlightButtonAtIndex:i];
return YES;
}
// We ran out of toolbar items before finding the nth loadable one
return NO;
}
//