fix a large number of context menu and bookmark info bugs and cleanup the

code. see http://bugzilla.mozilla.org/show_bug.cgi?id=245710#c11 for a
comprehensive list (bug 245710)
This commit is contained in:
pinkerton%aol.net 2004-06-16 06:09:47 +00:00
Родитель 0feb2db55b
Коммит 26ee61eb3e
11 изменённых файлов: 70 добавлений и 49 удалений

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

@ -25,7 +25,7 @@
<key>826</key>
<string>84 401 213 60 0 0 1152 746 </string>
<key>894</key>
<string>276 641 156 66 0 0 1152 746 </string>
<string>311 722 156 68 0 0 1280 832 </string>
<key>919</key>
<string>337 341 606 458 0 0 1280 832 </string>
</dict>
@ -37,6 +37,10 @@
<integer>910</integer>
<integer>889</integer>
</array>
<key>IBOpenObjects</key>
<array>
<integer>894</integer>
</array>
<key>IBSystem Version</key>
<string>7F44</string>
</dict>

Двоичные данные
camino/resources/localized/English.lproj/BrowserWindow.nib/objects.nib сгенерированный

Двоичный файл не отображается.

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

@ -743,7 +743,7 @@ const int kReuseWindowOnAE = 2;
browserController = (BrowserWindowController*)[[self getFrontmostBrowserWindow] windowController];
if (browserController) {
if ([browserController bookmarksAreVisible:NO])
if ([browserController bookmarksAreVisible:NO allowMultipleSelection:NO])
[mToggleSidebarMenuItem setTitle:NSLocalizedString(@"Hide All Bookmarks", @"")];
else
[mToggleSidebarMenuItem setTitle:NSLocalizedString(@"Show All Bookmarks", @"")];

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

@ -21,6 +21,7 @@
*
* Contributor(s):
* David Haas <haasd@cae.wisc.edu>
* Josh Aas <josha@mac.com>
*
*
* Alternatively, the contents of this file may be used under the terms of
@ -46,9 +47,11 @@
@class KindaSmartFolderManager;
@class RunLoopMessenger;
#define kBookmarkMenuContainerIndex 0
#define kToolbarContainerIndex 1
#define kHistoryContainerIndex 2
enum {
kBookmarkMenuContainerIndex = 0,
kToolbarContainerIndex = 1,
kHistoryContainerIndex = 2,
};
// check 1 bookmark every 2 minutes, but only if we haven't been there in a day
#define kTimeBeforeRecheckingBookmark 86400.0

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

@ -481,7 +481,7 @@ static unsigned gFirstUserCollection = 0;
NSString * menuTitle;
// open in new window
if (isFolder || (outlineView && ([outlineView numberOfSelectedRows] > 1)))
if (isFolder)
menuTitle = NSLocalizedString(@"Open Tabs in New Window", @"");
else
menuTitle = NSLocalizedString(@"Open in New Window", @"");
@ -490,7 +490,7 @@ static unsigned gFirstUserCollection = 0;
[contextMenu addItem:menuItem];
// open in new tab
if (isFolder || ([outlineView numberOfSelectedRows] > 1))
if (isFolder)
menuTitle = NSLocalizedString(@"Open in New Tabs", @"");
else
menuTitle = NSLocalizedString(@"Open in New Tab", @"");
@ -530,7 +530,11 @@ static unsigned gFirstUserCollection = 0;
}
id parent = [item parent];
if ([parent isKindOfClass:[BookmarkFolder class]] && ![parent isSmartFolder]) {
// if we're not in a smart collection (other than history)
if (!outlineView ||
![target isKindOfClass:[BookmarkViewController class]] ||
![[target activeCollection] isSmartFolder] ||
([target activeCollection] == [self historyFolder])) {
// space
[contextMenu addItem:[NSMenuItem separatorItem]];
// delete

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

@ -103,6 +103,7 @@
-(void) restoreFolderExpandedStates;
-(BOOL) isExpanded:(id)anItem;
-(BOOL) haveSelectedRow;
-(int)numberOfSelectedRows;
-(void) setItem:(BookmarkFolder *)anItem isExpanded:(BOOL)aBool;
-(void) setActiveCollection:(BookmarkFolder *)aFolder;
-(BookmarkFolder *)activeCollection;

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

@ -24,6 +24,7 @@
* Max Horn <max@quendi.de>
* David Haas <haasd@cae.wisc.edu>
* Simon Woodside <sbwoodside@yahoo.com>
* Josh Aas <josha@mac.com>
*
*
* Alternatively, the contents of this file may be used under the terms of
@ -418,7 +419,7 @@ static unsigned int TableViewSolidVerticalGridLineMask = 1;
// container (bookmark menu, toolbar bookmarks, etc), clear the item panel's selection entirely,
// which will fall back to checking the selected container panel's selection. If
// the manager is visible, don't muck with the selection.
if (![mBrowserWindowController bookmarksAreVisible:NO]) {
if (![mBrowserWindowController bookmarksAreVisible:NO allowMultipleSelection:NO]) {
[self displayBookmarkInOutlineView:parentFolder];
long parentRow = [mItemPane rowForItem:parentFolder]; // will be -1 if top-level container
if (parentRow >= 0)
@ -677,7 +678,8 @@ static unsigned int TableViewSolidVerticalGridLineMask = 1;
// update buttons
[mAddBookmarkButton setEnabled:inCanEdit];
[mAddFolderButton setEnabled:inCanEdit];
[mInfoButton setEnabled:inCanEdit];
// if editable and something is selected, then enable get info button, otherwise disable it
[mInfoButton setEnabled:(inCanEdit && ([mItemPane numberOfSelectedRows] == 1))];
}
-(void) setActiveCollection:(BookmarkFolder *)aFolder
@ -799,7 +801,7 @@ static unsigned int TableViewSolidVerticalGridLineMask = 1;
- (void) selectContainer:(int)inRowIndex
{
[mContainerPane selectRow:inRowIndex byExtendingSelection:NO];
if ( inRowIndex == kHistoryContainerIndex ) {
if (inRowIndex == kHistoryContainerIndex) {
[mItemPane setDataSource:mHistorySource];
[mItemPane setDelegate:mHistorySource];
[mHistorySource loadLazily];
@ -819,11 +821,14 @@ static unsigned int TableViewSolidVerticalGridLineMask = 1;
[self setCanEditSelectedContainerContents:NO];
else
[self setCanEditSelectedContainerContents:YES];
[mItemPane setDeleteAction: @selector(deleteBookmarks:)];
if ( kBookmarkMenuContainerIndex == inRowIndex )
[mAddSeparatorButton setEnabled:YES];
else
[mAddSeparatorButton setEnabled:NO];
// if its a smart folder, but not the history folder
if ([[self activeCollection] isSmartFolder] && (inRowIndex != kHistoryContainerIndex)) {
[mItemPane setDeleteAction:nil];
}
else {
[mItemPane setDeleteAction:@selector(deleteBookmarks:)];
}
[mAddSeparatorButton setEnabled:(kBookmarkMenuContainerIndex == inRowIndex)];
}
[mItemPane reloadData];
}
@ -1002,14 +1007,14 @@ static unsigned int TableViewSolidVerticalGridLineMask = 1;
-(NSMenu *)tableView:(NSTableView *)aTableView contextMenuForRow:(int)rowIndex
{
if (aTableView == mContainerPane) {
NSMenu* contextMenu = nil;
if (rowIndex >= 0) {
contextMenu = [aTableView menu];
int numItems = [contextMenu numberOfItems];
while (numItems > 2)
[contextMenu removeItemAtIndex:(--numItems)];
NSMenu *contextMenu = [[[aTableView menu] copy] autorelease];
if ([aTableView numberOfSelectedRows] > 0) {
[contextMenu addItem:[NSMenuItem separatorItem]];
NSMenuItem *useAsDockItem = [[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"Use as Dock Menu", @"Use as Dock Menu") action:@selector(setAsDockMenuFolder:) keyEquivalent:[NSString string]];
[useAsDockItem setTarget:self];
[contextMenu addItem:useAsDockItem];
[useAsDockItem release];
if (rowIndex >= (int)[[BookmarkManager sharedBookmarkManager] firstUserCollection]) {
[contextMenu addItem:[NSMenuItem separatorItem]];
NSMenuItem *deleteItem = [[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"Delete",@"Delete") action:@selector(deleteCollection:) keyEquivalent:[NSString string]];
[deleteItem setTarget:self];
[contextMenu addItem:deleteItem];
@ -1178,6 +1183,10 @@ static unsigned int TableViewSolidVerticalGridLineMask = 1;
[mItemPane reloadItem: item reloadChildren: aReloadChildren];
}
- (int)numberOfSelectedRows {
return [mItemPane numberOfSelectedRows];
}
- (BOOL)haveSelectedRow
{
return ([mItemPane selectedRow] != -1);
@ -1186,19 +1195,16 @@ static unsigned int TableViewSolidVerticalGridLineMask = 1;
-(void)outlineViewSelectionDidChange: (NSNotification*) aNotification
{
BookmarkInfoController *bic = [BookmarkInfoController sharedBookmarkInfoController];
int index = [mItemPane selectedRow];
if (index == -1)
{
if ([mItemPane numberOfSelectedRows] == 1) {
[mInfoButton setEnabled:YES];
if ([[bic window] isVisible]) {
[bic setBookmark:[mItemPane itemAtRow:[mItemPane selectedRow]]];
}
}
else {
[mInfoButton setEnabled:NO];
[bic close];
}
else
{
id item = [mItemPane itemAtRow: index];
[mInfoButton setEnabled:YES];
if ([[bic window] isVisible])
[bic setBookmark:item];
}
}
/*

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

@ -253,7 +253,7 @@ typedef enum
- (IBAction)manageBookmarks: (id)aSender;
- (IBAction)manageHistory: (id)aSender;
- (IBAction)toggleSidebar:(id)aSender;
- (BOOL)bookmarksAreVisible:(BOOL)inRequireSelection;
- (BOOL)bookmarksAreVisible:(BOOL)inRequireSelection allowMultipleSelection:(BOOL)allowMultipleSelection;
- (void)createNewTab:(ENewTabContents)contents;

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

@ -1766,13 +1766,18 @@ static NSArray* sToolbarDefaults = nil;
[mBookmarkViewController addItem: self isFolder: aIsFolder URL:aURL title:aTitle];
}
- (BOOL)bookmarksAreVisible:(BOOL)inRequireSelection
// if bookmarks are visible, but say no if selection required and there isn't one
// if bookmarks aren't visible, or selection not required, then value for allowMultipleSelection is ignored
- (BOOL)bookmarksAreVisible:(BOOL)inRequireSelection allowMultipleSelection:(BOOL)allowMultipleSelection
{
BOOL bookmarksShowing = [mContentView isBookmarkManagerVisible];
if (inRequireSelection)
bookmarksShowing &= ([mBookmarkViewController haveSelectedRow]);
// trying to make this logic as clear as possible
if (bookmarksShowing && inRequireSelection) {
bookmarksShowing = [mBookmarkViewController haveSelectedRow];
if (bookmarksShowing && !allowMultipleSelection) {
bookmarksShowing = [mBookmarkViewController numberOfSelectedRows] <= 1;
}
}
return bookmarksShowing;
}
@ -2581,7 +2586,7 @@ static NSArray* sToolbarDefaults = nil;
- (BOOL)canGetInfo
{
return [self bookmarksAreVisible:YES];
return [self bookmarksAreVisible:YES allowMultipleSelection:NO];
}
- (BOOL)shouldShowBookmarkToolbar

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

@ -187,7 +187,6 @@
id item;
int rowIndex;
NSPoint point;
point = [self convertPoint:[theEvent locationInWindow] fromView:nil];
rowIndex = [self rowAtPoint:point];
@ -199,12 +198,11 @@
item = [self itemAtRow:rowIndex];
if (item) {
id delegate = [self delegate];
// If the item was not selected, select it now
if (![self isRowSelected:rowIndex]) {
if (![delegate respondsToSelector:@selector(outlineView:shouldSelectItem:)]
|| [delegate outlineView:self shouldSelectItem:item])
[self selectRow:rowIndex byExtendingSelection:NO];
// Make sure the item is the only selected one
if (![delegate respondsToSelector:@selector(outlineView:shouldSelectItem:)]
|| [delegate outlineView:self shouldSelectItem:item]) {
[self deselectAll:self]; // we don't want anything but what was right-clicked selected
[self selectRow:rowIndex byExtendingSelection:NO];
}
if ([delegate respondsToSelector:@selector(outlineView:contextMenuForItem:)])

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

@ -85,13 +85,13 @@
if (![self isRowSelected:rowIndex]) {
if ([delegate respondsToSelector:@selector(tableView:shouldSelectRow:)]) {
if (![delegate tableView:self shouldSelectRow:rowIndex])
return nil;
return [self menu];
}
}
if ([delegate respondsToSelector:@selector(tableView:contextMenuForRow:)])
return [delegate tableView:self contextMenuForRow:rowIndex];
}
return nil;
return [self menu];
}
//