"Cannot make menu separator anywhere but in bookmark menu" b=223337 sr=pinkerton

This commit is contained in:
joshmoz%gmail.com 2005-01-07 06:02:43 +00:00
Родитель 3b52333710
Коммит 69d44a4fb9
5 изменённых файлов: 54 добавлений и 43 удалений

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

@ -101,22 +101,25 @@
[aItem retain];
[mItem release];
mItem = aItem;
[self setTitle:[aItem title]];
[self setImage:[aItem icon]];
[self setTarget:self];
if ([aItem isKindOfClass:[Bookmark class]])
{
if ([aItem isKindOfClass:[Bookmark class]]) {
if ([(Bookmark *)aItem isSeparator]) {
[self setTitle:nil];
return;
}
[self setAction:@selector(openBookmark:)];
[self setToolTip:[(Bookmark *)aItem url]];
}
else
{
else {
[[self cell] setClickHoldTimeout:0.5];
if ([(BookmarkFolder *)aItem isGroup])
[self setAction:@selector(openBookmark:)];
else
[self setAction:@selector(showFolderPopupAction:)];
}
[self setTitle:[aItem title]];
[self setImage:[aItem icon]];
[self setTarget:self];
}
- (void)bookmarkChanged:(BOOL*)outNeedsReflow

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

@ -483,11 +483,7 @@ NSString* BookmarkFolderDockMenuChangeNotificaton = @"bf_dmc";
} else if ([aChild isKindOfClass:[Bookmark class]]){
if ([aNewParent isRoot])
return;
if ((isSeparator = [(Bookmark *)aChild isSeparator])) {
BookmarkFolder *menuFolder = [[BookmarkManager sharedBookmarkManager] bookmarkMenuFolder];
if ((aNewParent != menuFolder) && (![aNewParent isChildOfItem: menuFolder]))
return;
}
isSeparator = [(Bookmark *)aChild isSeparator];
}
[undoManager beginUndoGrouping];
// What we do depends on if we're moving into a new folder, or just

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

@ -398,10 +398,6 @@ static unsigned gFirstUserCollection = 0;
} else if ([aBookmark isKindOfClass:[Bookmark class]]) {
if (parent == [self rootBookmarks])
return NO;
BookmarkFolder *menuFolder = [self bookmarkMenuFolder];
if ([aBookmark isSeparator] &&
((![parent isChildOfItem:menuFolder]) && (parent != menuFolder)))
return NO;
}
if ([parent isChildOfItem:aBookmark])
return NO;

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

