version 1.25, 2002/04/18 00:27:51
|
version 1.26, 2002/04/19 07:58:30
|
Line 60
|
Line 60
|
{ |
{ |
[super init]; |
[super init]; |
mBookmarks = nsnull; |
mBookmarks = nsnull; |
mCachedParent = nsnull; |
|
mCachedHref = nil; |
mCachedHref = nil; |
return self; |
return self; |
} |
} |
Line 106
|
Line 105
|
if (!mBookmarks) |
if (!mBookmarks) |
return; |
return; |
|
|
nsCOMPtr<nsIContent> content; | BookmarkItem* item = nil; |
if (aUseSel) { |
if (aUseSel) { |
int index = [mOutlineView selectedRow]; |
int index = [mOutlineView selectedRow]; |
|
|
if (index >= 0) { |
if (index >= 0) { |
BookmarkItem* item = [mOutlineView itemAtRow: index]; | item = [mOutlineView itemAtRow: index]; |
if ([mOutlineView isExpandable: item]) | if ([mOutlineView numberOfSelectedRows] != 1 || ![mOutlineView isExpandable: item]) |
content = [item contentNode]; | item = nil; |
} |
} |
} |
} |
|
|
if (!content) |
|
mBookmarks->GetRootContent(getter_AddRefs(content)); |
|
|
|
mCachedParent = content; |
|
|
|
nsCOMPtr<nsIDOMDocument> domDoc(do_QueryInterface(mBookmarks->gBookmarks)); |
nsCOMPtr<nsIDOMDocument> domDoc(do_QueryInterface(mBookmarks->gBookmarks)); |
|
|
// Fetch the title of the current page and the URL. |
// Fetch the title of the current page and the URL. |
Line 162
|
Line 156
|
[textField setStringValue: [NSString stringWithCharacters: title.get() length: nsCRT::strlen(title.get())]]; |
[textField setStringValue: [NSString stringWithCharacters: title.get() length: nsCRT::strlen(title.get())]]; |
|
|
[mBrowserWindowController cacheBookmarkDS: self]; |
[mBrowserWindowController cacheBookmarkDS: self]; |
|
|
|
// Build up the folder list. |
|
NSPopUpButton* popup = [mBrowserWindowController getAddBookmarkFolder]; |
|
BookmarksService::ConstructAddBookmarkFolderList(popup, item); |
|
|
[NSApp beginSheet: [mBrowserWindowController getAddBookmarkSheetWindow] |
[NSApp beginSheet: [mBrowserWindowController getAddBookmarkSheetWindow] |
modalForWindow: [mBrowserWindowController window] |
modalForWindow: [mBrowserWindowController window] |
Line 197
|
Line 195
|
[mCachedHref release]; |
[mCachedHref release]; |
elt->SetAttribute(NS_LITERAL_STRING("href"), href); |
elt->SetAttribute(NS_LITERAL_STRING("href"), href); |
} |
} |
|
|
|
// Figure out the parent element. |
|
nsCOMPtr<nsIDOMElement> parentElt; |
|
nsCOMPtr<nsIContent> parentContent; |
|
NSPopUpButton* popup = [mBrowserWindowController getAddBookmarkFolder]; |
|
NSMenuItem* selectedItem = [popup selectedItem]; |
|
int tag = [selectedItem tag]; |
|
if (tag == -1) { |
|
mBookmarks->GetRootContent(getter_AddRefs(parentContent)); |
|
parentElt = do_QueryInterface(parentContent); |
|
} |
|
else { |
|
BookmarkItem* item = [(BookmarksService::gDictionary) objectForKey: [NSNumber numberWithInt: tag]]; |
|
// Get the content node. |
|
parentContent = [item contentNode]; |
|
parentElt = do_QueryInterface(parentContent); |
|
} |
|
|
nsCOMPtr<nsIDOMElement> parent(do_QueryInterface(mCachedParent)); |
|
nsCOMPtr<nsIDOMNode> dummy; |
nsCOMPtr<nsIDOMNode> dummy; |
parent->AppendChild(elt, getter_AddRefs(dummy)); | parentElt->AppendChild(elt, getter_AddRefs(dummy)); |
|
|
nsCOMPtr<nsIContent> childContent(do_QueryInterface(elt)); |
nsCOMPtr<nsIContent> childContent(do_QueryInterface(elt)); |
mBookmarks->BookmarkAdded(mCachedParent, childContent); | mBookmarks->BookmarkAdded(parentContent, childContent); |
} |
} |
|
|
-(IBAction)deleteBookmarks: (id)aSender |
-(IBAction)deleteBookmarks: (id)aSender |
Line 741 void BookmarksService::EnsureToolbarRoot
|
Line 755 void BookmarksService::EnsureToolbarRoot
|
} |
} |
} |
} |
|
|
|
static |
|
void RecursiveAddBookmarkConstruct(NSPopUpButton* aPopup, NSMenu* aMenu, int aTagToMatch) |
|
{ |
|
// Get the menu item children. |
|
NSArray* children = [aMenu itemArray]; |
|
int startPosition = 0; |
|
if (aMenu == BookmarksService::gBookmarksMenu) |
|
startPosition = 3; |
|
|
|
int count = [children count]; |
|
for (int i = startPosition; i < count; i++) { |
|
NSMenuItem* menuItem = [children objectAtIndex: i]; |
|
NSMenu* submenu = [menuItem submenu]; |
|
if (submenu) { |
|
// This is a folder. Add it to our list and then recur. |
|
[aPopup addItemWithTitle: [menuItem title]]; |
|
NSMenuItem* lastItem = [aPopup lastItem]; |
|
if ([menuItem tag] == aTagToMatch) |
|
[aPopup selectItem: lastItem]; |
|
|
|
[lastItem setTag: [menuItem tag]]; |
|
RecursiveAddBookmarkConstruct(aPopup, submenu, aTagToMatch); |
|
} |
|
} |
|
} |
|
|
|
void |
|
BookmarksService::ConstructAddBookmarkFolderList(NSPopUpButton* aPopup, BookmarkItem* aItem) |
|
{ |
|
[aPopup removeAllItems]; |
|
[aPopup addItemWithTitle: [gBookmarksMenu title]]; |
|
NSMenuItem* lastItem = [aPopup lastItem]; |
|
[lastItem setTag: -1]; |
|
int tag = -1; |
|
if (aItem) { |
|
nsIContent* content = [aItem contentNode]; |
|
PRUint32 utag; |
|
content->GetContentID(&utag); |
|
tag = (int)utag; |
|
} |
|
RecursiveAddBookmarkConstruct(aPopup, gBookmarksMenu, tag); |
|
} |
|
|
void |
void |
BookmarksService::ConstructBookmarksMenu(NSMenu* aMenu, nsIContent* aContent) |
BookmarksService::ConstructBookmarksMenu(NSMenu* aMenu, nsIContent* aContent) |
{ |
{ |