@ -149,11 +149,12 @@ static const int kBMBarScanningStep = 5;
if ([mButtons count] == count)
return;
for (unsigned int i = 0; i < count; i ++)
{
for (unsigned int i = 0; i < count; i++) {
BookmarkButton* button = [self makeNewButtonWithItem:[toolbar objectAtIndex:i]];
[self addSubview: button];
[mButtons addObject: button];
if (button) {
[self addSubview:button];
[mButtons addObject:button];
}
}
if ([self isShown])
[self reflowButtons];
@ -174,6 +175,8 @@ static const int kBMBarScanningStep = 5;
-(void)addButton:(BookmarkItem*)aItem atIndex:(int)aIndex
{
BookmarkButton* button = [self makeNewButtonWithItem:aItem];
if (!button)
return;
[self addSubview: button];
[mButtons insertObject: button atIndex: aIndex];
if ([self isShown])
@ -202,11 +205,9 @@ static const int kBMBarScanningStep = 5;
-(void)removeButton:(BookmarkItem*)aItem
{
int count = [mButtons count];
for (int i = 0; i < count; i++)
{
for (int i = 0; i < count; i++) {
BookmarkButton* button = [mButtons objectAtIndex: i];
if ([button bookmarkItem] == aItem)
{
if ([button bookmarkItem] == aItem) {
[mButtons removeObjectAtIndex: i];
[button removeFromSuperview];
if (count > i && [self isShown])
@ -242,19 +243,19 @@ static const int kBMBarScanningStep = 5;
float curRowYOrigin = kBookmarkToolbarTopPadding;
float curX = kBookmarkButtonHorizPadding;
for (int i = 0; i < count; i ++)
{
BookmarkButton* button = [mButtons objectAtIndex: i];
NSRect buttonRect;
if (i < aIndex)
{
for (int i = 0; i < count; i++) {
BookmarkButton* button = [mButtons objectAtIndex:i];
BookmarkItem *item = [button bookmarkItem];
NSRect buttonRect;
if ([item isKindOfClass:[Bookmark class]] && [(Bookmark *)item isSeparator]){
continue;
}
else if (i < aIndex) {
buttonRect = [button frame];
curRowYOrigin = NSMinY(buttonRect) - kBookmarkButtonVerticalPadding;
curX = NSMaxX(buttonRect) + kBookmarkButtonHorizPadding;
}
else
{
else {
[button sizeToFit];
float width = [button frame].size.width;
@ -264,8 +265,7 @@ static const int kBMBarScanningStep = 5;
buttonRect = NSMakeRect(curX, curRowYOrigin + kBookmarkButtonVerticalPadding, width, kBookmarkButtonHeight);
curX += NSWidth(buttonRect) + kBookmarkButtonHorizPadding;
if (NSMaxX(buttonRect) > NSWidth([self bounds]))
{
if (NSMaxX(buttonRect) > NSWidth([self bounds])) {
// jump to the next line
curX = kBookmarkButtonHorizPadding;
curRowYOrigin += (kBookmarkButtonHeight + 2 * kBookmarkButtonVerticalPadding);
@ -280,8 +280,7 @@ static const int kBMBarScanningStep = 5;
float computedHeight = curRowYOrigin + (kBookmarkButtonHeight + 2 * kBookmarkButtonVerticalPadding + kBookmarkToolbarBottomPadding);
// our size has changed, readjust our view's frame and the content area
if (computedHeight != oldHeight)
{
if (computedHeight != oldHeight) {
[super setFrame: NSMakeRect([self frame].origin.x, [self frame].origin.y + (oldHeight - computedHeight),
[self frame].size.width, computedHeight)];

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

@ -277,11 +277,25 @@ static unsigned int TableViewSolidVerticalGridLineMask = 1;
[mContainerPane editColumn:0 row:index withEvent:nil select:YES];
}
-(IBAction) addSeparator:(id)aSender;
-(IBAction)addSeparator:(id)aSender;
{
Bookmark *aBookmark = [[Bookmark alloc] init];
[aBookmark setIsSeparator:YES];
[[[BookmarkManager sharedBookmarkManager] bookmarkMenuFolder] insertChild:aBookmark];
BookmarkFolder *parentFolder = nil;
unsigned index = 0;
if ([mItemPane numberOfSelectedRows] == 1){
int row = [mItemPane selectedRow];
BookmarkItem *item = [mItemPane itemAtRow:row];
if ([item respondsToSelector:@selector(parent)]) {
parentFolder = [item parent];
index = [parentFolder indexOfObject:item] + 1;
}
}
if (!parentFolder) {
parentFolder = [self activeCollection];
index = [parentFolder count];
}
[parentFolder insertChild:aBookmark atIndex:index isMove:NO];
}
-(void)addItem:(id)aSender isFolder:(BOOL)aIsFolder URL:(NSString*)aURL title:(NSString*)aTitle
@ -289,8 +303,7 @@ static unsigned int TableViewSolidVerticalGridLineMask = 1;
// We ALWAYS use the selected item to determine the parent.
BookmarkFolder *parentFolder = nil;
BookmarkItem* item = nil;
if ([mItemPane numberOfSelectedRows] == 1)
{
if ([mItemPane numberOfSelectedRows] == 1) {
// There is only one selected row. If it is a folder, use it as our parent.
// Otherwise, use selected row's parent.
int index = [mItemPane selectedRow];
@ -807,7 +820,12 @@ static unsigned int TableViewSolidVerticalGridLineMask = 1;
- (void) selectContainer:(int)inRowIndex
{
[mContainerPane selectRow:inRowIndex byExtendingSelection:NO];
[mAddSeparatorButton setEnabled:(inRowIndex == kBookmarkMenuContainerIndex)];
BookmarkFolder *activeCollection = [mRootBookmarks objectAtIndex:inRowIndex];
BOOL enableSeparator = YES;
if ([activeCollection isRoot] || [activeCollection isSmartFolder]) {
enableSeparator = NO;
}
[mAddSeparatorButton setEnabled:enableSeparator];
if (inRowIndex == kHistoryContainerIndex) {
[mItemPane setDataSource:mHistorySource];
[mItemPane setDelegate:mHistorySource];
@ -820,7 +838,6 @@ static unsigned int TableViewSolidVerticalGridLineMask = 1;
else {
[mItemPane setDataSource:self];
[mItemPane setDelegate:self];
BookmarkFolder *activeCollection = [mRootBookmarks objectAtIndex:inRowIndex];
[self setActiveCollection:activeCollection];
[self restoreFolderExpandedStates];
[mItemPane setTarget:self];